http://www.geocities.

com/pammal_sureshbabu/silktest/ SilkTest Tutorial
Testing The primary reasons to test the applications are to identify the defects and measure the quality of the application. Types of testing Different kinds of testing There are different types of tests that can be executed depending on the objectives of the test engineer. Error testing Verify the product’s responses to error conditions. These tests ensure that the responses are meaningful, correct, and may include the display of context-sensitive, error-specific help screens. Reviewing error message lists may help to identify each error which can be generated by a specific screen or module. Stress testing Measure the system’s response to large amounts of data. This may include singleusers manipulating large sets of data, or multiple machines running the application simultaneously. White - Box testing Places the focus on the internal structure of the software. Tests are designed using the code and the functional specification as input. Black - Box testing Views the software from the end-user perspective, and is unaware of the underlying code. Distributed testing Is concerned about the behavior of the client software as well as the data being stored and manipulated at the server. This may include verification of startup data, modifications to tables, verification that cascading deletes are correct, and that dependencies between database tables are correct. Multi - User testing Includes concurrency tests which verify the interaction of two simultaneous users on two separate machines. For example, if one user locks a record, a second user may receive an error message when attempting to lock the same record. Stress testing

verifies the response of the system when a large number of users are connected to the database. Other types of tests verify that a process on one machine is capable of initiating a process on another machine. SilkTest overview SilkTest: SilkTest is a tool specifically designed for doing regression1 and functionality testing. It is developed by Segue Software Inc. SilkTest is the industry's leading functional testing product for e-business applications, whether Window based, Web, Java, or traditional client/server-based. SilkTest also offers test planning and 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. The version of SilkTest which is being used is the 5.0.3. 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 2 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 test reads like a logical trace of all of the steps that were completed by the user. The SilkTest 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 that is stored in a text field. 2. Write the testcase manually We can write tests that are capable of accomplishing many variations on a test. The key here is re-use. A testcase can be designed to take parameters including input data and expected results. This “data-driven” testcase is really an instance of a class of testcases that performs certain steps to drive and verify the application-undertest. Each instance 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.
1

A set of baseline tests that are run against each new build of an application to determine if the current build has regressed in quality from the previous one. 2 In a script file3 , an automated testcase that 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. 3 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 SilkTest for functional and regression testing SilkPerformer for load and performance simulation SilkPilot for functional and regression testing CORBA and EJB servers SilkRadar for automated defect tracking SilkVision for enterprise application health monitoring SilkExpress for a scalability and load testing consulting

solution

Features of silktest SilkTest Features: Some of the features of silktest are given below. • • • • • • • • • • • • • • • • • • • • • Easy-to-use interface Built-in recovery system The object oriented concept Record & Play Multi-kind application testing Automatic generation of results Browser & Platform independent Distributed testing 24x365 unattended testing Power Testing with the 4Test Language Centralized Testing of Distributed Applications Distributed Access to Test Results Extensive Component Testing Cross-Platform Java Testing Testing Across Multiple Browsers and Windows Versions Support for HTML, XML, JavaScript, Java, ActiveX, Windows controls, and Visual Basic Single-recording testing for cross-platform Java testing with the SilkBean Against Over 35 Databases Link Tester Validation of Advanced Database Structures and Techniques Creation of o Test Plan o Test Frame o Test Suite Integration with other silk products.

SilkTest 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. SilkTest interacts with the GUI to submit operations to the application automatically. and debug your 4Test scripts and testplans. compile. The person is said to be interacting with the GUI (Graphical User Interface). SilkTest drives the client application by means of an Agent process running on each application’s machine. . The Agent The 4Test Agent is the software process that translates the commands in your 4Test scripts into GUI-specific commands.Components of silktest SilkTest architecture Normal use of an application consists of a person manipulating a keyboard and mouse to initiate application operations. • • • • SilkTest may not recognise some objects in a window / page due to some technical reasons. SilkTest consists of two distinct software components that execute in separate processes: • • The SilkTest host software The 4Test Agent software SilkTest host software The SilkTest host software is the program you use to develop. any number of Agents can run on remote machines. Sometimes it will be difficult to activate some window. edit. This manual refers to the systems that run remote Agents as target machines. This manual refers to the system that runs this program as the host machine or the SilkTest machine. SilkTest may not recognise some window frames. The 'tag' value may get changed frequently. In a networked environment. The simulated user (SilkTest) is said to be driving the application. The application then drives the server just as it always does. it is the Agent that actually drives and monitors the application you are testing. Thus SilkTest can simulate the actions of a person who is exercising all the capabilities of an application and verifying the results of each operation. Limitations of silktest Limitations of SilkTest: Some of the limitations of SilkTest are given below. During SilkTest testing. One Agent can run locally on the host machine. In other words. These methods of directly manipulating the server application are intended to support testing in which the client application drives the server. In a client/server environment. The application under test reacts to the simulated user exactly as it would react to a human user. run.

Windows 95. A basic testplan is structured as a hierarchical outline and contains: • • Descriptions of individual tests and groups of tests.x Internet Explorer 4 and 5 ActiveX. a system needs to run the silk test is given below. that accomplish the actual work of testing.1 Microsoft Web browser control The automated testing process The automated testing process The testing process has these four steps: 1 Creating a testplan (if you are using the testplan editor) 2 Recording a test frame 3 Creating testcases 4 Running testcases and interpreting their results Creating a testplan If the testplan editor is used.the automated testing process is started by creating a testplan. Visual Basic 5 and 6 Java JDK 1. Statements that link the test descriptions in the plan to the 4Test routines. System requirements The minimum requirement. In web based applications.As many levels of description can be used. 98 or 2000 Pentium 466 Mhz or better processor (application dependent) 32 MB RAM 60MB Hard Disk  Supported Environments: o o o o o o Netscape Navigator 4. Recording a test frame . called testcases. sometimes silktest will take the links as simple text. o o o o Windows NT.3 Swing 1.• • It may be necessary to make some modifications if testing should be shifted to other browser/operating system.

either by running a collection of scripts. The results file and its associated comparison tools allow you to quickly pinpoint the problems in your application. called the identifier.run one or more testcases. functions. Verify the state (this is the heart of the testcase). don’t need to change any of the scripts. called the identifier. A window declaration specifies a cross-platform. For maximum ease and power.Next. called the tag. statistics are written to a results file. if the object’s actual name changes on the current GUI.This information minimally consists of a declaration for each GUI object. called the tag. It is a file that contains all the information about the application’s GUI objects that SilkTest needs when you record testcases. Running testcases and interpreting results Next. and maps the identifier to the object’s actual name.these two approaches can be combined. called its class. To record declarations for the main window and menu hierarchy of your application: • Start up your application and Silktest. and properties can be added to the basic window declarations recorded by SilkTest.only the tag in the window declarations need to be changed. . called window declarations. on another GUI. Return the application to its original state. or. cross-platform name for a GUI object. of each of the GUI objects in your application. if you are using the testplan editor. called a suite. record a test frame. or in a localized version of the application. As each testcase runs. methods. the declaration indicates the type of the object. Creating testcases The 4Test commands in a testcase collectively perform three distinct actions: • • • Drive the application to the state to be tested. In addition. recording the basic testcase and then extending it using 4Test’s flow of control features. by running specific portions of the testplan. or to write the 4Test code manually if one is comfortable withprogramming languages. SilkTest file type: Test Frame A Test Frame The test frame is the backbone that supports the testcases and scripts. The powerful object-oriented recorder can be used to automatically capture these 4Test commands to interact with the application. and maps the identifier to the object’s actual name. which contains descriptions. but can also include any data that you want to associate with each GUI object.Variables. as well as any new classes and methods that you want to define. A window declaration specifies a logical. Because the testcases use logical names. logical name for a GUI object.

