Silk Test Tutorial
Silk Test Tutorial
Introduction
Silk Test is a tool specifically designed for doing REGRESSION AND FUNCTIONALITY testing. It is developed by Segue Software Inc. Silk Test is the industrys leading functional testing product for e-business applications, whether Window based, Web, Java, or traditional client/server-based. Silk Test also offers test planning, management, direct database access and validation, the flexible and robust 4Test scripting language, a built in recovery system for unattended testing, and the ability to test across multiple platforms, browsers and technologies. You have two ways to create automated tests using silktest: 1. Use the Record Testcase command to record actions and verification steps as you navigate through the application. 2. Write the testcase manually using the Visual 4Test scripting language.
1. Record Testcase
The Record / Testcase command is used to record actions and verification steps as you navigate through the application. Tests are recorded in an object-oriented language called Visual 4Test. The recorded testreads like a logical trace of all of the steps that were completed by the user. The Silk Test point and click verification system allows you to record the verification step by selecting from a list of properties that are appropriate for the type of object being tested. For example, you can verify the text is stored in a text field.
varies by the data that it carries. Since far fewer tests are written with this approach, changes in the GUI will result in reduced effort in updating tests. A data-driven test design also allows for the externalization of testcase data and makes it possible to divide the responsibilities for developing testing requirements and for developing test automation. For example, it may be that a group of domain experts create the Testplan Detail while another group of test engineers develop tests to satisfy those requirements. In a script file, an automated testcase ideally addresses one test requirement. Specifically, a 4Test function that begins with the test case keyword and contains a sequence of 4Test statements. It drives an application to the state to be tested, verifies that the application works as expected, and returns the application to its base state. A script file is a file that contains one or more related testcases. A script file has a .t extension, such as find .t Other Segue products The Silk products include Sit Test for functional and regression testing Silk Performer for load and performance simulation Silk Pilot for functional and regression testing CORBA and EJB servers Silk Radar for automated defet tracking Silk Vision for enterprise application health monitoring Silk Express for a scalability and load testing consulting solution.
Test Suite Integration with other silk products. Silk Test Architecture Normal use of an application consists of a person manipulating a keyboard and mouse to initiate application operations. The person is said to be interacting with the GUI (Graphical User Interface). During Silk Test testing, Silk Test interacts with the GUI to submit operations to the application automatically. Thus Silk Test can simulate the actions of a person who is exercising all the capabilities of an application and verifying the results of each operation. The simulated user (Silk test) is said to be driving the application. The application under test reacts to the simulated user exactly as it would react to a human rest. Silk Test consists of two distinct software components that execute in separate
processes :
Silk Test host software The Silk Test host software is the program you use to develop, edit, compile, run and debug your 4Test scripts and test plans. This manual refers to the system that runs this program as the host machine or the Silk Test machine. The Agent The 4Test Agent is the software process that translates the commands in your 4Test scripts into GUI-specific commands. In order words, it is the Agent that actually drives and monitors the application you are testing. One Agent can run locally on the host machine. In a networked environment, any number of Agents can run on remote machines. This manual refers to the systems that run remote Agents as target machines. This manual refers to the systems that run remote Agents as target machines. In a client/server environment, Silk Test drives the client application by means of an Agent process running on each applications machine. The application then drives the server just as it always does. Silk Test is also capable of driving the GUI belonging to a server or of directly driving a server database by running scripts that submit SQL statements to the database. These methods o directly manipulating the server application are intended to support testing in which the client application drives the server.
System Requirements :
The minimum requirement, a system needs to run the silk test is given below :
Windows NT, Windows 95, 98 or 2000 Pentium 466 Mhz or better processor (application dependent) 32 MB RAM 60MB Hard Disk Supported Environments: Netscape Navigator 4.x Internet Explorer 4 and 5 Active X, Visual Basic 5 and 6 Java JDK 1.3 Swing 1.1 Microsoft Web browser control
4Tests flow of control features. Running testcases and interpreting results Next, run one or more testcases, either by running a collection of scripts, called a suite, or, if you are using the testplan editor, by running specific portions of the testplan. As each testcase runs, statistics are written to a results file. The results file and its associated comparison tools allow you to quickly pinpoint the problems in your application. A Test Frame The test frame is the backbone that supports the testcases and scripts. It is a file that contains all the information about the applications GUI objects that Silk Test needs when you record testcases. This information minimally consists of a declaration for each GUI object, but can also include any data that you want to associate with each GUI object, as well as any new classes and methods that you want to define. A window declaration specifies a cross-platform, logical name for a GUI object, called the identifier, and maps the identifier to the objects actual name, called the tag. Because the testcases use logical names, if the objects actual name changes on the current GUI, on another GUI, or in a localized version of the application, only the tag in the window declarations need to be changed; dont need to change any of the scripts. Variables, functions, methods, properties can be added to the basic window declarations recorded by Silk Test. To record declarations for the main window and menu hierarchy of your application. 1. Start up your application and Silktest. 2. Select File / New. The New dialog appears. 3. Select the Test Frame radio button and click OK. The New Test Frame dialog is displayed, allowing to create a test. 4. Frame file for an application displayed in the Application list box. 5. Select the application fro the Application list box. If a Web application is tested, different fields are seen. 6. Click OK. The new test frame file is created. The file contains the 4Test declarations for the main window and all its menus, as well as a generic declaration that is valid for each of the standard message boxes in the application.
A Test Plan
A Testplan is made up of a large amount of information, a structured, hierarchical outline provides an ideal model for organizing and developing the details of the plan. A testplan consists of two distinct parts An outline that describes the test requirements Statement that connect the outline to the 4Test scripts and testcases that implement the test requirements. Using the testplan, we can create and run tests. To start a new testplan : Select File / New Select Testplan and click OK. An empty testplan window opens.
A Test Suite
A Test Suite is a collection of test scripts. Consider a case that we are having a set of script (.t) file. If we want to run these scripts against our application, we have to select the required testcase or we have to run the entire script file. But after the completion of that script file, the user has to manually change that to the next script file to run those testcases available in that script. Instead of that silktest provides a way to continuously select a set of script files and run those script files at-a-stretch. This can be done by creating a new Test Suite file and declare the needed script files in that suite file. To start a new test suite: 1. Select File / New. 2. Select Test Suite and click OK. 3. In that suite file enter the script file names to run continuously. 4. Save that script file. 5. Compile the script file and run it. 6. Now the process of running the script will not stop after the completion of the first script file, instead of that it will automatically pass to the next script file and run the testcases available there. Assume a case where there is a folder called silk scripts in c drive with five test script files. Here in the suite file, we are calling all the script files instead of running those script files separately. The suite file will look like as given below : use c:\silkscripts.\script.t" use c:\silkscripts.\script2t" use "c:\silkscripts./script3.t" use "c:\silkscripts\script4.t" use "c:\silkscripts\5."
A Test script
A testscript file contains various testcases for various test conditions. A Testcase In a script file, a testcase ideally addresses one test requirement. Specifically, a 4Test function that begins with the testcase keyword and contains a sequence of 4Test statements. It drives an application to the state to be tested, verifies that the application works as expected, and returns the application to its base state. In the silktest tool, select the File -> Now option the menu bar. In the resulting dialog box �New�, there will be options for selecting different kind of files. Select the file type 4� test script� option. It will open a new script file. Before start writing the testcase, declare the necessary file that is to be used in that script file. Start with the keyword �testcase� followed by the testcase name. The name of the testcase is whatever as selected by the user. But make sure that by looking at the name of the testcase, the objective of the testcase should be understandable. Start the tests from the scratch so that the silktest will start eh application and to the
testing from the base state. Use necessary conditions / loops if necessary. At the end of each and every script, print a statement to know whether the test case has achieved its objective or not. The user can make sure that the particular part of the application is error free by looking at the message you print. Try to make the testcase effective and time consuming (say) by keeping the second tests continue from the place where the first test finishes. A sample testcase for registering into the yahoo mail. Testcase registration () Browser.LoadPage "mail.yoo.com") Sign In YahooMail.SetActive () SignIn Yahoo.Mail.objSingIn YahooMail.SignUp.Now.Click() Sleep (3) WelcomeTo Yahoo.Set Active Welcome To yahoo.objWelcomeToYahoo.LastName.SetText("lastname") Welcome To Yahoo.objWelcomeToYahoo.LanguageConten1.Select(5) WelcomeTo Yahoo.objWelcome ToYahoo.ContactMeOccassionally About.Click () Welcome To Yahoo.objWelcome To Yahoo.Submit ThisForm.Click() If Registration Success.Exists () Print ("Test Pass") else logerror ("Test Fail")
hen you start Silk Test the first time (or whenever you start and have no open windows), the QuickStart Wizard is displayed automatically. You can also invoke the wizard at any time by selecting File/New and clicking the Quickstart Wizard icon. You can use the Quickstart wizard to : 1. Create a testplan You simply name the file (giving it the .pln extension) and its directory. 2. Create a test frame, Which contains descriptions of the GUI objects in your application that you want to test. As prompted, you simply open your application and open the various windows and dialogs that you want to test in the application. The wizard automatically records all the declarations in a file called frame.inc. You don�t have to do any coding. 3. Record testcases You name the testcase and provide a description for the testplan, then simply record the testcase. Again, you don�t have to do any coding. The wizard automatically sages the testcase in script (.t) file with the same name as the testplan. Run testcases.
Wizard and are asked to confirm that the test is what you want. 13. Click Next. 14. Run the test by clicking the Run Test Button. 15. The wizard reports the results. You an move the wizard to the side and look at the results file that is created whenever you run a test. 16. In the wizard, click Next to save your testcase. The testcase is saved in a script (.t) file with the same name as testplan (in this case, edit.t) 17. Click Close to close the wizard. You see a window containing the results file from the test you just ran. In another window is the testplan.
tool bar. To run the entire set of testcases in a testscript file, click the ==> icon or select the Run - > Run option. If there is any syntax error in the script file, it will show that if you move to the next line of the code. But the other errors are known only at the time of compilation or during the run. To open a new or existing files In Silktest, Select the File -> New menu from the menu bar. (or) select from the white icon in the left top corner of the window. It will ask for various kind of files to open. Select the 4Test include file to declare the window objects from the application. The 4Test Script file option is to open the script file where we will be writ ing testscript. The above two files are more important for building the scripts. Open the application you want to test. If you are going to test the Yahoo site, then open the browser load the page you want to start testing. The page that you start testing the application will be assumed as the BaseState. Even we can explicitly declare the window base state. The Test Script file will be used only after creating the include file. We will be using the include file to write the script file. Hence we have to declare the include file that we are calling in the testscript files. To open an existing file, select File -> Open and select the existing file. To write a new plug & play testcase (using Action) This example is to write the script for logging into the yahoo site. Start the Silk Test by selecting from the Start menu. Configure the settings as given in lab I. Click File -> New menu, and select the 4Test script file option. Click on the OK button. Start with the keyword testcase Action () and press Enter key in your keyboard. The testcase is the default keyword for any testcase and the name Action is the name of the testcase. The testcase name can be anything but it is advisable to name it clearly so that will represent the functionality of the test. Now start writing the testcase (Follow the below instructions) Open the application in parallel ie., open the browser in which the application has to run. (say Netscape) Go to Silk Test Click Record -> Actions. Menu from the menu bar. It will load the Record Actions dialog box. Keep the dialog box as it is, go to the application and do the action what ever you want to perform. The silktest will record the events you do sequentially and you can vie it in the Record Actions dialog. After completing your task (till whatever you want to record), click on the paste to editor button in the Record Action dialog box. Then click the close button to close the Record actions dialog box and go to your
application. Now the recorded code will be readily available in the testscript editor, inside the testcase. Now delete the keyword recording in your first line of the recorded code. Now, select the entire recorded code by keeping the mouse arrow at the leftmost dot (.) in your editor at the first line, and drag it till the end. Right click on the selected code and select the Move Left option. The code is ready now. Now, compile the code from the Run -> compile option and run the script by selecting the Run -> Run menu. Now the testcase will automatically start the application and perform the events recorded and throws the results. The sample recorded testcase for yahoo login look like this : Testcase Action () // [-] recording Browserpage.Set Active () Browser.Location.Set Text (www.yahoo.com) Browser.Location. Type Keys () Yahoo.HtmlLink (Mail| #26|$http:??Yahoo! () BrowserPage.HtmlTextField(Yahoo!ID: | # 1). SetPosition (1, 1) BrowserPage.HtmlTextField(Yahoo!ID: | # 1). Set Text (username) BrowserPage.HtmlTextField(Yahoo!ID: | # 1). TypeKeys () BrowserPage.HtmlTextField(Password:|#2).Set Text (password) BrowserPage.HtmlPushButton (Sign In|#1). Click ()
testcases. But to make the code clear we use different files for different purposes. If no testcases is written in a file (include), then the include file can be compiled but cannot be run. It will show error that the file does not contain any testcases. Only the file with the testcase present will be allowed to run. Before running the scripts, separate declaration file have to be written (for declaring the objects) and the script file (for writing scripts using that declaration file) and compile them. The steps to be followed for running the scripts are as below. Open the silk test tool. Open the script (*.t) file that has to be run. Compile the script by selecting the Run-> Compile menu from the menu bar (or) from the compile icon. It will compile that particular script and the other related files, called by that script. The user can confirm that by looking at the progress status (in yellow color) in the bottom-right corner of the silktest too. If there is any error, the error details are displayed in the compile time. The user has to make necessary changes. Then, select the Run-> Testcase from the menu bar (or) else select the Run icon. The testcases can be run by selectively or at-a-stretch. If the selective method is selected, it will ask for the testcase to be run from a list of testcases. After selecting the testcase and start running, the silktest will automatically start the application and start the test from the basestate. Recording the Events / Action Writing scripts in SilkTest includes steps of commands with declaration of window names and its objects before that. To avoid these difficulties and to make the process easier (this is an alternate for writing line-by-line steps of the scripts) silktest provides a special feature of recording events.
Yahoo.HtmlLink (Mail|#26|$http:??Yahoo!) BrowserPage.HtmlTextField (Yahoo!ID:| #1). SetPosition (1,1) BrowserPage.HtmlTextField(Yahoo!ID: | # 1). Set Text (username) BrowserPage.HtmlTextField(Yahoo!ID: | # 1). TypeKeys () BrowserPage.HtmlTextField(Password:|#2).Set Text (password) BrowserPage.HtmlPushButton (Sign In|#1). Click () The alternate for the above recorded statements will be as below: Browser.Loadpage (Yahoo!) // Loads the yahoo homepage as the default page if Yahoo.Exists() // checking for the existence of the homepage print (Yahoo window exists) // confirming that the window exists Yahoo.objYahoo.Loginname.SetText (username) Yahoo.objYahoo.Password.SetText (password) Yahoo.objYahoo.Submit.Click() The difference between the above two different scripts are, the method II needs windows & its objects to declared before the scripts are to be written. It is not in the case of the recording kind of the code. SILK TEST FEATURES
Platform Independent
Silk Test doesnt care about how the application is created, in which software the application is written, what kind of design is used, which browser it is being worked, in which operating system the application is running. All that needs for an application to be tested using silktest is that it needs a frame (like window)
Browser Independent
There are various kinds of browsers used by various people for running their applications. The user may use any browser of his choice to test the standard application. Each and every browser acts differently with different applications. They show the same page differently. The web objects they display can also be aligned or displayed in different manner. SilkTest just looks at these browser contents as objects and hence they cannot avoid any images, texts, that they are not identifiable. Also we can write a test in one browser and run it in any other browser (to some extend). i.e, using SilkTest, we can do cross browser testing. With minor modifications, your tests are robust enough to support different browsers and different versions of these browsers. Technology Independent Silktest does not care how the application was built. It seamlessly works with the different web technologies commonly used today. How to use the same code for multiple browsers: Start writing the silk scripts. Capture the window declarations (.inc file) and write the .t file. Say if you are capturing the declarations from Internet Explorer & run successfully on it. As we captured the declarations from I.E., we now have to make the same test case run on Netscape since the tag value changes from multiple browsers. Testing the Windows based applications