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.

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

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.As many levels of description can be used.x Internet Explorer 4 and 5 ActiveX. a system needs to run the silk test is given below. called testcases. Statements that link the test descriptions in the plan to the 4Test routines. Visual Basic 5 and 6 Java JDK 1. that accomplish the actual work of testing. o o o o Windows NT.3 Swing 1. A basic testplan is structured as a hierarchical outline and contains: • • Descriptions of individual tests and groups of tests. In web based applications.the automated testing process is started by creating a testplan. System requirements The minimum requirement. Recording a test frame .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.• • It may be necessary to make some modifications if testing should be shifted to other browser/operating system. Windows 95. sometimes silktest will take the links as simple text.

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

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

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

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

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

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

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

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

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

the keyword 'Yahoo' is called as the identifier. //------------------------------------------------------------------------------------------------------// a sample Window Declaration include file ( decregistration. Using this declaration file. 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.t ) use "c:\scripts\decregistration.inc" testcase registration() .Netscape" parent Browser [+] HtmlText Home o tag "Home" [+] HtmlText ClickforMail o tag " ClickforMail " In the above example.• • • • tag "Yahoo .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.inc )  //decregistration. we can start writing testscripts.inc"  [-] window BrowserChild SignInYahooMail o o o o tag "Sign in .

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

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

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

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

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

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

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

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

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

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

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

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

GetState ()) // prints WS_MAXIMIZEDTextEditor. subtraction.Minimize ( ) Notes Minimize does nothing if the window is already an icon.Maximize ()Print (TextEditor.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. 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.TextEditor.Minimize ()TextEditor. Syntax window. Example TextEditor. 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. and modulus operations. multiplication. division. exponentiation.Restore ()Print (TextEditor.GetState ()) // prints WS_NORMAL Minimize() method Class : MoveableWin class Action : Reduces the window to an icon. and returns the remainder Exponentiation**Lets you refer to a number in terms of a base value and an exponent Operand type .

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

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

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

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

Syntax for each item in expr statement VariableDescription itemA variable name. When every element in the list or set has been processed. the iterator sets item to the value of another list or set element. Syntax if boolean-expr .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.. Each time it executes. control passes to the next statement in the script. and then control passes back to the iterator to check for another item. Example testcase foreachExample () LIST OF STRING lsFruit = {.} "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. statementA single statement or a series of statements.. exprAn expression that evaluates to a list or a set. the statement section executes for that value. Notes The for each iterator executes once for each element in the list or set specified by expr.

Example testcase ifExample () INTEGER i = 1. control passes to the else clause. if any. the statement immediately below it is executed.. and if boolean-expr is FALSE.statement [else statement] VariableDescription boolean-exprA boolean expression. 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. statement is not executed. If there is no else clause in an if statement. statementA single statement. Syntax switch (expr) case case-value(s) statement [ case case-value(s) statement ].. If the value of the boolean expression is FALSE. and control passes to the next statement in the script (which could be another if statement).. or a series of statements.. [ default statement ].

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

Example TestVerification (STRING sExpectedValue..MyPageList..Select ("/Options/Agent") do . STRING sTestValue) if ( sExpectedValue == sTestValue ) Print ("Test was successful") else raise 1. see the PageList class. For TabList controls. LISTITEM Notes Select causes the specified page to become the current (active) page in the pagelist. Syntax pagelist. For information on specifying sPage. sTestValue) except .//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. statements2A single statement or series of statements (executed only if exception is raised in statements1). Select generates a click on the specified tab.Select (sPage) VariableDescription sPageThe page to select. "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. Example MyDialog. except statement Action :Handles (ignores) an exception without halting a script. Syntax do statements1 except statements2 VariableDescription statements1A single statement or series of statements that may generate an exception.

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

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

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

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

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

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

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

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