different fields are seen. Select the Test Frame radio button and click OK. This can be done by creating a new Test Suite file and declare the needed script files in that suite file. we have to select the required testcase or we have to run the the entire script file. To start a new testplan: • • Select File/New Select Testplan and click OK. a structured. Using the testplan. The file contains the 4Test declarations for the main window and all its menus.t) file.The new test frame file is created. Test Suite A Test Suite A Test Suite is a collection of test scripts. The New dialog appears. If we want run these scripts against our application. Instead of that silktest provides a way to continously select a set of script files and run those script files at-a-stretch. Click OK. Save that script file. we can create and run tests. But after the completion of that script file. hierarchical outline provides an ideal model for organizing and developing the details of the plan.The New Test Frame frame file for an application displayed in the Application list box. Consider a case that we are having a set of script (. An empty testplan window opens. . the user has to manually change that to the next script file to run those testcases available in that script. In that suite file enter the script file names to be run continously.• • • • • Select File/New. Select the application from the Application list box. To start a new test suite: • • • • Select File/New. as well as a generic declaration that is valid for each of the standard message boxes in the application. Test Plan A Test Plan A testplan is made up of a large amount of information.If a Web application is tested. A testplan consists of two distinct parts • • An outline that describes the test requirements Statements that connect the outline to the 4Test scripts and testcases that implement the test requirements. Select TestSuite and click OK.

and returns the application to its base state. Here in the suite file. Test Case In a script file.  Use necessary conditions / loops if necessary. // Clickinglinks. .  It will open a new script file. print a statement to know whether the testcase has achieved its objective or not.  In the silktest tool. a 4Test function that begins with the testcase keyword and contains a sequence of 4Test statements. a testcase ideally addresses one test requirement. Now the process of running the script will not stop after the completion of the first script file. A sample testcase for registering in to the yahoo mail.t” use “c:\silkscripts\script5.  Start with the keyword ‘testcase’ followed by the testcase name.  Select the file type ‘4 Test script’ option.t use “c:\silkscripts\script1. select the File -> New option from the menu  In the resulting dialog box ‘New’. instead of that it will automatically pass to the next script file and run the testcases available there. But make sure that by looking at the name of the testcase. Steps to create a testcase  bar. The suite file will look like as given below.  Start the tests from the scratch so that the silktest will start the application and do the testing from the base state. Specifically.t” use “c:\silkscripts\script4. The user can make sure that the particular part of the application is error free by looking at the message you print. there will be options for selecting different kind of files.t” use “c:\silkscripts\script2. the objective of the testcase should be understandable.• • Compile the script file and run it. The name of the testcase is whatever as selected by the user.  Before start writing the testcase.  Try to make the testcase effective and time consuming (say) by keeping the second tests continue from the place where the first tests finishes. declare the necessary file that is to be used in that script file. Assume a case where there is a folder called silkscripts in c drive with five test script files. It drives an application to the state to be tested. verifies that the application works as expected.  At the end of each and every script.t” use “c:\silkscripts\script3. we are calling all the script files instead of running those script files separately.t” Test Script A testscript file contains various testcases for various test conditions.

Set the path ''Firesip\Europa\software\silktest5.dat" file.0.Exists()  • else  Session II: Lab I : Installation of SilkTest SilkTest installation tips • • • • • • • Run the Silk Test setup from the CD or through the Network. After installing. In the installation process. It will ask for the default browser option. it will ask for the SilkTest/ SilkTest Agent only option.SetActive() • SignInYahooMail.objWelcomeToYahoo. During installation.1\licence' for the "licence. Note that you are allowed to select only one Browser option. then continue with that.objWelcomeToYahoo. it will open the SilkTest tool with the Quick start wizard open.Click() • sleep(3) • WelcomeToYahoo.objWelcomeToYahoo. For the ‘Will you be testing browsers?’ message box.objSignInYahooMail. By default SilkTest goes fine with Netscape browsers.1\silktest' directory in your Network Neighbourhood.Sele ct(5) • WelcomeToYahoo.SetText("las tname") • WelcomeToYahoo.testcase registration () • Browser. The quickstart wizard will assist you in creating various silk files.LoadPage("mail. Select the appropriate Browser you want to test the application using Silk Test.0.SubmitThisForm. If you are a first time user of silktest. it will ask for the licence file.Click() • if RegistrationSuccess.com") • SignInYahooMail. select “Yes” if you are going to test web based applications. logerror("Test Fail") print("Test Pass") • Getting started with the QuickStart Wizard .LanguageContent1.exe file to start the installation.SetActive • WelcomeToYahoo. The SilkTest software is available in the 'Firesip\Europa\software\silktest5.objWelcomeToYahoo.SignUpNow.yahoo.ContactMeOccasionallyA bout. Get in to the above folder and select the setup. Select the Silk Test option if you are installing this for testing applications in the stand-alone machine.LastName1.Click() • WelcomeToYahoo.

menus. click on the QuickStart Wizard title bar to see Text Editor added to the list of applications. which will organize and manage your tests. you are ready to create a testcase.If you are using SilkTest with the testplan editor. 5 Select Text Editor and click Next. The next step is to record the test frame. 7 Click Next.inc. Your test is now being recorded. When you start SilkTest the first time (or whenever you start and have no open windows). the wizard lists all the open (running and not minimized) applications. 4 To create a new test frame. 9 When you have finished capturing the windows and dialogs in Text Editor. You simply name the file (giving it the .inc in the same directory as your testplan. The wizard automatically records all the declarations in a file called frame. 2 Click Next.pln extension) and its directory. the wizard records all the declarations that SilkTest needs in a file called frame. you don’t have to do any coding. 3 Name the file edit.” Click Next. which contains descriptions of the GUI objects in your application that you want to test. 4 Run testcases. Now you will name a new testplan. the QuickStart Wizard is displayed automatically. 11 Name the test FindBox and enter the description “Verify controls in Find dialog. When you place the mouse pointer on a window or dialog. 6 The Capture Windows panel displays. The wizard automatically saves the testcase in a script (. Procedure To use the wizard: 1 Invoke the wizard by selecting File/New and clicking the QuickStart Wizard icon. At this point. and so on that you want to test. You don’t have to do any coding. leave New Test Frame selected and click Next. you can use the QuickStart Wizard. 3 Record testcases. 10 Click Next twice.t) file with the same name as the testplan.pln and click Next. After you open the Text Editor. then simply record the testcase. If Text Editor is not open. Again. 2 Create a test frame. which defines all the windows. click Return to Wizard in the Capturing New Windows dialog. dialogs. describing the procedure. you can open it now (it is in the directory where you installed SilkTest).As prompted. You can use the QuickStart wizard to: 1 Create a testplan. 8 Now you simply open a document window and open all the dialogs that you want to test in the Text Editor. as indicated by the Record Status window on your screen. . you simply open your application and open the various windows and dialogs that you want to test in the application. Now that you have created your test frame. You can also invoke the wizard at any time by selecting File/New and clicking the QuickStart Wizard icon. You name the testcase and provide a description for the testplan. which greatly simplifies the four steps of automated testing.

select Option -> Extentions menu from the menu bar. You return to the Wizard and are asked to confirm that the test is what you want. the use file will have the declaration 'extend\netscape. close the wizard if you dont need it or else. Close the Find dialog (to return to your base state). Now the script is ready to open the Netscape browser by default and run the scripts. Say. place your mouse pointer over the dialog’s title bar. In that dialog box. Since we have selected the Extentions. and press Ctrl+Alt to verify its state. This is to use the common include files as per the application. Enable the Netscape option by checking against it and un-check all the other options. You can move the wizard to the side and look at the results file that is created whenever you run a test. The Verify Window dialog displays. You see a window containing the results file from the test you just ran. Now click on the Options -> Runtime option. then click Done in the Record Status window. Click on the OK button. select Search/Find to open the Find dialog. Go to 'Programs -> SilkTest -> SilkTest' option (with green color icon) It will open the silktest tool. 15 The wizard reports the results. . If you get the QuickStart wizard. 17 Click Close to close the wizard. if you are testing the web based application in the Netscape browser. click Next to save your testcase.12 Now go to Text Editor. check the kind of application you are testing.inc' of the include file. refer to the 'Installation tips' to go with the wizard. It will load the Extentions dialog box. Click OK to verify all properties for the dialog.t) file with the same name as the testplan (in this case. Say if the silktest has been installed in your c:\ drive then set the use files = "C:\Program Files\Segue\SilkTest\EXTEND". Set the 'use path' option to point to the silktest installed folder.t). Configuration & Enabling the options Configuring the settings • • • • • • • In SilkTest. In another window is the testplan. 16 In the wizard. 13 Click Next. edit. 14 Run the test by clicking the Run Test Button. • • Exposure to SilkTest IDE To start the SilkTest tool • • • • Select the 'Start' button in Windows status bar. The testcase is saved in a script (. From the status bar Go to the Start -> Programs -> SilkTest -> Extention Enabller option. to declare the same set of extentions ( as in step 4) in the 'Extention Enabler' dialog box.

Configure the settings as given in lab I. click the "==>" icon or select the Run -> Run option. compile the testscript file and click the "=>t" icon in the tool bar. To open a new or existing files In Silktest. To open an existing file. If there is any syntax error in the script file. The '4Test Script file' option is to open the script file where we will be writing testscript. We will be using the include file to write the script file. The Test Script file will be used only after creating the include file. then open the browser load the page you want to start testing. We can run a testcase selectively. • • • • • • • Select the File -> New menu from the menu bar. Hence we have to declare the include file that we are calling in the testscript files. The page that you start testing the application will be assumed as the 'BaseState'.. Even we can explicitily declare the window base state.To compile & run scripts • • • • • • • • Open the testscript file (with the extention . Click on the OK button. Select the '4Test include file' to declare the window objects from the application. Click 'File -> New' menu. Also we can select the icon with the 'tick' mark to compile the scripts.t). To compile a selected file. Open the application you want to test. The above two files are more important for building the scripts. If you are going to test the Yahoo site. Select the Run -> Compile option from the menu bar. It will ask for various kind of files to open. select File -> Open and select the existing file. The 'Run' option will get enabled only for the testscript files. keep the mouse cursor on that particular file and give the Run-Compile option. .. • • • • Start the SilkTest by selecting from the 'Start' menu. But the other errors are known only at the time of compilation or during the run. it will show that if you move to the next line of the code. Hence if there is any problem with the include file. We cannot run a include file or a test frame. and select the '4Test script file' option. To run the entire set of testcases in a testscript file. (or) select from the 'white icon' in the left top corner of the window. To write a new plug & play testcase (using Action) This example is to write the script for logging in to the yahoo site. you will get error by compiling the testscript file itself. The files that are associated with the script files will also get compiled.> • How to start.

. The testcase name can be anything but it is advisable to name it clearly so that will represent the functionality of the test.TypeKeys ("") o Yahoo.Click () o BrowserPage. Then click the close button to close the Record actions dialog box and go to your application. After completing your task (till whatever you want to record).Click () Record and play a testcase to login into the hotmail site and logout.com?r?m2"). compile the code from the 'Run -> compile' option and run the script by selecting the 'Run -> Run' menu.SetText ("username") o BrowserPage.yahoo. It will load the 'Record Actions' dialog box. click on the 'paste to editor' button in the 'Record Action' dialog box. Now start writing the testcase (Follow the below instrutions).Location. go to the application and do the action what ever you want to perform. ie. inside the testcase. Open the application in parallel. Now the testcase will automatically start the application and perform the events recorded and throws the results.• • • • • • • • • • • • • • • • • • • Start with the keyword 'testcase Action()' and press Enter key in your keyboard.TypeKeys ("") o BrowserPage. Now. Now delete the keyword 'recording' in your first line of the recorded code.HtmlTextField("Yahoo! ID:|#1"). Right click on the selected code and select the 'Move Left' option.SetText ("password") BrowserPage. The code is ready now.HtmlTextField("Password:|#2"). Session III : The 4Test language The 4Test language . 1) o BrowserPage. menu from the menu bar. select the entire recorded code by keeping the mouse arrow at the leftmost dot (.HtmlLink("Mail|#26|$http:??www.HtmlPushButton("Sign In|#1"). The testcase is the default keyword for any testcase and the name Action is the name of the testcase.HtmlTextField("Yahoo! ID:|#1").SetPosition (1.) in your editor at the first line.yahoo.SetText ("www. Now the recorded code will be readily available in the testscript editor. and drag it till the end.. The silktest will record the events you do sequentially and you can view it in the 'Record Actions' dialog.SetActive () o Browser. Keep the dialog box as it is.com") o Browser. open the browser in which the application has to be run. Now.Location.(say Netscape) Go to SilkTest Click Record -> Actions. The sample recorded testcase for yahoo login look like this: testcase Action() o //[-] recording o BrowserPage.HtmlTextField("Yahoo! ID:|#1").

4Test’s powerful features are organized into three basic kinds of functionality: • • • A robust library of object-oriented classes and methods that specify how a testcase can interact with an application’s GUI objects. operators. and these window names & variables will be pasted to the silk test editor. In the Options -> Extentions menu. then set the path of that file in this 'use files' option. set the primary extensions 'Enabled' and disable all the other extentions if not needed. which will activate the ‘Paste to Editor’ button in the Record Window Declaration dialog. and data types that you use to add structure and logic to a recorded testcase. Then these variables can be pasted to the silk test editor by using the Ctrl+Alt keys. This will automatically add the include file in to the 'use files' option in Options->Runtime. Setting the runtime options Customization of scripts by runtime options The Runtime option are set by the user according to the kind of the software that is to be tested. Now captured window will be pasted to the editor as [-] window BrowserChild Yahoo . How to declare windows Declaring a window: Take the example of a Yahoo Mail web site.The window declarations are recorded by using the Record-> Window Declarations option available in the silk test. A set of statements. This option should reflect the kind of the application that is to be tested. This will be automatically set if you select the kind of application you are testing. say "c:\programfiles\segue\silktest\EXTEND" Set the use files = The file you are including for the extension type. There are two default settings that has to be done to make a minimal code run. Set the use path = the path of the 'extend' directory in the installed silktest folder. A library of built-in functions for performing common support tasks. the protocol should be set in the runtime option.The 4Test language is an object-oriented fourth-generation language (4GL) designed specifically with the needs of the QA professional in mind. The agent captures all the variables relevant to that screen. In the Options -> Runtime menu. For testing across networks. Note This section provides a high-level look at 4Test. If there is any common file that is used in many areas of the script.

Using this declaration file.• • • • tag "Yahoo . we can start writing testscripts.t ) use "c:\scripts\decregistration.inc )  //decregistration.inc"  [-] window BrowserChild SignInYahooMail o o o o tag "Sign in .Netscape" parent Browser [+] HtmlText Home o tag "Home" [+] HtmlText ClickforMail o tag " ClickforMail " In the above example. Creating simple scripts A Sample Testcase with the declaration file Let us consider the sample testcase for registering in the yahoo mail site.inc  use "c:\scripts\clsregistration.inc" testcase registration() .Yahoo! Mail" parent Browser [-] HtmlLink SignUpNow tag "Sign up"  [-] window BrowserChild WelcomeToYahoo o o o o o o o tag "Welcome to Yahoo!" parent Browser [+] HtmlTextField SignUpForYourYahooID1 [+] HtmlTextField SignUpForYourYahooID2 [-] HtmlButton SubmitThisForm tag "Submit this *" //------------------------------------------------------------------------------------------------------// a sample script file ( registration. the keyword 'Yahoo' is called as the identifier. //------------------------------------------------------------------------------------------------------// a sample Window Declaration include file ( decregistration.

com"). Exists() are some of the methods • • . as the User's choice.SignUpForYourYahooID1. Function name can be anything. html links. Windows are declared in decregistration.Click() WelcomeToYahoo. Similarly Text Values are entered into various text fields in the window 'WelcomeToYahoo' with the help of 'SetText' operator. <window-name>. Here. SELECT for POPUPLISTS etc.• • • • • • • • • • • Browser.<control-name>.objWelcomeToYahoo.mail.Note that the inverted commas is necessary with Settext operation.<operation> If an operation is to be done on the window itself (not in its controls. The corresponding classes.SignUpForYourYahooID2. thus.Entertainment.SignUpNow.objWelcomeToYahoo.Click()'will click the button SubmitThisForm.Click().inc The command statement. is the name of the control link and 'CLICK()' is the operation performed to click that control link. The command line.Exists()  print("Test Pass") else  logerror("Test Fail") //------------------------------------------------------------------------------------------------------Brief Description: The general syntax for performing any operation on the window is as follows <window-name>. 'SignInYahooMai' is the window name. 'SignUpNow'.SetText ("newuser@yahoo. 'WelcomeToYahoo. is the function name used to do registration in the Yahoo site.com") SignInYahooMail.SetActive() SignInYahooMail.<operation> CONTROLS / OBJECTS: Controls are the various text fields. SetActive().yahoo. buttons.SignUpNow. say activating a window). in a browser window or dialog box or in any non web application.SetActive WelcomeToYahoo. check boxes etc.com") WelcomeToYahoo.SubmitThisForm. other than when passing parameters. It can be SETTEXT for TEXTFIELDS. IsActive(). o Browser. CLICK for BUTTONS. clicks the link 'signupnow'. SignInYahooMail.SubmitThisForm. which consists of the various controls in the window are initialized in clsregistration.. In the above example.LoadPage("www.Click() if RegistrationSuccess.LoadPage("mail. popuplists. CHECK BOXES. is used to load the site. respective operations are defined. LINKS. OPERATIONS: Depending upon the different type of controls.yahoo.SetText("password") WelcomeToYahoo.Click() sleep(3) WelcomeToYahoo. Window object need not be mentioned. • • • • • resister().

The user can confirm that by looking at the progress status (in yellow color ) in the bottom-right corner of the silktest tool. the testcases that meets various test conditions will be written in the script file. then the include file can be compiled but cannot be run. Print is the method used to print a particular statement on the result file. The user has to make necessary changes. constants. After selecting the testcase and start running. called by that script. The testcases can be run by selectively or at-a-stretch. logerror behaves similarly like print. If the selective method is selected. One as an include file and the other as a script file. • • • • • • • • • Open the silk test tool. Here there is no need to specify the window object.inc) for writing testcases. once the testcase completes execution. seperate declaration file have to be written ( for declaring the objects) and the script file (for writing scripts using that declaration file) and compile them.Only the file with the testcase present will be allowed to run. Then. except the statement will be printed in red colour in the . It will be with the extention *. it will ask for the testcase to be run from a list of testcases. The script file (*. If no testcases is written in a file (include) . the error details are displayed in the compile time. Results file Automatic generation of results . Before running the scripts. window objects.• used to verify the browser window status. The script file will be used in writing scripts. variables. The core objects of the scripts lies here. But to make the code clear we use different files for different purposes.t. Compile the script by selecting the Run-> Compile menu from the menu bar (or) from the compile icon.res file How to compile & run scripts? Running the silkscripts The basic silk scripts will be in two forms. If there is any error. It will show error that the file does not contain any testcases. • • The include file with the extention *.t) file that has to be run.t) can be used for declaring objects and the include file (*. structures and classes. The body of the scripts will be defined here. the silktest will automatically start the application and start the test from the basestate. Open the script (*. select the Run->Testcase from the menu bar (or) else select the Run icon. The steps to be followed for running the scripts are as below. ie.inc can be used for the declaration of window names. It will compile that particular script and the other related files.

tblName. As each testcase runs.One or more testcases can be run. The state of the testing can also be known by stopping the test. the generated result file will be as below. started time. 0 warnings [+] Testcase NewGroupMembersDelete .t(109) Naming conventions .lnkMail. Script login. The result file contains details such as script name. Script login.t . statistics are written to a results file. either by running a collection of scripts. At the end of the running of each and every testcases. the status of the test will be saved in a result (. the generated result file will be as below. total scripts run.hcml1. 0 errors. machine name.1 error Machine: (local) Started: 03:13:11PM on 02-Aug-2001 Elapsed: 0:19:47 [ ] Passed: 1 tests (100%) Failed: 0 tests (100%) Totals: 1 tests. elapsed time. errors or progress of each and every test case. 0 warnings [+] Testcase NewGroupMembersDelete .t) is aborted manually. total passed.Click()Called from LoginTahoo at tlogin. 1 errors.1 error Machine: (local) Started: 04:26:19PM on 25-Jul-2001 Elapsed: 0:00:09Totals: 1 error.and whether the testcase run is aborted automatically or externally.1 error *** Error: Window '[HtmlTable]NAME' was not found Occurred in Yahoo.t . or by running only the selected script (or) testcases.res) file and is displayed. the generated result file will be as below.t) is passed. by pressing the two 'shift' keys simultaneously.objYahoo.Passed Machine: (local) Started: 03:13:11PM on 02-Aug-2001 Elapsed: 0:19:47 [ ] Passed: 1 tests (100%) Failed: 0 tests (0%) Totals: 1 tests. total failed. 0 warnings *** Program aborted by user Consider the situation that a script (say login. The results file and its associated comparison tools allow you to quickly pinpoint the problems in your application. For examples: Consider the situation that a script (say login.t) is failed due to some error. Script login.t .Passed Delete current Member Test Pass *** Warning: DefaultBaseState is closing Browser windows ----------------------------------------------------------Consider the situation that a script (say login.

it will be confused to use those objects in the testscript file.Yahoo! Mail" parent Browser clsSignInYahooMail objSignInYahooMail Here.Yahoo!" [-] HtmlLink HelpYahoo // o tag "Help" [+] HtmlLink Yahoo In the above case. declaring the window name with a pre-name 'cls' is to show it as a class name. [-] window BrowserChild winSignInYahooMail • • • tag "Sign in . It is the same code given above with the naming conventions used.Naming conventions SilkTest uses various files that contains declaration and uses the objects. Sometimes There may be chances for the programmer to get confused by looking at the name of the declarerd identifiers. Consider the code for a window declaration file. there are two variables in same name 'HelpYahoo' but of different data types.Yahoo! Mail" parent Browser [-] HtmlImage HtmlImage1 o tag "#1" [-] HtmlText HelpYahoo // o tag "Help . Hence we can follow a naming method to make the variables more presice and clear. Also the text and links are preceded by 'txt' & 'lnk'. Here after declaring the objects. [-] winclass clsSignInYahooMail • • • • [-] HtmlImage imgHtmlImage1 o tag "#1" [-] HtmlText txtHelpYahoo // o tag "Help . Note: This convention is not a must to follow but to make the coding more easy to understand .Yahoo!" [-] HtmlLink lnkHelpYahoo // o tag "Help" [+] HtmlLink lnkYahoo Here. and so the class name and its objects. the window name is preceded by the keyword 'win'. Consider the below code. For example assume a case where we are declaring a window (say yahoo page) [-] window BrowserChild SignInYahooMail • • • • • • tag "Sign in .

However. control is immediately passed to the except clause. such as when a verification fails. The statement has the following syntax: • • do  except  statements statements If an exception is raised in the do clause of the statement. if the expected value doesn’t match the actual value in a verification statement). You can also generate exceptions explicitly in a script. They indicate that something did not go as expected in a script. Some of these features are: • • • • Set break points Single step Step into and Step out Access the Call Stack . The debugging feature allows you to do most of what you need to troubleshoot a script. or when an invalid function is called. Using do.except you can handle exceptions locally.. If no exception is raised in the do clause of the statement. when there is a division by zero in a script. control is passed to the line after the except clause—the statements in the except clause are not executed. which: • Terminates the testcase • Logs the error in the results file • Restores your application to its default base state in preparation for the next testcase These runtime errors are called exceptions. suppose you don’t want SilkTest to transfer control to the recovery system when an exception is generated.. instead of passing control to SilkTest’s built-in error handler (which is part of the recovery system).. They can be generated automatically by SilkTest. instead of to the recovery system.. SilkTest by default calls its built-in recovery system.except Using do. but instead want to trap the exception and handle it yourself.Debugging Scripts Debugging the scripts If a testcase fails (for example.

The application state DefaultBaseState is predefined for your use by SilkTest. and so on. Recording Application state Application State An application state is typically used to put an application into the state it should be in at the start of a testcase.. The SetAppState function executes the statements defined in the application state and in each of the application states upon which it is based. based on AppState2. · By default. ie. The base state is the lowest level of application state in this chain of inheritance. After getting the 'Record Actions' dialog box. in the DefaultTestCaseExit function. Calling the SetBaseState function executes only the statements in AppState1. suppose a testcase uses the application state AppState3. starting with the statements in the base state and working up to the application state chain. The steps are given below. based on AppState1.Actions menu. which in turn can be based on another application state. SilkTest calls the SetBaseState function when you exit a testcase. 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. 2. · By default. the sequence of steps to be 4. Create a new Testcase.The debugger runs in a separate state and produces output helps you to better locate any errors that may have arisen. the programmer has to simply do the ordinary testing process by selecting or useing the windows & its objects. 1. use the appstate keyword when you define the testcase. 3. Record & Play Recording the Events / Action Writing scripts in SilkTest includes steps of commands with declaration of window names and its objects before that. tested. For example. in the DefaultTestCaseEnter function. The second example below associates the application state MyAppState (which is based on MyBaseState) with the testcase MyTestCase. To associate an application state with a testcase. should be done. . Select the option Record . SilkTest call the SetAppState function when you enter a testcase. The SetBaseState function executes the statements defined in the lowest level application state only (the base state). You can define the application state from scratch or base the definition on another application state.

com") // Loads the yahoo homepage as the default page if Yahoo. After completing these steps.SetText ("password") BrowserPage. Save the script and run that testcase.objYahoo.SetText ("www. 1) BrowserPage.Location. Now the scripts are automatically available in the script file.com") Browser.Loadpage("www. It is not in the case of the recording kind of the code.Click () BrowserPage.HtmlPushButton("Sign In|#1").SetText("password") Yahoo. the user has to click the 'Paste to Editor' button 6. the method II needs windows & its objects to declared before the scripts are to be written.Exists() // checking for the existence of the homepage  print("Yahoo window exists") // confirming that the window exists Yahoo. • [-] recording         BrowserPage.Click() • • • The difference between the above two different scripts are. in the 'Record Actions' dialog box.HtmlLink("Mail|#26|$http:??www.SetActive () Browser.SetText ("username") BrowserPage.TypeKeys ("") Yahoo.yahoo.Password.yahoo.HtmlTextField("Yahoo! ID:|#1"). Implementing: Classes & Objects Basic Object-oriented features The following object-oriented programming terms and concepts are used • • • • Classes Methods Objects Properties .Location.Click () The alternate for the above recorded statements will be as below: • • Browser. A recorded statements for logging in to the yahoo site.HtmlTextField("Yahoo! ID:|#1").SetText("username") Yahoo.TypeKeys ("") BrowserPage.Submit.HtmlTextField("Yahoo! ID:|#1").Loginname.objYahoo.com?r? m2").SetPosition (1. will look line the sample given below.HtmlTextField("Password:|#2").objYahoo.5. 7.yahoo.

the Exit button on a window is an object of the PushButton class. pushbuttons. the parent class Control defines all the characteristics common to all kinds of controls: check boxes. For example. you can look up the class and the methods it supports in the online Help or Library Browser. Each class has an associated set of properties. each class does not need to define all the methods it needs. and so on. For example. Inheritance Classes are organized in a hierarchy. although some properties are common among classes. A class contains a collection of information about a type of object. Properties A property is the physical characteristic of an object that you can access directly. if you decide to write or augment a testcase by hand. called methods. Syntax link. Objects An object is a specific instance of a class. in the 4Test language. For example. sharing characteristics common to their parent classes. Methods & Properties Methods in 4Test Some of the methods used in silktest are given below.• Inheritance Classes Classes are the core of object-oriented languages and are common to basic GUI architecture. iYpos] ) . text fields. the proper 4Test methods for each of your manual actions are recorded automatically for you. Methods For each GUI object in your application. such as menus or text fields. one action you can perform on objects of class DialogBox is the GetDefaultButton method. You could not use this method with objects that were not dialog boxes. so it really is transparent to you which class the recorded methods belong to. The following figure shows several classes in the main window of a sample application. that can be performed on all objects of that type. The methods that are available to an object are dictated by the class to which the object belongs. the class can just inherit the existing definition from its ancestor classes.Click ( [iButton. you cannot use methods defined for the CheckBox class to perform actions on objects in the PushButton class. Click() method (HtmlLink) Class : HtmlLink class Action : Clicks a mouse button on the HtmlLink. which is the pushbutton that is pressed when the Return or Enter key is pressed. When you record testcases. However. For example. For example. iXpos. This method returns the identifier of the default pushbutton. there is an associated class that defines the actions. Methods defined for one class cannot be used to perform actions on a different class. the CheckBox class defines the actions that can be performed on all the checkboxes in your application. The reason for this is that classes are related to each other. In this way.

INTEGER.SetText (sHello) Close() method . SetText substitutes sText for the characters starting with the iStartChar character. SignIn. iNumChars]) Variable Description sText The text to substitute. The button is declared as SignIn. and continuing to the end of the line. If iStartChar is omitted. iStartChar Optional. The coordinates are relative to the HtmlLink. The number of characters in the text field to substitute with sText. world"Find.SetText (sText [. Notes SetText substitutes the characters sText for the text in the text field. iStartChar. If you do not specify coordinates. iNumChars Optional. Syntax textfield. Example The following example clicks the Sign In Button of Yahoo Mail in the Welcome Page of the Yahoo Mail page. If both iStartChar and iNumChars are specified. SetText substitutes sText for the entire contents of the text field.Notes Click moves the mouse to the HtmlLink and clicks the specified mouse button. If iStartChar is specified. The character position in the text field (starting from 1) at which to begin the substitution. INTEGER. This method works only with the first line of multi-line text fields. Example STRING sHello = "Hello.FindWhat. YahooMail. it substitutes sText for iNumChars characters starting with the iStartChar character. the click occurs in the center of the link.Click () SetText method (TextField) Class : TextField class Action : Substitutes new text for all or part of the text in the text field. STRING.

Accept () // TextEditor displays a message boxMessageBox. in this sequence. if closing a window causes the application to display a message box and bCloseConfirm is set to FALSE.Click ( ) (only on the Macintosh). 6 Click the list of buttons specified with OPT_CLOSE_WINDOW_BUTTONS. type the keys specified in OPT_CLOSE_DIALOG_KEYS and wait one second for the dialog to close. bSetActive]) The Close method attempts to close the window by trying the following events.Class : MoveableWin class Action : Closes the window.Close.LineNumber. none of the following steps are executed.Message. or if the buttons used to close the message box are not covered under the OPT_CLOSE_CONFIRM_BUTTONS option.Close () Exists() method Class : AnyWin class Action : Tests whether the window exists. Even if this method does not close the window. 7 Select the menus specified with OPT_CLOSE_WINDOW_MENUS. the call will fail and raise the exception E_CANT_CLOSE_WINDOW. 4 If the window is a dialog. For example. click that button.Pick ( ) (on platforms and windows that have system menus). 3 Call window. Close may fail. 2 Call window.") // close the message boxMessageBox.SetText ("A")GotoLine. .SysMenu.Close ([bConfirm. Syntax window.Verify ("Must enter a number.CloseBox. call it. 5 If there is a single button in the window. This method supports several specifications you can make to help SilkTest closes a window: Example // Set the line number in GotoLine dialog to a stringGotoLine. stopping when the window closes: 1 If a Close method is defined for the window.

as in the following: Verify (SaveMessage.New. and browser messages and warnings. If the window is not unique.LoadPage (blLocation [. even though your code does not explicitly call Pick. use Exists with the Verify function. or exposed for it to exist. for example. sPassword]) Notes As part of its normal operation. Passing in a string as blLocation . so that the value returned by Exists is used. BROWSERLOCATION is the union of the STRING and WINDOW data types. Example TextEditor. The window does not have to be active.Syntax bDoesExist = window. Exists waits up to the specified number of seconds for the window to exist. TRUE) Exists should always be part of another statement. To check whether a window exists and raise an error if it does not.Exists (5)) SaveMessage.Exists ([nTimeout]) Notes Exists returns TRUE if the window exists before the nTimeout seconds elapse. security dialogs. which checks for and handles windows invoked by LoadPage operations. SilkTest raises the E_WINDOW_NOT_UNIQUE exception. unless the OPT_VERIFY_UNIQUE option is set to FALSE. Syntax browser. enabled. LoadPage calls the OnLoadPage method. sUser. Action : Loads the specified page. If you specify nTimeout.File. you may see menus pop up on the screen when calling Exists on a menu item.Pick ()if (SaveMessage. Exists does not raise an error if the window does not exist. If you set the OPT_MENU_PICK_BEFORE_GET option to TRUE.Exists (5). authentication dialogs.Dismiss () LoadPage() method Window : LoadPage is declared for the Browser window. or FALSE if the window does not exist.

if these were specified. you can pass in a string. if these were specified.LoadPage ("www. If the page cannot be loaded. You accomplish this by defining your own OnLoadPage method for the window. If the window is already maximized. Passing in a window as blLocation The main benefit of passing in a window to the LoadPage method is that it gives you the opportunity to customize the loading of a browser page. the window declaration must define a member or property. Note that in order to pass in a window as the value of blLocation. sLocation. Syntax window. In this sense. Maximize does nothing. to bypass unwanted windows that pop up before the desired page appears. along with values for sUser and sPassword. which specifies the URL to load. sURL.Maximize ( ) Notes Maximize resizes the window to its full (maximized) size. Example To display the Yahoo mail home page.com") or pass in a window: Browser.mail.LoadPage (YahooMail) Maximize() method Class : MoveableWin class Action : Maximizes the window. If the page cannot be loaded. for example. The LoadPage method calls your custom OnLoadPage method and passes to it the definition of the window’s sURL as the first argument. such as sound clips or videos.yahoo. sLocation. Browser. Example . LoadPage passes for sUser and sPassword. You might want to redefine OnLoadPage. the AppError function is called.If blLocation is a string. passing in a window is equivalent to passing in a string as the value of blLocation. In addition. LoadPage calls the OnLoadpage method and passes the string to it as the first argument.

and modulus operations. division. Example TextEditor.Minimize ()TextEditor. Syntax window. The most commonly used operators are discussed in here briefly These can be classified as • • • Arithmetic Operators Logical Operators Bit wise Operators Arithmetic operators Definition The arithmetic operators perform addition. multiplication. Addition+Adds one operand to the other Subtraction -Subtracts the second operand from the first Multiplication *Multiplies one operand by the other Division /Divides the first operand by the second Modulo%Divides the first INTEGER operand by the second. subtraction.GetState ()) // prints WS_MAXIMIZEDTextEditor.Restore Operators Operators in SilkTest Operators: The 4Test language provides the programmer with operators which are similar to the operators which are used in the other programming languages.Minimize ( ) Notes Minimize does nothing if the window is already an icon.TextEditor.Restore ()Print (TextEditor. and returns the remainder Exponentiation**Lets you refer to a number in terms of a base value and an exponent Operand type .GetState ()) // prints WS_NORMAL Minimize() method Class : MoveableWin class Action : Reduces the window to an icon. exponentiation.Maximize ()Print (TextEditor.