objSignYahooMail.SetText(x.usrid) logpwd.com") SignInYahooMail.void Login(login x) • • logid.inc use "decsigninyahoomail.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 .LoadPage("www.inc" login loginfo // object declared for the structure testcase login() • • • • loginfo{"USER_ID".SetActive() SignYahooMail.SetText(x.yahoomail. "USER_PWD") // passing parameter for the object of a struct Browser.usrpwd) DESCRIBING YOUR TESTCASE FOR LOGIN: file://tlogin.t use clsstructure.

• • • • • • • • • • • • • • 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. The third column corresponds to the REAL data type. the following C data types are supported for use in calling functions in DLLs. including enumerated types and records.• • • TABLEROW TIME WINDOW C data types for DLL functions In addition to the 4Test data types. User-defined types You can also create new data types. The following table summarizes the functions by category: • • • • • Application state Array manipulation Char/string conversion Data type manipulation Distributed processing .

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

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

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

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

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

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

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

GUI. The conditions given in the test plan should be covered in the testcases. It is the name by which SilkTest locates and identifies objects in the application. Sometimes. In that case. [-] window BrowserChild Yahoo . For example consider the sample code given below. An Identifier: Name used in test scripts to refer to an object in the application. we can write the following testcases for testing the ‘HtmlTextfield Name’ (as viewed by silktest). even an invalid value entered will take the application to crash the whole process and stops the application from progressing further.look at the negative side too. Logical. [+] 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. to ensure that the data entered by the end user is a valid one.Independent name. 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. We identify the controls and windows / frames of the application by looking at the identifiers.

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

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

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

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

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

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

Hence change the text 'window BrowserChild' to the keyword 'winclass'..inc.....in sample. copy the declaration Yahoo.... and the name of the browserchild and the dialogbox should not be the same............in decsample... PreferencesNetscape. ... select the File -> New menu. No detail regarding window should exists.........OK........... 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... in which select the '4Test include file' type.. To write the class file using the above declaration file: • Now the declaration / include file that contains the declaration of the following windows (say).SetActive() Preferences... [-] window DialogBox PreferencesNetscape [-] window BrowserChild Preferences ..... Here.. • • • To start with the class file.t.. Preferences. [-] window BrowserChild Yahoo tag "Yahoo .....Maximize() Sleep(2) PreferencesNetscape..... .....Click() ..SetText("newpassword") Preferences.SetActive() PreferencesNetscape.. YahooMail. SignInYahoo.Make sure that the parent name of the browserchild is same as that of the dialogbox name.. Consider the following testcase that uses the above window declarations........inc file into this new include file.. Yahoo..ChangePassword... .. it should contain only the class definition and its variables.......

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

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

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

specify the path of the executable file of your application. • • • • Point to a Java archive (.jar is installed in this directory: <SilkTest install directory>\JavaEx If you will use only JDK 1.2 and JRE 1. you must point to it from your CLASSPATH. 5. Testing non-web applications Testing the Windows based applications Before start writing scripts.2 install directory. In the File -> New option in the menu bar.jar.2 by copying SilkTest_Java2. 4. you have to set the java classpath. 3.jar to your JDK 1. .2 for testing. Use that file to create your testscripts. Testing the Java based applications Before you start testing the java applications or applets.jar from <SilkTest install directory>\JavaEx to <JDK 1. • • To exercise certain database functions that are present in a GUI that runs directly on the server machine and is not a client application. select the test frame. If you do not copy SilkTest_Java2. In the resulting ‘New Test Frame’ dialog box.[ ] 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. This file is called SilkTest_Java2. enable the settings given below. the silktest will automatically create a declaration file with the default window declared. 1. you can activate Java support for JDK 1. Declare all the window names and its objects (used in writing scripts) starting from the first window.2. After submitting that dialog box.2 install directory>\jre\lib\ext.jar file) that contains the software that powers SilkTest's Java support for JDK 1. When you install SilkTest. To set the server database to a known state. 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. 2. SilkTest_Java2.

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

There are set of timer functions to accomplish the above tasks . 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 . It can be used like a stop watch to measure elapsed time. STRING sOverallTime HTIMER TotalTimer TotalTimer = TimerCreate () TimerStart (TotalTimer) // Statements to accomplish any task . "SELECT * FROM department") // process the information that came back print ("Here's the info in the Department table:") print () while (DB_FetchNext (hstmnt. 4Test timers are accurate to the millisecond (.// connect to Powersoft Demo DB hdbc = DB_Connect ("dsn=Powersoft Demo DB V5. id.UID=dba") // retrieve info from Department table hstmnt = DB_ExecuteSql (hdbc. Illustration to timer functions : This illustration used to calculate the time taken for the testcase to complete execution .PWD=sql.001 seconds). 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 .

[-] 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. soutput)) [ ] print (soutput) . writing the data retrieved from the application for validation purpose and also for creating custom output files.TimerStart function starts the specified timer. FM_READ) [ ] string soutput [-] while (FileReadLine (ReadFromFile.res) file.txt". TimerDestroy destroys the specified timer.Print ("All code executed in {sOverallTime} seconds") TimerDestroy (TotalTimer) TimerCreate function creates a timer to keep track of an operation time . . Find the sample code below for creating and working with the files. Total time taken for an operation to complete is difference between timer stop and start minus the time paused. stext) The following sample code shows how to read from a file and print contents into results (*. The following code creates a file with 100 lines [-] testcase WorkingWithFile () [ ] HFILE NewFile [ ] NewFile = FileOpen ("C:\MyFile. 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. TimerStop stops the specified timer.txt".

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

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

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

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

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

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

Sign up to vote on this title
UsefulNot useful