subtracts one from its operand. then the plus operator is the equivalent of the SetAddMember function. NoteThe exclusion of set B from set A is equivalent to: SetIntersection (A. Blue} In the third example above. The minus operator is the equivalent of the SetExclude and SetRemoveMember functions. the operand’s placement before or after the operand determines whether the increment/decrement operation takes place before or after the assignment. Arithmetic operators with sets The plus (+) and minus (-) operators are valid operators for sets.[COLORS]{Red. SetComplement (B)) The following examples should make the behavior of set exclusion operations more clear: OperationResulting set Red . Blue}Red Red . the specification of a single member as the right operand works like the SetRemove function to remove that member from the left operand set.[COLORS]{Green. the increment or decrement operation occurs after the assignment Examples // The following three statements are equivalent: i++ .(decrement) operators take a single argument.Red{Green. ·If the operator appears before the operand (++n). the increment or decrement operation occurs before the assignment ·If the operator appears after the operand (n++). In an assignment statement.SuperSetB SubSet is the set containing all members of SuperSetA that are not also contained in SuperSetB. Blue}empty set [COLORS]{Red. Green.(operator) and ++ (operator) The ++ (increment) and -. -. ·++ adds one to its operand. either of which could be a single member: SubSet = SuperSetA . it performs the exclusion of two sets. If either of the subsets is a single member. ·-.Operands for the arithmetic operators can be integers or real numbers. it performs the union of two sets: SuperSet = SubSetA + SubSetB SuperSet contains all members of both subsets with no duplicates. The plus operator is the equivalent of the SetUnion and SetAddMember functions. Blue} . Green.

n = 10 x = ++n // Increment n after assignment. child window. returns FALSE if both operands are FALSE. Operand type These operators apply to integers. // Afterwards. and not operations. x is 10 and n is ll. Bitwise AND&Masks off the specified bits Bitwise inclusive OR|Turns on the specified bits Bitwise exclusive OR^Sets to 1 each bit position where the operands have different bits. Logical not!Takes only one operand. Left Shift<<Shifts to the left the left operand by the number of bit positions indicated by the right operand. ! makes the resulting value FALSE. and exclusive OR (XOR). They work by evaluating the first operand and then. bitwise inclusive OR. if necessary the second. The second operand is evaluated only if its value is needed to determine the result. left shift. rather than the method.i=i+1 i +=1 // Increment n before assignment. . Operand type Operands to logical operators must all have type BOOLEAN. property. Logical and&&Returns TRUE if both operands evaluate to TRUE. or variable of the same name which the class itself defines. Right Shift>>Shifts to the right the left operand by the number of bit positions indicated by the right operand. If the operand evaluates to TRUE. or variable that is inherited by the window or class. Logical or||Returns TRUE if either operand evaluates to TRUE. n = 10 x = n++ Logical Operators Definition The logical operators perform logical and. right shift. returns FALSE if either operand is FALSE. Scope resolution operator Use the scope resolution (::) operator inside a window or class declaration to refer to a method. child window. ! makes the resulting value TRUE. both x and n have the value 11. Bitwise 1’s complement~Changes each 1-bit into a 0-bit and vice-versa. OR. Result type The logical operators return one of the BOOLEAN values TRUE or FALSE. or. and one’s complement (unary). and sets to 0 each bit position where the operands have the same bits. // Afterwards. If the operand evaluates to FALSE. Result type The following table shows each of the possible results for bitwise AND. property. Bitwise operators Definition The bitwise operators perform bitwise AND.

depending on the value of an expression. we can add logic and robustness to a recorded testcase.. By using 4Test flow-of-control statements.01 AND (&)010001 OR ( | )010111 XOR ( ^ )010110 Statements Statements in SilkTest There are various statements available in 4Test language for writing testcases.except handles an exception (error) rather than having it halt the script. Conditionally execute a statement block if. The following table summarizes the statements.else executes a statement block based on the value of a boolean expression. select executes one case from a group of cases. switch executes one of the statements that follow. To Use one of these 4Test statements Execute statement blocks more than once for each executes a statement block once for each element in a list. for executes the loop once for each increment of a counter. Handle exceptions do. while executes a loop until a test condition (boolean expression) is false. raise raises a user-defined exception. reraise reraises an ....

optionally passing back a return value. 2. or select statement. return returns control back to the calling function. statementCode to be executed a specified number of times until loop-var is outside the range start-expr to end-expr. the for statement skips the loop but does not generate an error.exception the testcase is handling itself within a do. step-expr Optional for incrementing loop-variable by a value other than 1.. Note You must specify an explicit step-expr to decrement a loop. Specify a positive number to increment. A negative number to decrement. start-expr A number which specifies the starting value of loop-variable..except statement. either a single statement or a series of statements. for each. If you fail to do this. exit ends the execution the current script. for each. continue begins the next iteration of a for. specify step -1. Transfer flow of control break transfers control of the script out of the innermost nested for. switch. goto transfers control to the statement prefixed with the specified label. to decrement a loop by 1. Syntax for loop-var = start-expr to end-expr [step step-expr] statement VariableDescription loop-var A loop variable to hold the current value of the for loop. Example testcase ForExample () . or while statement without completing the current iteration. while. For example. end-expr A number which specifies the end value of loop-variable. For statement numeric iteration Action : Uses numeric iteration to control the number of times a statement executes.

Syntax if boolean-expr . When every element in the list or set has been processed.. control passes to the next statement in the script. the iterator sets item to the value of another list or set element. exprAn expression that evaluates to a list or a set. and then control passes back to the iterator to check for another item. the statement section executes for that value.INTEGER i = 0 for i = 2 to 9 step 2 Print (i) // This script prints: //2 //4 //6 //8 for each statement Action Iterates over the elements of a list or a set. statementA single statement or a series of statements. Notes The for each iterator executes once for each element in the list or set specified by expr. Each time it executes.} "apple" "mango" "kiwi" STRING sFruit for each sFruit in lsFruit Print (sFruit) // This script prints: //apple //mango //kiwi If Statement Action : Executes particular statements depending on the value of a condition. Example testcase foreachExample () LIST OF STRING lsFruit = {. Syntax for each item in expr statement VariableDescription itemA variable name..

. control passes to the else clause.. If the value of the boolean expression is FALSE. or a series of statements.statement [else statement] VariableDescription boolean-exprA boolean expression. statement is not executed. If there is no else clause in an if statement. [ default statement ]. Example testcase ifExample () INTEGER i = 1.. Syntax switch (expr) case case-value(s) statement [ case case-value(s) statement ]. and control passes to the next statement in the script (which could be another if statement). and if boolean-expr is FALSE. j = 2 BOOLEAN b = TRUE if (i == j) Print ("Equal") else Print ("Not Equal") Print ("Not even in the ballpark!") if (b) Print ("TRUE") // Prints: // Not Equal // Not even in the ballpark! // TRUE switch statement Action: Executes a particular statement depending on the value of an expression. Notes If the value of the boolean expression is TRUE. . if any. statementA single statement.. the statement immediately below it is executed.

"Case 5 to 7") case 8 to 9. case-valuesOne or more expressions. "Case 2. "Default Case") // This script prints: //1Case 1 //2Case 2. control passes to the first statement in the case-values clause. if one exists. "Case 1") case 2. 4 //5Case 5 to 7 //6Case 5 to 7 //7Case 5 to 7 //8Case 8 to 9 and 11 to 12 //9Case 8 to 9 and 11 to 12 . 4 // Compares i to 2 and 4 Print (i. If the value equals one of the expressions. Your script evaluates expr once and compares this value to the value of each of the expressions in case-values. If the value of expr equals one of the case-values.VariableDescription exprAn expression. statementsOne or more statements. control automatically passes to the next statement after the switch statement. Notes A switch statement can take the place of a series of if statements. Once the last statement in the case has been executed. and 7 Print (i. control passes to the statement that follows. "Case 8 to 9 and 11 to 12") default // If i is none of the above Print (i.11. The syntax shown above is correct for Visual 4Test. 11 to 12 // Compares i to 8. and it must be the last. Example The following example illustrates all of the ways you can specify case-values. Classic 4Test requires colons after the case and default labels. 4") case 5 to 7 // Compares i to 5. See the Notes below. Although C requires a break statement in each case to explicitly transfer control out of the switch. There can be only one default label.9. separated with commas. 4Test does not require it. testcase switchExample () INTEGER i for i = 1 to 12 switch (i) case 1 // Compares i to 1 Print (i. Otherwise control transfers to the statement following the default label. 6. 4 //3Default Case //4Case 2.12 Print (i.

. Syntax pagelist. see the PageList class. Syntax do statements1 except statements2 VariableDescription statements1A single statement or series of statements that may generate an exception. STRING sTestValue) if ( sExpectedValue == sTestValue ) Print ("Test was successful") else raise 1. LISTITEM Notes Select causes the specified page to become the current (active) page in the pagelist.MyPageList. except statement Action :Handles (ignores) an exception without halting a script.Select (sPage) VariableDescription sPageThe page to select. For information on specifying sPage.. Select generates a click on the specified tab. statements2A single statement or series of statements (executed only if exception is raised in statements1).//10Default Case //11Case 8 to 9 and 11 to 12 //12Case 8 to 9 and 11 to 12 Select method (PageList) Class : PageList class Action : Sets the current page to the specified page. sTestValue) except . For TabList controls. Example MyDialog. Example TestVerification (STRING sExpectedValue. "ERROR: Test verification failed" return ErrorHandler () Print (ExceptData()) //This script prints: //ERROR: Test verification failed return testcase do_except_example () STRING sTestValue = "xxx" STRINGsExpectedValue = "yyy" do TestVerification (sExpectedValue.Select ("/Options/Agent") do .

ErrorHandler () // Continue with testcase ... Notes The do...except statement allows a possible exception to be handled by the testcase instead of automatically terminating the testcase. If an exception is raised while the do clause (statements1) has control of the script, control immediately jumps to the first statement in statements2 in the except clause (often a call to one of the built-in 4Test functions that gets information on exceptions). If no exception is raised while statements1 has control of the script, control jumps to the first statement beyond the do ... except statement (the statements in statements2 are not executed). Session IV: Lab II : How to login into the yahoo site: Write a script to check for the existence of the mail in yahoo site. (save it as testscript1.t) - use any maid id to check for mail Write a script to delete all the mails in the yahoo inbox. (save it as testscript2.t) Create a test suite to run the above two testscripts at-once. (refer Session I) Look at the result files and if you see any error or warning, try to rectify it. To write a testcase using 4test include file & 4test script file

This example is to write the script for logging in to the yahoo site. To declare the window objects • • • • Start the SilkTest by selecting from the 'Start' menu. Configure the settings as given in lab I. Set it to Netscape. Click 'File -> New' menu, and select the '4Test include file' option and click OK. Click on the OK button.

• • • • • • • • • • •

It will open a new include file (of type .inc) Open the application in parallel. ie., open the browser in which the application has to be run.(say Netscape) In the netscape browser, load the page 'www.yahoo.com'. Go to the silktest. Select 'Record -> Window Declarations' option from the menu bar and go to the browser (your application) Wait till the 'Record Declarations' dialog box appears. Till that the application will be scrolled up and down to trap all the objects in that window. In the resultant 'Record Declarations' dialog box, all the objects of the yahoo home page declared can be viewed. Press the 'Ctrl'+ 'Alt' keys simultaneously. It will activate the button 'paste to editor' in the 'Record Declarations' dialog box. Click on the 'paste to editor' button to paste the window objects in the silk editor. Now it will display a code as given below. (say) [-] window BrowserChild Yahoo //identifier for window tag "Yahoo - Netscape" //tag for window parent Browser [+] HtmlLink Mail [+] HtmlImage LoginInfo [+] HtmlText Newsletter [-] HtmlPushButton Search // identifier for variiable search of type HtmlPushButton tag "Search" // tag value for the control pushbutton search. [+] HtmlPushButton Submit

• • • • • • • • •

Now click on the 'Mail' link in the home page. It will load the SignIn page. Now you have to declare that page in to your include / declaration file. Go to silktest. Select 'Record -> Window Declarations' option from the menu bar and go to the browser. Wait till the 'Record Declarations' dialog box appears. Till that your application will be scrolled up and down to trap all the objects in that window. In the resultant 'Record Declarations' dialog box,all the objects of the yahoo SignIn page declared can be viewed. Press the 'Ctrl'+ 'Alt' keys simultaneously. It will activate the button 'paste to editor' in the 'Record Declarations' dialog box. Click on that button and paste the second page of the application in to the editor. Now the include file will look as below. [-] window BrowserChild Yahoo tag "Yahoo - Netscape" parent Browser [+] HtmlLink Mail [+] HtmlImage LoginInfo [+] HtmlText Newsletter

[+] HtmlTextField Search [+] HtmlPushButton Submit • [-] window BrowserChild SignInYahoo tag "Sign In Yahoo - Netscape" parent Browser [+] HtmlLink CheckMail [+] HtmlImage SignIn [+] HtmlText Mails [-] HtmlTextField Password tag "Pasword" o • • • [+] HtmlPushButton Submit

Login into the site by supplying the username and password and get into it. Now the browser will contain the 'Yahoo Mail' page. Now using the above few steps declare the objects available in 'Yahoo Mail' page. Now the include file will be (say): [-] window BrowserChild Yahoo tag "Yahoo - Netscape" parent Browser [+] HtmlLink Mail [+] [+] [+] [+] HtmlImage LoginInfo HtmlText Newsletter HtmlTextField Search HtmlPushButton Submit

[-] window BrowserChild SignInYahoo tag "Sign In Yahoo - Netscape" parent Browser [+] HtmlLink CheckMail [+] [+] [+] [-] HtmlImage SignIn HtmlText Mails HtmlTextField username HtmlTextField Password tag "Pasword"

o [+] HtmlPushButton Submit [-] window BrowserChild YahooMail tag "Yahoo Mail - Netscape" parent Browser [+] HtmlLink Mail [+] HtmlImage LoginInfo [+] HtmlText Newsletter

use "c:\myscripts\decsample. Start with the keyword 'testcase Login()' and press Enter key in your keyboard.Submit. use "c:\myscripts\decsample. The dec is just to mark that it is a declaration/include file.Click() // to click the mail link in home page if SignInYahoo.Exists() print("The yahoo sign in page is loaded") SignInYahoo. Also the silktest will automatically load the home page as we have declared the sLocation variable.Click() if YahooMail. const wMainWindow = Yahoo // default window name.Username.SetText("pasword") SignInYahoo. Save the above inlcude file as 'decyahoo. Declare the inlcude file in your script file by including the below line in the beggining.SetText("username") SignInYahoo. const sLocation="www. The above two variables are declared in the 'c:\program files\segue\silktest\defaults.inc" testcase Login() Yahoo.Exists() print("You have sucessfully logged in") else LogError("Sorry.inc' file.Mail. include the code given below in the above file.[+] HtmlTextField Search [+] HtmlPushButton Submit • • • Create a folder called myscripts (say) in any drive to save the include file. The name of the testcase should be meaningful so that it represents the functionality of the test.yahoo.Password. The testcase is the default keyword for any testcase and the name Login is the name of the testcase. Assume that the folder is created in c:\ drive. • To write testscript using the above include file • • • • • • Already the include file 'decsample.SetActive() // this is to activate the window Yahoo.inc" Open a new testcase by marking the keyword 'testcase'. It is not necessary to save the scripts in that same drive where the silktest has been installed.com" • This is to mark that the 'Yahoo' window will be the application base state and every testcase will start with the above window. Now. Cannot log in") else LogError("Cannot Load Yahoo sign in page") • • • .inc' is in the folder. click on the File -> New option and open a new '4Test include file' file. Now start writing the testcase (write the below code).inc' in 'c:\myscripts' folder. Create a folder myscripts in c:\ drive.

you will get a result file where you can know the status of the test.t' in the 'c:\myscripts' folder... then the window declaration can be as above.. testcase login() testcase checkmail() . The Pop-Up window is what we call as dialog box in SilkTest. • • • • • • Assume that all the windows in yahoo are declared and the current window is in 'Yahoo! Mail' dialog box.....• • • After completing the script. Many times we have to come across the dialog boxes that is apart from a browser.Netscape'. on clicking the 'Add attachment' link. Now. Value can be entered into the textbox/textfield using the SetText() method. Select the Record -> Window Declarations menu..IsActive() methods. Click() method is used to click the text.. Save it as 'sample.. it can be done and saved in another name. Here SetActive() method for the windows is to activate the given window... and click on the 'Yahoo! Mail' popup window. Note: • • • • • • • • • • Here various methods are available for every control. The declaration will be as below..inc'.We need to follow the following steps.. refer Lab I. If we need to write a new testscript file.. .with some attachment. links and images.For running the scripts.. In the composing page.. a pop-up window 'Yahoo! Mail' will be loaded. Now start writing the next testcase. Open the declaration / include file 'decsample.... The window can be checked using Exists(). Differentiating the Window & Dialog box If the application is opened in the browser. The SetText() method is for the type textfield. For that dialog box. save it in the folder. But dont close the 'record Declarations' dialogbox. Wait till the 'Record Declarations' dialogbox appears.. At the end of the run. Your code is ready now. ... we cannot cannod do the declaration as the other browsers. For dropdown control.Select(n) function can be used where 'n' value depends on our selection.. keep the cursor on the top of the window frame of the pop-up window (a blue pane that contains the window name 'Yahoo! Mail .. Now you can compile the above tetscase and run it. Assume composing a mail in yahoo. Assume the above code.... Press the 'Ctrl' + 'Alt' keys simultaneously and paste the dialog name into the editor.

..SetActive() Preferences. Session V : Changing window declarations for implementing classes . PreferencesNetscape...... and the name of the browserchild and the dialogbox should not be the same... [-] window DialogBox PreferencesNetscape [-] window BrowserChild Preferences .......... Consider the following testcase that uses the above window declarations..Click() .t... [-] window BrowserChild Preferences [ ] tag "Preferences" [ ] parent PreferencesNetscape [+] HtmlTextField ChangePassword [+] HtmlPushButton OK [+] HtmlPushButton Cancel • Now check for the difference between the two. click the 'Resume Tracking' button to continue tracking the window objects..SetActive() PreferencesNetscape......Netscape" • Now go to the application and in the 'Record Declarations' dialogbox..... Now....inc.. This will save the exact contents of the windows as below............OK......... The dialogbox name bears the declaration of the window name browserchild bears the contents of the window... and the of the the window the action in Make sure that the parent name of the browserchild is same as that of the dialogbox name...SetText("newpassword") Preferences...Maximize() Sleep(2) PreferencesNetscape.... keep the mouse cursor inside the dialogbox (not on the dialog frame name) and press 'Crtl'+'Alt' keys...[-] window DialogBox PreferencesNetscape [ ] tag "Preferences .....in decsample... Here the name dialogbox can be used for activating / maximizing / minimizing while the name of the browserchild can be used for performing the window...ChangePassword...................... .....in sample.. .

and create the object of that class. retain the tags. Now our class is defined.Netscape" parent Browser [+] HtmlText Home o tag "Home" [+] HtmlText ClickforMail o tag " ClickforMail " In the above example. Declare the class file (clsYahoo. [-] winclass clsYahoo • • • //tag "Yahoo . How to create classes . change the window BrowserChild to winclass.Netscape" //parent Browser [+] HtmlText Home o tag "Home" From the above code.inc) Declare the declaration file (decYahoo. Now captured window will be pasted to the editor as [-] window BrowserChild Yahoo • • • • tag "Yahoo . Now copy the variables only (i. and these window names & variables will be pasted to the silk test editor. We record the window declaration by using the Record-> Window Declarations option available in the silk test.Let us take the example of a Yahoo mail web site. • • • • In the class file. Now we have the window declaration for the yahoo web site and create an object for the winclasss clsYahoo.inc) in the script file (Yahoo. with the variables retained. the keyword 'Yahoo' is called as the identifier..t). Then these variables can be pasted to the silk test editor by using the Ctrl+Alt keys. [-] window BrowserChild Yahoo • clsYahoo objYahoo // creating an object for the class clsYahoo under the window yahoo Now the class file for the window Yahoo will be as below. we have to make sure that after window declaration. Once the class is defined we need to create an instance of the class to use the variable that has been captured. The agent captures all the variables relevant to that screen. which will activate the ‘Paste to Editor’ button in the Record Window Declaration dialog. In the declaration file.inc) in the declaration file (decYahoo. from the HtmlText Home) and put it under the class which is defined under the classes directory. and remove the tag value. Now in the directory declarations create a new file called ‘decYahoo.inc’ (an include file).e. remove the variables.

we can apply this OOPs concept to write better test scripts and test plan. The agent captures all the variables relevant to that screen.Using the OOPS concept in Silk Test Oops offers many benefits to program designers of the users. SilkTest uses the object oriented concepts for the built in custom controls and other features. By default. which will activate the ‘Paste to Editor’ button in the Record Window Declaration dialog. The syntax for declaring a class in silk test is winclass <class-name> Here the class name is preceded by the winclass keyword. better quality of software and lesser maintenance of cost. We record the window declaration by using the Record-> Window Declarations tool available in the silk test. It is easy to partition the work in a project based on objects. Object orientation contributes to solutions of many problems associated with the development of quality of software products. The variables that are declared inside the winclass are got from capturing the window declarations. It is possible to map objects in the problem domain to those objects in the program. and these variables will be pasted to the silk test editor. • • • It is possible to have multiple objects to exist without any interference. This saves development time and ensures higher productivity. For ex: let us take the example of a Yahoo mail web site. We also make sure that the data it contains and the code that operates on the date goes with it. Software complexity can be easily managed. The declaration will contain the window name followed by the controls. We can build programs from standard working modules that communicate with one another rather than having to start writing codes from the scratch. we can eliminate redundant code and extend the use of existing classes. The principles of data hiding help programmers to build secure programs that cannot be invaded by codes in other parts of the program. Let us consider that we are declaring a window from the Yahoo home page. Object oriented systems can be easily upgraded from small to a large system. The new technology promises greater programmer productivity. Here we can define a class.Netscape" . Then these variables can be pasted to the silk test editor by using the Ctrl+Alt keys. Under the Classes directory create a class winclass clsYahoo Now captures window will be pasted to the editor as [-] window BrowserChild Yahoo • tag "Yahoo . In silk test. Advantages of Oops: Through inheritance.

e.objYahoo. Now we have the window declaration for the yahoo web site and create an object for the winclasss clsYahoo.mail.yahoo.Exists()  Yahoo. So.com”) If Yahoo. Now in the directory declarations create a new file called ‘decYahoo. Now we can start writing a testcase for the website.t use "c:\silktest\declarations\decYahoo. Then we have to click the submit button and check whether the expected result has been achieved or not.com’ into the browser and set the login and password values.user. from the HtmlText Home) and put it under the class which is defined under the classes directory.inc" // declaring the declaration file.Click()  If YahooMail.submit..• • • parent Browser [+] HtmlText Home o tag "Home" [+] HtmlText ClickforMail o tag " ClickforMail " Now copy the variables only (i. If the process gets over correctly.password.inc file into the testscript file yahoo.yahoo.SetText(“username”)  Yahoo. [-] window BrowserChild Yahoo • clsYahoo objYahoo // creating an object for the class clsYahoo under the window yahoo Make sure that you inport clsYahoo. Writing a testcase using classes & declarations: Before writing the testcase create a new script file (say yahoo. testcase loginYahoo() • • Browser.LoadPage(“mail.Exists()  Print(“Yahoo mail exists – Test Pass”)  Else  LogError(“Yahoo mail doesn’t exists – Test Fail”) Else  LogError(”Cannot load yahoo mail page”) • . Once the class is defined we need to create an instance of the class to use the variable that has been captured.t) in the ‘testscripts’ folder. the test passes and if not the test fails.objYahoo. The syntax for writing the testcase is testcase loginyahoo() The name itself indicates that this testcase does the job of logging into the yahoo site.inc before creating the object.inc’ (an include file). now let us start writing the testcase // yahoo. Now the object objYahoo for the winclass winYahoo has been created. Before start writing the testcases import the folder silktest/declarations/decyahoo.SetText(“password”)  Yahoo.t. What we are trying to achieve here is to load the page ‘www. Now our class is defined.objYahoo.

But before we instantiate the class.t file for describing your test case. and to declare a function.inc type login is record // here the structure name is 'login' string usrid string usrpwd DECLARING THE CLASS FOR THE WINDOW OF LOGIN FIELDS & FUNCTION TO SET TEXT FIELD VALUES FOR LOGIN: // clsstructure. Then we check if the yahoo page is loaded by using the if condition. Let us consider a function in which we need to pass two parameters. After the page has been loaded. A . for logging into the Yahoo site.inc file for declaring a structure. for the two login fields (User ID and password). we have refer to the object with the browser name of the window where the variable has been recorded from. According to that. Even if we did not specify the user defined result message. we will print the result. we set the username and password in the respective textfield using the SetText() method. So we use Yahoo.objYahoo. DECLARING A STRUCTURE: //decstructure. we are loading the url using the BrowserLoadPage() method where we pass the url as a parameter to browser. through which you are setting the text values for login and password. we check for the existence of the YahooMail page.Here. the silktest will by default print the test status.inc file for declaring a class for the window where the login fields occur.inc use "decstructure. One . in your test case. Files that you are going to use: • • • One .user.SetText(“username”) After doing so.inc" winclass clssigninyahoomail • • HtmlTextField logid HtmlTextField logpwd . Here you will notice that the object is used to refer to the user and password variable of winclass clsYahoo. Log ID and PWD. How to use structures Using Structures Consider a case as given below.

inc" login loginfo // object declared for the structure testcase login() • • • • loginfo{"USER_ID".void Login(login x) • • logid.usrid) logpwd.Login(loginfo) // passing the parameter for setting the values Advanced 4Test language More on 4test language Data types and variables Built-in data types 4Test provides the following built-in data types: • • • • • • • • • • • • • • • • • • • • ANYTYPELIST ARRAY BOOLEAN BROWSERTYPE DATACLASS DATATYPE DATE DATETIME FONTSTYLE GUITYPE HANDLE INTEGER LIST LONG NUMBER REAL SEMAPHORE SET STRING TABLECOL .yahoomail.t use clsstructure.SetActive() SignYahooMail.inc use "decsigninyahoomail.objSignYahooMail.SetText(x. "USER_PWD") // passing parameter for the object of a struct Browser.com") SignInYahooMail.SetText(x.LoadPage("www.usrpwd) DESCRIBING YOUR TESTCASE FOR LOGIN: file://tlogin.

the following C data types are supported for use in calling functions in DLLs. The third column corresponds to the REAL data type. The following table summarizes the functions by category: • • • • • Application state Array manipulation Char/string conversion Data type manipulation Distributed processing . • • • • • • • • • • • • • • char int short long unsigned char unsigned int unsigned short unsigned long float double The first two columns above show data types that correspond to the 4Test INTEGER data type. For example: type FILE is LIST OF STRING type COLOR is enum red green Built-in functions 4Test contains a function library to handle the most common programming tasks. User-defined types You can also create new data types.• • • TABLEROW TIME WINDOW C data types for DLL functions In addition to the 4Test data types. including enumerated types and records.

Loadpage("www.properties & methods are clearly defined.• • • • • • • • • • • • • • Exception handling File manipulation List manipulation Numeric operations Random values Results file operations Script information Semaphore operations Set manipulation Startup String manipulation System calls Timers. The Line 1 is for loading the the homepage of the yahoo site.SetText("username") // Setting the login name in the corresponding textfield Yahoo.CheckMessage. In line 3. time/date info Window information Sample script for 4Test statements Consider an example of testing a web based application.Exists()  LogError("Cannot login . its objects. The concepts of the classes are described in the 'How to write scripts' portion of the index page. //------------------------------------------------------------------------------------------------------// a sample script file ( registration.objYahoo.test fail") // printing the error message print("Yahoo mail logged in") YahooMail. testcasesample() • • • • • • Browser.Click() if !YahooMail. A sample script Sample code with description Let us consider the sample testcase for registering in the yahoo mail site.objYahoo. In the next line.Exists() // checking for the existence of the homepage  print("Yahoo window exists") // confirming that the window exists Yahoo.objYahooMail. framename used. the SetText is the method belong to the class textfield. the 4Test statements. HtmlTextField Loginname.Password.Click() // checking the mail • • In the above example.Loginname.objYahoo.t ) .SetText("password") Yahoo.com") // Loads the yahoo homepage as the default page if Yahoo.Submit.yahoo. the exists is a method that belongs to the window class 'Yahoo'.

objWelcomeToYahoo.Click() sleep(3) WelcomeToYahoo.FirstName1.SetText("firstname") WelcomeToYahoo.Click() if RegistrationSuccess.com") SignInYahooMail.inc  use "c:\scripts\clsregistration.SetText("currentmailid ") WelcomeToYahoo.LoadPage("mail.Select(5) WelcomeToYahoo.objWelcomeToYahoo.SignUpNow.HtmlTextField6.ContactMeOccasionallyAbout.Click() WelcomeToYahoo.HtmlTextField7.Gender1.Occupation1.SignUpForYourYahooID3.inc"  [-] window BrowserChild SignInYahooMail o o o tag "Sign in .objWelcomeToYahoo.objWelcomeToYahoo.objWelcomeToYahoo.objWelcomeToYahoo.objWelcomeToYahoo.SetActive() SignInYahooMail.Entertainment.SetText("birthmonth") WelcomeToYahoo.objWelcomeToYahoo.HtmlPopupList2.SignUpForYourYahooID1.inc" testcase registration() • • • • • • • • • • • • • • • • • • • • • • • • • • Browser.objWelcomeToYahoo.SetText ("newuser@yahoo.LanguageContent1.Exists()  print("Test Pass") else  logerror("Test Fail") //------------------------------------------------------------------------------------------------------// a sample Window Declaration include file ( decregistration.objWelcomeToYahoo.SetActive WelcomeToYahoo.objWelcomeToYahoo.inc )  file://decregistration.objWelcomeToYahoo.SetText("pas sword") WelcomeToYahoo.SetText("lastname") WelcomeToYahoo.objWelcomeToYahoo.Select(5) WelcomeToYahoo.Yahoo! Mail" parent Browser clsSignInYahooMail objSignInYahooMail .com") WelcomeToYahoo.SubmitThisForm.objWelcomeToYahoo.objWelcomeToYahoo.HtmlTextField5.SignUpForYourYahooID2.Select(5) WelcomeToYahoo.Select(2) WelcomeToYahoo.yahoo.Industry1.use "c:\scripts\decregistration.Select(5) WelcomeToYahoo.SetText("conf irmpassword") WelcomeToYahoo.Select(3) WelcomeToYahoo.SetText("AnswerToSec urrityQuestion") WelcomeToYahoo.HtmlPopupList1.objWelcomeToYahoo.objWelcomeToYahoo.objWelcomeToYahoo.HtmlTextField4.LastName1.SetText("birthyear") WelcomeToYahoo.ZipPostalCode1.objWelcomeToYahoo.Click() WelcomeToYahoo.objSignInYahooMail.SetText("zipcode") WelcomeToYahoo.

Window object need not be mentioned. We can also write using the Window name followed by control name.<control-name>. thus. [-] window BrowserChild WelcomeToYahoo o o o tag "Welcome to Yahoo!" parent Browser clsWelcomeToYahoo objWelcomeToYahoo //------------------------------------------------------------------------------------------------------// a sample class include file (clsregistration. in a browser window or dialog box or in any non web application. respective operations are defined. OPERATIONS: Depending upon the different type of controls. check boxes etc. html links. CHECK BOXES.<operation> CONTROLS / OBJECTS: Controls are the various text fields.Yahoo!" [+] HtmlLink Help o tag "Help" [+] HtmlLink Yahoo o tag "Yahoo!" [+] HtmlHeading WelcomeToYahooMail o tag "Welcome to Yahoo! Mail" [+] HtmlHeading YouMustSignInToRead o tag "You must sign in to read" [+] HtmlHeading NewToYahoo o tag "New to Yahoo!?" [+] HtmlHeading ExistingYahooUsers o tag "Existing Yahoo! users" //------------------------------------------------------------------------------------------------------Brief Description: The general syntax for performing any operation on the browser is as follows <window-name>. SELECT for POPUPLISTS etc.<object-name>. It can be SETTEXT for TEXTFIELDS. LINKS..<operation> If an operation is to be done on the window itself (not in its controls.<operation> It is not necessary to use class to write testscripts. In that case the syntax will be as below <window-name>. say activating a window). buttons. <window-name>.<control-name>. popuplists. In the above example. CLICK for BUTTONS.inc)  [-]winclass clsSignInYahooMail • • • • • • • • [+] HtmlImage HtmlImage1 o tag "#1" [+] HtmlText HelpYahoo o tag "Help . .

Click()'. The command line. which consists of the various controls in the window are initialized in clsregistration.SignUpForYourYahooID1.inc" testcase registration() • • • • • • • Browser. 'WelcomeToYahoo.com"). will select the third value from the list. other than when passing parameters.SignUpForYourYahooID2.objSignInYahooMail.SetText("pas sword") . except the statement will be printed in red colour in the .objSignInYahooMail.inc The command statement. 'SignUpNow'.res file Built-in recovery system Sample code with description Let us consider the sample testcase for registering in the yahoo mail site.objWelcomeToYahoo. IsActive(). is the function name used to do registration in the Yahoo site. Exists() are some of the methods used to verify the browser window status. 'SignInYahooMai' is the window name.com") WelcomeToYahoo. Select is the operation used to select a particular value from a popup list.SignUpNow.SetText ("newuser@yahoo.Click(). Windows are declared in deregistration.t ) use "c:\scripts\decregistration. 'objSignInYahooMail' is the object of that particular window.com") SignInYahooMail.yahoo.• • • • • • • • • resister(). SignInYahooMail.inc is included in decregistration.Click() sleep(3) WelcomeToYahoo. clicks the link 'signupnow'. is the name of the control link and 'CLICK()' is the operation performed to click that control link.Click()'will click the button SubmitThisForm. SetActive(). o Browser. Select(3). Note that the inverted commas is necessary with Settext operation.t.LoadPage("www.SubmitThisForm. //------------------------------------------------------------------------------------------------------// a sample script file ( registration.Entertainment. Similarly Text Values are entered into various text fields in the window 'WelcomeToYahoo' with the help of 'SetText' operator. will check the check box Entertainment and 'WelcomeToYahoo. Print is the method used to print a particular statement on the result file.mail. which in turn is included in tregistration.SignUpNow.objWelcomeToYahoo. logerror behaves similarly like print.yahoo. Here. Here there is no need to specify the window object. Function name can be anything.inc.objWelcomeToYahoo.SetActive WelcomeToYahoo. once the testcase completes execution. The corresponding classes. 'objWelcomeToYahoo' is the object of 'WelcomeToYahoo' window. as the User's choice. The file clsregistration. is used to load the site.objWelcomeToYahoo.LoadPage("mail.SetActive() SignInYahooMail.

inc)  [-]winclass clsSignInYahooMail • [+] HtmlImage HtmlImage1 .objWelcomeToYahoo.Click() if RegistrationSuccess.SetText("firstname") WelcomeToYahoo.SetText("birthmonth") WelcomeToYahoo.ZipPostalCode1.Select(2) WelcomeToYahoo.objWelcomeToYahoo.HtmlPopupList1.objWelcomeToYahoo.FirstName1.Select(5) WelcomeToYahoo.objWelcomeToYahoo.LanguageContent1.objWelcomeToYahoo.objWelcomeToYahoo.Entertainment.objWelcomeToYahoo.SubmitThisForm.Yahoo! Mail" parent Browser clsSignInYahooMail objSignInYahooMail  [-] window BrowserChild WelcomeToYahoo o o o tag "Welcome to Yahoo!" parent Browser clsWelcomeToYahoo objWelcomeToYahoo //------------------------------------------------------------------------------------------------------// a sample class include file (clsregistration.objWelcomeToYahoo.Select(5) WelcomeToYahoo.LastName1.Select(5) WelcomeToYahoo.SetText("lastname") WelcomeToYahoo.inc )  file://decregistration.SetText("birthyear") WelcomeToYahoo.Gender1.HtmlTextField5.Click() WelcomeToYahoo.objWelcomeToYahoo.objWelcomeToYahoo.ContactMeOccasionallyAbout.HtmlPopupList2.objWelcomeToYahoo.objWelcomeToYahoo.HtmlTextField7.inc  use "c:\scripts\clsregistration.Occupation1.Click() WelcomeToYahoo.• • • • • • • • • • • • • • • • • • • WelcomeToYahoo.objWelcomeToYahoo.inc"  [-] window BrowserChild SignInYahooMail o o o tag "Sign in .SetText("conf irmpassword") WelcomeToYahoo.Select(5) WelcomeToYahoo.SetText("currentmailid ") WelcomeToYahoo.SetText("zipcode") WelcomeToYahoo.objWelcomeToYahoo.HtmlTextField6.Exists()  print("Test Pass") else  logerror("Test Fail") //------------------------------------------------------------------------------------------------------// a sample Window Declaration include file ( decregistration.SignUpForYourYahooID3.HtmlTextField4.objWelcomeToYahoo.objWelcomeToYahoo.Select(3) WelcomeToYahoo.objWelcomeToYahoo.Industry1.SetText("AnswerToSec urrityQuestion") WelcomeToYahoo.

SignInYahooMail.inc.<object-name>. say activating a window). is used to load the site. CHECK BOXES. clicks the link 'signupnow'. check boxes etc. is the function name used to do registration in the Yahoo site. is the name of the control link and 'CLICK()' is the operation performed to click that control link. In that case the syntax will be as below <window-name>. 'SignUpNow'. The file clsregistration. OPERATIONS: Depending upon the different type of controls. as the User's choice. o Browser. CLICK for BUTTONS.SignUpNow.mail. thus.<operation> CONTROLS / OBJECTS: Controls are the various text fields. Windows are declared in deregistration. .Yahoo!" [+] HtmlLink Help o tag "Help" [+] HtmlLink Yahoo o tag "Yahoo!" [+] HtmlHeading WelcomeToYahooMail o tag "Welcome to Yahoo! Mail" [+] HtmlHeading YouMustSignInToRead o tag "You must sign in to read" [+] HtmlHeading NewToYahoo o tag "New to Yahoo!?" [+] HtmlHeading ExistingYahooUsers o tag "Existing Yahoo! users" //------------------------------------------------------------------------------------------------------Brief Description: The general syntax for performing any operation on the browser is as follows <window-name>. We can also write using the Window name followed by control name.• • • • • • • o tag "#1" [+] HtmlText HelpYahoo o tag "Help . in a browser window or dialog box or in any non web application. In the above example. The command line.<operation> It is not necessary to use class to write testscripts.<control-name>. Window object need not be mentioned.inc is included in decregistration.t.yahoo. which in turn is included in tregistration.objSignInYahooMail. Here. 'SignInYahooMai' is the window name.. • • • • • resister().<control-name>. which consists of the various controls in the window are initialized in clsregistration. respective operations are defined. html links. Function name can be anything. popuplists. buttons.<operation> If an operation is to be done on the window itself (not in its controls.inc The command statement. LINKS. SELECT for POPUPLISTS etc. <window-name>. It can be SETTEXT for TEXTFIELDS. 'objSignInYahooMail' is the object of that particular window.LoadPage("www. The corresponding classes.com").Click().

IsActive().objWelcomeToYahoo. Select(3). logerror behaves similarly like print. the window declarations in the ‘declarations’ folder. and declarations. But to increase the effectiveness and easy updation. Scripts have to be tuned fine by putting in sleep() commands so that the script will wait for actions which may take some time to complete. classes are used. other than when passing parameters.objWelcomeToYahoo. Select is the operation used to select a particular value from a popup list. Exists() are some of the methods used to verify the browser window status.Entertainment. that are available in the viewport.SubmitThisForm. 'objWelcomeToYahoo' is the object of 'WelcomeToYahoo' window. Here there is no need to specify the window object. SetActive().• • • • Similarly Text Values are entered into various text fields in the window 'WelcomeToYahoo' with the help of 'SetText' operator. will check the check box Entertainment and 'WelcomeToYahoo. How to write different testcases? A Testcase A testcase ideally addresses one test requirement. But we have to .Click()'will click the button SubmitThisForm. once the testcase completes execution. But there are certain conditions that each and every test should be performed with various criteria checked. Here the normal way of testing is done by entering a text and checking whether that value is passed correctly. we can write the scripts effectively with easy understanding and it will be usefull if there is any need for future updation of scripts. variables (say HtmlText) at the ‘classes’ folder. It will be easy to find the path of all these files if we put these folders in a separate folder called ‘silktest’. • Silktest    Declarations Classes Testscripts for keeping the window declarations for keeping the winclasses & its contents for keeping the testscripts. If we follow the above style of programming. the classes and its fields. Note that the inverted commas is necessary with Settext operation. Let us consider a case of a text field ‘Name’ in a window. This will enable quick access to objects that are hidden fomr the window. We can also write scripts without using classes. 'WelcomeToYahoo. except the statement will be prined in red colour in the . will select the third value from the list.Click()'.Maximize() commands. Here what ever we specify as testcases/testscripts should be available at the (say) ‘testscripts’ folder. we can use SetActive(). Print is the method used to print a particular statement on the result file. classes.res file Tips for making programming clear To make programming clear To make the coding clear we can create three separate folders for testscripts. Also to activate the window.

Sometimes. We identify the controls and windows / frames of the application by looking at the identifiers. An Identifier: Name used in test scripts to refer to an object in the application. Logical. In that case. we can write the following testcases for testing the ‘HtmlTextfield Name’ (as viewed by silktest). For example consider the sample code given below. even an invalid value entered will take the application to crash the whole process and stops the application from progressing further. [-] window BrowserChild Yahoo . The conditions given in the test plan should be covered in the testcases. An experiment with the tags An experiment with the tags A Tag: is an object’s actual name or index as it appears in the GUI. [+] testcase Blank_Field() [+] testcase Valid_Text() [+] testcase Long_Text() [+] testcase Valid_Html() [+] testcase Invalid_Html() [+] testcase Invalid_Character() [+] testcase Valid_Character() [+] testcase Integer_Value() [+] testcase Valid_URL() [+] testcase Invalid_URL() There should be a test plan to be followed while writing the testcases. Identifier is mapped to the tag in a window declaration.look at the negative side too. GUI. to ensure that the data entered by the end user is a valid one. It is the name by which SilkTest locates and identifies objects in the application.Independent name.

Because only the window name or browser window name contains this keyword in the declaration part. the identifier name is 'CheckMail' and the tag value of it is '#2'. You will get another dialog box 'Record window declarations options' . there is a window declaration of the Yahoo home page (only some variables are given above for example). From the above example. select the 'options' button. But the tag value should not be changed since the silktest will identify the objects in the window (or) the window itself by only looking at the tag values. Hence. let us change the tag value for the HtmlImage CheckMail. Next comes the three variables. . Here no need to change the identifier name. the code will look like this. [-] window BrowserChild Yahoo   tag "Yahoo . The first variable is of datatype HtmlImage.  tag "Yahoo . To select multitag option.Here.Netscape" parent Browser [-] HtmlImage CheckMail  tag "#3" // tag changed [-] HtmlText Messenger  tag "Messenger" [+] HtmlLink PhotoGallery It is advisable to use muititags to avoid frequent change in tag values. • • • • Select the Record -> Window Declarations option from the menu bar.Netscape" parent Browser [-] HtmlImage CheckMail //expanded form of the variable  tag "#2" [-] HtmlText Messenger  tag "Messenger" [+] HtmlLink PhotoGallery In the above example. The 'parent Browser' text shows that the window is a main window and not a dialog box. The user/programmer will write the script using the identifier name and it can be changeable. In the 'Record Window Declarations' dialog box. You will get the Record Window Declarations dialog box waiting on your applicatoin to capture the window and its objects. It contains the BrowserChild (window) name followed by its tag value and the parent information. After changing the tag value from '#2' to '#3'. the tag value should be same as of that when declared.

Double click on the object. Now the silktest will capture the objects as multitags. BrowserCustomClass not found… then it might happen because of the change in tag value. Also the cursor will wait in the same line of the object. Say if you get the error ‘HtmlText Name not found’. The tag values are available in the third column of the ‘Record Window Declaration’ dialog box.jsp" parent Browser  [-] HtmlImage CheckMail  [-] multitag "Check Mail"  [ ] "#1" When to change the tag: Consider a situation that the testing process stops due to some error. After double clicking on the object that gives the error. If the tag value matches. It will take you the file where that object has been declared. chech the 'Record Multiple tags' option and click on the 'OK' button.) buttons simultaneously. if the error is ‘HtmlText not found’. Check for the tag value of the control that gives you the error. and activate your application manually. if the error is ‘BrowserCustomClass Not Found’ then click on the Window name. which gives you the error. How to change the tag: By making some changes in the script. then leave it as it is. Then go to menu Window-> Declaration in the silktest. We will check for the result file for the kind of error.Netscape"  [ ] "#12"  [ ] "$http:??yahoohomepage. press the Ctrl+Dot(. It can be considered as a limitation of the tool. Click on the [+] image in the object name. Follow the steps given below. then double click on the variable text. we have to continue the testing process.• • In that dialog box. [-] window BrowserChild Yahoo  [-] multitag "Yahoo . in order to check for errors. Check for the tag value. Double click on the error by keeping the cursor in the leftmost end of the error statement (that is indicated in red color) The control will take you to the statement where you get the error message. A multitag will look like as below. For example. to rectify the error in your code: • • • • • • • • • • • • Take the error file (result file). In Silktest. . If the error is something like HtmlLink not found. Click on the [+] image in the error statement. the tag value will get changed rarely. then check for the tag value of the text ‘Name’ to that of the value in the previously available identifier.

Configure the settings as given in lab I. It will open a new include file (of type . then copy the tag value of the entire window in a file. Copy the tag (only) of that particular object and overwrite it on the existing tag of that object. Save that file. . Go to the silktest. ie. Session VI: Lab III : How to login into the yahoo site using classes: Write a testcase using classes to compose and send a yahoo mail with an attachment..yahoo. and select the '4Test include file' option and click OK.(say Netscape) In the netscape browser. Press the 'Ctrl'+ 'Alt' keys simultaneously. Set it to Netscape. you can view all the objects of the yahoo home page declared. Now the chances of getting the error are minimal.com'. Use do…except statement to verify whether the email id already exists. Write a testcase to perform a stress test by adding 100 addresses into the addressbook of the yahoo site. Till that your application will be scrolled up and down to trap all the objects in that window. load the page 'www. Select 'Record -> Window Declarations' option from the menu bar and go to the browser (your application) Wait till the 'Record Declarations' dialog box appears. Make sure that you have to copy only the tag value and not the entire line / the identifier name.• • • If the tag value doesn’t match. To declare the window objects • • • • • • • • • • • • Start the SilkTest by selecting from the 'Start' menu. Write a testcase for registering into the yahoo mail-id.inc) Open the application in parallel. open the browser in which application has to be run. In silktest. compile it and run it again. the tag value of the window / objects will get changed rarely. Hence applying these steps is a necessary one in letting the testcase errorfree to make your application bug-free. To write a testcase using classes This example is to write the script for logging in to the yahoo site. It will activate the button 'paste to editor' in the 'Record Declarations' dialog box. In the resultant 'Record Declarations' dialog box. Click 'File -> New' menu. temporarily. Click on the OK button. Use any file to attach.

Netscape" parent Browser [+] HtmlLink CheckMail [+] HtmlImage SignIn [+] HtmlText Mails [-] HtmlTextField Password tag "Pasword" . Click on that button and paste the second page of the application in to the editor. Now it will display a code as given below. Till that the application will be scrolled up and down to trap all the objects in that window. [+] HtmlPushButton Submit • • • • • • • • • Now click on the 'Mail' link in the home page. Now declare that page in the include / declaration file. Press the 'Ctrl'+ 'Alt' keys simultaneously.Netscape" parent Browser [+] HtmlLink Mail [+] [+] [+] [+] HtmlImage LoginInfo HtmlText Newsletter HtmlTextField Search HtmlPushButton Submit • • [-] window BrowserChild SignInYahoo tag "Sign In Yahoo . (say) [-] window BrowserChild Yahoo //identifier for window tag "Yahoo . Wait till the 'Record Declarations' dialog box appears. Select 'Record -> Window Declarations' option from the menu bar and go to the browser. It will activate the button 'paste to editor' in the 'Record Declarations' dialog box. It will load the SignIn page.• • • Click on the 'paste to editor' button to paste the window objects in the silk editor. Go to silktest.Netscape" //tag for window parent Browser [+] HtmlLink Mail [+] HtmlImage LoginInfo [+] HtmlText Newsletter [-] HtmlPushButton Search // identifier for variiable search of type HtmlPushButton tag "Search" // tag value for the control pushbutton search. In the resultant 'Record Declarations' dialog box. [-] window BrowserChild Yahoo tag "Yahoo .all the objects of the yahoo SignIn page declared can be viewed. Now the include file will look as below.

Netscape" parent Browser [+] HtmlLink Mail [+] [+] [+] [+] HtmlImage LoginInfo HtmlText Newsletter HtmlTextField Search HtmlPushButton Submit • • [-] window BrowserChild SignInYahoo tag "Sign In Yahoo .o • • • [+] HtmlPushButton Submit Login into the site by supplying the username and password and get into it. Now the include file will be (say): [-] window BrowserChild Yahoo tag "Yahoo . The dec is just to mark that it is a declaration/include file. Now the browser will contain the 'Yahoo Mail' page. Create a folder myscripts in c:\ drive. Now using the above few steps declare the objects available in this page too.inc' in 'c:\myscripts' folder.com" • . const wMainWindow = Yahoo // default window name. Save the above inlcude file as 'decyahoo. It is not necessary to save the scripts in that same drive where the silktest has been installed.Netscape" parent Browser [+] HtmlLink CheckMail [+] [+] [+] [-] HtmlImage SignIn HtmlText Mails HtmlTextField username HtmlTextField Password tag "Pasword" • o [+] HtmlPushButton Submit [-] window BrowserChild YahooMail tag "Yahoo Mail .yahoo. Assume that the folder is created in c:\ drive.Netscape" parent Browser [+] HtmlLink Mail [+] [+] [+] [+] HtmlImage LoginInfo HtmlText Newsletter HtmlTextField Search HtmlPushButton Submit • • • Create a folder called myscripts (say) in any drive to save the include file. const sLocation="www. include the code given below in the above file.

then we can make the window declaraiton as given above. Also the silktest will automatically load the home page as the sLocation variable has been declared. Open the declaration / include file 'decsample. Many times we have to come across the dialog boxes that is apart from a browser. But don't close the 'Record Declarations' dialogbox. keep the mouse cursor inside the dialogbox (not on the dialog frame name) and press 'Crtl'+'Alt' keys.Netscape" • Now go to the application and in the 'Record Declarations' dialogbox.inc'. Assume composing a mail in Yahoo.Netscape'. Now. and click on the 'Yahoo! Mail' popup window. on clicking the 'Add attachment' link. [-] window BrowserChild Preferences [ ] tag "Preferences" [ ] parent PreferencesNetscape [+] HtmlTextField ChangePassword [+] HtmlPushButton OK [+] HtmlPushButton Cancel • Now check for the difference between the two. [-] window DialogBox PreferencesNetscape [ ] tag "Preferences . the declaration cannot be done as the other browsers. Here the name dialogbox can be used for activating / maximizing / minimizing while the name of the browserchild can be used for performing the window. This will save the exact contents of the windows as below.inc' file. Select the Record -> Window Declarations menu. Press the 'Ctrl' + 'Alt' keys simultaneously and paste the dialog name into the editor.with some attachment. a pop-up window 'Yahoo! Mail' will be loaded. and the of the the window the action in .• This is to mark that the 'Yahoo' window will be the application base state and every testcase will starts with the above window.The following steps has to be performed. keep the cursor on the top of the window frame of the pop-up window (a blue pane that contains the window name 'Yahoo! Mail . The Pop-Up window is what we call as dialog box in SilkTest. Differentiating the Window & Dialog box If we are opening the application in the browser. Wait till the 'Record Declarations' dialogbox appears. The declaration will be as below. The above two variables are declared in the 'c:\program files\segue\silktest\defaults. Now. click the 'Resume Tracking' button to continue tracking the window objects. • • • • • • Assume that all the windows in Yahoo are declared and thye current window is in 'Yahoo! Mail' dialog box. The dialogbox name bears the declaration of the window name browserchild bears the contents of the window. In the composing page. For that dialog box.

....Click() .... [-] window BrowserChild Yahoo tag "Yahoo .. ...... SignInYahoo.... No detail regarding window should exists.... Consider the following testcase that uses the above window declarations.. Hence change the text 'window BrowserChild' to the keyword 'winclass'..SetText("newpassword") Preferences. To write the class file using the above declaration file: • Now the declaration / include file that contains the declaration of the following windows (say). PreferencesNetscape....... it should contain only the class definition and its variables......t... • • • To start with the class file. Yahoo...... copy the declaration Yahoo....... YahooMail........ . in which select the '4Test include file' type.. Preferences.Maximize() Sleep(2) PreferencesNetscape..in sample..in decsample.. and the name of the browserchild and the dialogbox should not be the same.... .inc file into this new include file...... Copy the first window declaration from the decsample.Netscape" parent Browser [+] HtmlLink Mail [+] HtmlImage LoginInfo [+] HtmlText Newsletter [+] HtmlTextField Search o • • [+] HtmlPushButton Submit Since this is a class file.Make sure that the parent name of the browserchild is same as that of the dialogbox name..ChangePassword.........OK.SetActive() Preferences.....inc. Here..SetActive() PreferencesNetscape.. select the File -> New menu.. [-] window DialogBox PreferencesNetscape [-] window BrowserChild Preferences ......

say 'clsSample. Declare the inlcude file in your script file by including the below line in the begining. in the location 'c:\myscripts'.precede it with the word cls. Don't remove the tag value for the variables. [-] window BrowserChild Yahoo tag "Yahoo .. Start with the keyword 'testcase Login()' and press Enter key in your keyboard. Declare the declaration file in the testscripts file Declare the Class file in the declaration file.inc" Open a new testcase by marking the keyword 'testcase'.Netscape" parent Browser clsYahoo objYahoo // object of the class clsYahoo Perform the above set of task for all the windows. After performing the above changes the window declaration for the Yahoo will look like as below.inc'.• • • • Then change the name 'Yahoo' to 'clsYahoo' (say)since the name of the window should not be the same as that of its class. ie. that class should contain all the variables or controls that belong to this window. the class file will look like as below: [-] winclass clsYahoo [+] HtmlLink Mail [+] HtmlImage LoginInfo [+] HtmlText Newsletter [+] HtmlTextField Search o [+] HtmlPushButton Submit Now go to the 'decsample. Create an object for that class to where you have put all those variables that comes under this window. ie. put 'use "c:\myscripts\decsample. • • • • • • • • • • • • • • • To write testscript using the above include file: • • • • • • Already the include file 'decsample. Now save the class file in any name. The testcase is the default keyword for any testcase and the name .inc file For the dialog boxes. Delete all the variables. create objects for the BrowserChild 's and not for the 'DialogBox'es.. ie. The name can be changed to anything but to make it clear that it is a class file.inc' in the folder c:\myscripts.t file put 'use "c:\myscripts\clssample. Now.inc' file and make the changes given below.inc"' in the decsample.inc"' in the sample. use "c:\myscripts\decsample. click on the File -> New option and open a new '4Test include file' file.. delete it. Then remove the tag value for the window name only. whatever comes next to the 'parent browser'. After performing the above.

• • • • Login is the name of the testcase.SetActive() // this is to activate the window Yahoo. which browser it is being worked. use "c:\myscripts\decsample. save it in the folder. Session VII : Browser & Platform independence Platform Independent Silk Test doesn't care about how the application is created.Click() if YahooMail.. an image as a HTML Image.Submit. in which operating system the application is running.. Assume that classes have been created for all the windows.regardless of the technology behind them. Cannot log in") else LogError("Cannot Load Yahoo sign in page") • • • After completing the script.Username. The web objects they display can also be aligned or displayed in different manner.For running the scripts.Password. Now compile the above tetscase and run it. The user may use any browser of his choice to test the standard application.Exists() print("The yahoo sign in page is loaded") SignInYahoo. a result file will be obtained where the status of the test can be known. They show the same page differently.Click() // to click the mail link in home page if SignInYahoo.Mail.Exists() print("You have sucessfully logged in") else LogError("Sorry. what kind of design is used. Now start writing the testcase (write the below code). Browser Independent There are various kinds of browsers used by various people for running their applications. refer Lab I. a table as a HtmlTable.t' in the 'c:\myscripts' folder. Save it as 'sample. At the end of the run. All that needs for an application to be tested using silktest is that it needs a frame ( like window). For example.SetText("username") SignInYahoo. The name of the testcase can be anything but it is advisable to name it clearly so that it will represent the functionality of the test. in which software the application is written. Each and every browser acts differently with different applications.objYahoo.inc" testcase Login() Yahoo. The SilkTest recognizes the objects as they appear in the screen. in a web based application. .SetText("pasword") SignInYahoo. the silkiest sees a link as a HTML Link..

.e.SilkTest just looks at these browser contents as objects and hence they cannot avoid any images. Feel Healthier.E. For example -------------------------------------------------------------------------------HtmlLink SomeLink explorer tag "Checkout" // for IE netscape tag "#2" // for Netscape -----------------------------------------------------------------------//Window Use [-] window BrowserChild MyToica [ ] tag "^?my?" [ ] !netscape4 tag "Toica: My Toica-New" [ ] netscape4 tag "Toica: My Toica" .inc file) and write the . we now have to make the same test case run on Netscape since the tag value changes from multiple browsers.. your tests are robust enough to support different browsers and different versions of these browsers... How to use the same code for multiple browsers: Start writing the silk scripts..t file for this we would write is MyWebsite.0 If the same objects have different tags. Technology Independent Silktest does not care how the application was built. using SilkTest. Also we can write a test in one browser and run it in any other browser (to some extend). Capture the window declarations (.webmd. texts. It seamlessly works with the different web technologies commonly used today.test.Click() and this worked fine on IE5. As we captured the declarations from I. we can do cross browser testing. that they are not identifiable. i. With minor modifications.t file.net?mywebmd?images? misc?JoinToday. you can use the browser tag specifiers to change the object for IE and Netscape. Say if you are capturing the declarations from Internet Explorer & runs successfully on it..Join. Join Today Go!" • [ ] "#12" • [ ] "$http:??images.gif" ------------------------------------The . An Include file ----------------[-] window BrowserChild MyWebsite  [-] HtmlImage Join • [+] multitag "Be Smarter.

If you do not copy SilkTest_Java2. When you install SilkTest. . Testing non-web applications Testing the Windows based applications Before start writing scripts. To set the server database to a known state. enable the settings given below.2 by copying SilkTest_Java2.2 for testing. you can activate Java support for JDK 1. 2. you have to set the java classpath.2 and JRE 1.jar. the silktest will automatically create a declaration file with the default window declared. In the resulting ‘New Test Frame’ dialog box.jar to your JDK 1. 4.jar is installed in this directory: <SilkTest install directory>\JavaEx If you will use only JDK 1. Testing the Java based applications Before you start testing the java applications or applets. After submitting that dialog box. 3. In the File -> New option in the menu bar. • • • • Point to a Java archive (.2 install directory. Database Tester & its functions Database tester SilkTest provides facilities for testing a distributed application that accesses a database or directly testing database software itself for the following reasons.jar file) that contains the software that powers SilkTest's Java support for JDK 1.[ ] parent Browser //Object Use [-] HtmlTextField FirstName • • [ ] netscape4 tag "[TextField]First Name:" [ ] !netscape4 tag "$ufn" Using the above you can run the same script across browsers.2. Declare all the window names and its objects (used in writing scripts) starting from the first window. you must point to it from your CLASSPATH.jar from <SilkTest install directory>\JavaEx to <JDK 1. Use that file to create your testscripts. 1. 5. select the test frame. • • To exercise certain database functions that are present in a GUI that runs directly on the server machine and is not a client application. specify the path of the executable file of your application. SilkTest_Java2. This file is called SilkTest_Java2.2 install directory>\jre\lib\ext.

using SQL. The database tester provides direct access. DBTester comprises six functions that allow you to read and write database records without using the application's user interface. The database functions. It uses all the DBTester functions except DB_FetchPrev. Thus we can verify client test results without assuming the ability of the client to do that verification. DB_FinishSql : Removes the result of the SQL statement and releases the associated system resource (statement handle). Thus. To read information from the database to use as input to a testcase. DB_ExecuteSql : Sends an SQL statement to the database for execution. The functions that support these operations begin with the letters “DB_”. DB_FetchPrevious : Retrieves the previous row from the database. from a test script to any database supported by ODBC drivers. DB_Disconnect : Closes the connection between SilkTest and the database and releases all resources. submit an SQL statement. SQL statements can be submitted to the database. Overview of DBTester DBTester provides direct access. which you use exactly as you use DB_FetchNext. • • • • • DB_Connect : Opens a database connection and returns a handle to that system. About a dozen of these functions allow you to access your databases catalog tables. These database functions enable you to read and write database records without using the client application. read data from the selected record(s) if the SQL statement was SELECT. and subsequently disconnect from the database. In addition to using the SQL functions in your tests. Manage your test data in a database instead of in a text file. DB_FetchNext :Retrieves the next row from the database. allow you to connect to a database. among other things. While the example is based on a sample database. iheadID STRING sDeptName HDATABASE hdbc HSQL hstmnt . updating it with the results of your testing. An example showing the database testing functions used together This example shows how to use the DBTester functions together to access a database. testcase DBTest () // This test uses the functions in DBTester // to directly access an ODBC database INTEGER id. we can also use these functions to help manage our testing process by • • Maintain a bug database.• • To verify an application's database results without using the application. but the technique is the same regardless of which ODBC database you are accessing. from a SilkTest script to a database supported by ODBC drivers. you can test an application's database or database software without using the application itself. using SQL.

STRING sOverallTime HTIMER TotalTimer TotalTimer = TimerCreate () TimerStart (TotalTimer) // Statements to accomplish any task .PWD=sql.// connect to Powersoft Demo DB hdbc = DB_Connect ("dsn=Powersoft Demo DB V5. There are set of timer functions to accomplish the above tasks . "SELECT * FROM department") // process the information that came back print ("Here's the info in the Department table:") print () while (DB_FetchNext (hstmnt. Illustration to timer functions : This illustration used to calculate the time taken for the testcase to complete execution . iheadID)) print ("Dept: {id} Name: {sDeptName} Head: {iheadID}") // release resources (unneeded really because immediately followed by disconnect) DB_FinishSQL (hstmnt) // disconnect DB_Disconnect (hdbc) // // // // // // // Timer functions The main use of timer function is to measure the time taken for an particular operation . 4Test timers are accurate to the millisecond (. It can be used like a stop watch to measure elapsed time. sDeptName. ( For Ex : The time taken by the browser to load a page ) TimerStop (TotalTimer) sOverallTime = TimerStr (TotalTimer) Results: Here's the Dept: 100 Dept: 200 Dept: 300 Dept: 400 Dept: 500 info in the Department table: Name: R & D Head: 501 Name: Sales Head: 902 Name: Finance Head: 1293 Name: Marketing Head: 1576 Name: Shipping Head: 703 .001 seconds). id.UID=dba") // retrieve info from Department table hstmnt = DB_ExecuteSql (hdbc.

TimerStop stops the specified timer.res) file. The following code creates a file with 100 lines [-] testcase WorkingWithFile () [ ] HFILE NewFile [ ] NewFile = FileOpen ("C:\MyFile.txt". stext) The following sample code shows how to read from a file and print contents into results (*. .Print ("All code executed in {sOverallTime} seconds") TimerDestroy (TotalTimer) TimerCreate function creates a timer to keep track of an operation time . TimerDestroy destroys the specified timer.TimerStart function starts the specified timer. writing the data retrieved from the application for validation purpose and also for creating custom output files. soutput)) [ ] print (soutput) . FM_READ) [ ] string soutput [-] while (FileReadLine (ReadFromFile. [-] testcase ReadFromFile () [ ] HFILE ReadFromFile [ ] ReadFromFile = FileOpen ("C:\MyFile. FM_WRITE) [ ] string stext [] [ ] integer i [-] for i = 1 to 100 [ ] stext = "Sample Text" + str(i) [ ] FileWriteLine (NewFile. Total time taken for an operation to complete is difference between timer stop and start minus the time paused. Find the sample code below for creating and working with the files.txt". File functions We may have to deal with files in regular course of testing for different needs like getting data for input for data entry purpose.

//This is the final package name.setText(labelPrefix + numClicks). public Component createComponents() { final JLabel label = new JLabel(labelPrefix + "0 "). Now leave the application as it is and Create a new Test Frame. Run it by giving the command 'java SwingApplication'.event. changes after clicking the button provided.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { numClicks++. private int numClicks = 0. button.java' in the command prompt. and on clicking it will display the number of times it has been clicked. //import com.*. • • • • • • • • Copy the code given below in a text editor.*. } }). button. ----------------------------------------------------------------------------------------import javax.sun. Source code for a simple Java application The given java application contains a button. public class SwingApplication { private static String labelPrefix = "Number of button clicks: ". using timer function.*.2 Beta 4 and all //Swing releases before Swing 1.swing.awt. . Write the test script using that test frame.1 Beta 3.java Go to the command prompt. Lab IV: Source code for testing non-web application: Write a script to test the non-web application provided above and check whether the number being displayed. Write a testcase to find the time taken to add 100 addresses in Yahoo address book. Compile the code by giving the command 'javac SwingApplication. JButton button = new JButton("I'm a Swing button!"). Specify the path of the source file in Runtime -> Extentions. label.*. Save the code as SwingApplication. import java.the contents are written to the variable soutput.java. the content can be used anywhere in the testcase to enter the data on user interface. label.awt.setLabelFor(button).swing. import java. //Used by JDK 1.VK_I).setMnemonic(KeyEvent.

//Finish setting up the frame. //top 30.exit(0).add(contents. BorderLayout. 1)). pane. pane. } } ---------------------------------------------------------------------------------------Session IX: Using silktest in functionality. regression and stress testing in real time application.getContentPane()./* * An easy way to put space between a top-level container * and its contents is to put the contents in a JPanel * that has an "empty" border.add(label). frame. frame.setVisible(true). } catch (Exception e) { } //Create the top-level container and add contents to it.setBorder(BorderFactory. return pane. Component contents = app.setLookAndFeel( UIManager.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System. pane.createComponents(). //left 10. //bottom 30) //right ). and show it. */ JPanel pane = new JPanel(). frame.add(button).pack().CENTER). frame.setLayout(new GridLayout(0.createEmptyBorder( 30. } public static void main(String[] args) { try { UIManager. SwingApplication app = new SwingApplication(). pane. JFrame frame = new JFrame("SwingApplication").getCrossPlatformLookAndFeelClassName()). } }). Session X: Lab V: .

inc’ file in your silktest-installed directory. • Send a mail with the subject 'subject'. Enable the extension to 'IE . change the password to the same word. • Add Invalid addresses and check for errors. in home page.DOM' for Internet Explorer 5. How to start testing the window based applications? Before start writing scripts.0 in Options -> Extensions.Write the following testcases for Yahoo site. Use Internet Explorer 5.com” // say if the URL of the home page is as specified. • Open that mail and delete that after opening. Frequently Asked Questions How to start testing the web based applications? Before start writing scripts. • Login to yahoo mail and check for the existence of mails.  Declare all the windows and its objects (used in writing scripts) starting from the home page. (see declarations below). Concluding the session.  Const sLocation = “www. and search for the word 'subject' in the 'Search' option.  Use that file to create your scripts. • Delete all the mails in the inbox and send a new mail to your id.  Set the Home page as the default window in your declaration file.yahoo. .  Const wMainWindow = Yahoo // say if ‘Yahoo’ is the name of the window.0 / Win NT combination to test the application. • In the option menu. Start from the beginning to declare the windows and its objects in IE.  The above-specified constant variables are already declared in the ‘defaults.

and check the value returned by the Exists method. My window tags are very dynamic. You can even specify more than one value for each tag type. If you want to check for the existence of a window with a specific number of seconds as a limit. Multitags are very useful in many situations.Exists (5). If you do not want an error to be raised then use the method without the Verify statement. you can experiment with the setting in the Agent Options dialog to increase the window time-out. the silktest will automatically create a declaration file with the default window declared. and when will it not work? Multitags are meant to make your scripts less sensitive to changes at runtime. However. depending on your application performance and your machine's speed. the SilkTest Agent will try to resolve the object's tag by searching from the top of the declaration to the bottom until it finds the object. which are either dynamic or inconsistent for some reason. The multitag functions as a logical OR. After submitting that dialog box. The "Exists" method in 4Test is useful in a situation where timing is an issue. You can specify as many tag-strings as you want in a multitag statement. it matches a window or object if any of its components match. in a dynamic environment. Why do I get the message "Window not found"? I know the window exists It may be that you are using windows that are dynamic. you need to use the multitag features.• • • • • Declare all the window names and its objects (used in writing scripts) starting from the first window. In the resulting ‘New Test Frame’ dialog box. specify the path of the executable file of your application. Use that file to create your scripts. and if so. when a testcase is running. Timing often plays a role in this issue. In the File -> New option in the menu bar. Some objects or windows may take longer to load than SilkTest is expecting. TRUE) The "Verify" command is wrapped around the test so that an error will be raised. select the test frame. When will the multitag work. In this case. In general. How can I handle this? The "Window not found" error occurs for many reasons. Use the "Sleep" command in your 4Test script as well to slow down the script while waiting for a particular window to appear. the . This is useful with Java applets since they are known to be slow when downloading into a browser. that is. then try the following 4Test code in your script: Verify (SaveMessage.

When the error occurs. and then the installation continues. In Win95 and Win98 environments. How do I update tags in a declaration file without recording declarations again? To activate the "Record Tags" menu item in SilkTest 5. SilkTest modifies the GDI32.problem is usually related to window tags. If you are using Windows95 or WindowsNT. To remedy this . it usually means that a previous version of SilkTest was not un-installed properly. select Options/Agent. after making a backup of the original into the Segue sub directory. but not WinNT. you will see a message that SilkTest is inspecting the GDI32. and in general it is not good practice to run the same script across browsers. and you might want to try the suggestions in why do I get the message “Window not found”? I know the window exists. During installation. Installing SilkTest under Win95/98. if you can see the window on the screen. Save the new tags to your .dll is restored back to the Windows System directory.dll file. Normally. remove the Active Desktop before installing and running SilkTest. captions. and then click on the Compatibility tab. You will then be able to record the tags that have changed.0. If you do not see the window on the screen. In dynamic environments. Why doesn't SilkTest 5. it may rule out a timing issue and point more toward a tag issue. then it may be a timing issue. If you watch the script run. this error usually occurs because the tag that was generated is no longer appropriate. try to see what is on the screen at the time of the error. SilkTest modifies the GDI32.dll file.INC file so that you can continue to use them in subsequent tests.dll file. an error message refers to the GDI32. the original GDI32. it is possible that the original dll will not be successfully copied back into the Windows System directory. When recording test cases for browsers. One of the major symptoms encountered with Active Desktop and NT or 95 is that the objects inside IE4 are ignored or invisible to SilkTest. How do I create 4Test scripts that will work in cross browser situations? Browsers such as Internet Explorer and Netscape behave differently. which takes a few minutes. This can occur in both Win95 and Win98. Select Add Window Tags to the Record Menu.dll file for its own use during an install. During a un-install. If for some reason the SilkTest un-install process is interrupted or corrupted.DLL file? If you get a message stating that there is a problem with the GDI32.0 with IE4 see some of the objects on my page? If you are using Windows98 the Active Desktop co-exists with SilkTest without any known issues. and tags. it is best to record and playback in the same browser version to avoid problems such as inconsistent window IDs.

you should have no problems with the installation. What are the requirements for a test environment for Java applications and applets? There are a number of issues to consider in setting up a Java testing environment. and each vendor has setup requirements. to set up the agent machines for distributed or remote testing. In addition. If you are using more than one agent machine in a test.0 agent installation is the same as the general installation. enter the host name of the agent machine (if you are testing against one agent machine). If you have the appropriate license for your agent machine. replace the original GDI32. you will need to connect to all agents from your 4Test script. enter the network protocol in use between the host and the agent. Some vendors build their own JVMs. you will need to perform these steps: In the Options/Runtime tab. which are necessary for the Java application to run properly. the SilkTest 5. However. . It can get complicated since there are many vendors who supply Java classes.dll by placing it in the Windows System directory. see what is the Silk Bean and in what environments can it be used. Below is a table listing the issues that you need to consider before taking the steps to set up your Java test environment. Segue's SilkTest requirements need to be added to the mix.0 agents? Unlike some previous versions. In the Options/Runtime tab. How do I install and start SilkTest 5. If you plan to use the Silk Bean for distributed testing of Java applications.situation.

Sign up to vote on this title
UsefulNot useful