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.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

. depending on the value of an expression. raise raises a user-defined exception.else executes a statement block based on the value of a boolean expression. The following table summarizes the statements. Handle exceptions do. 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... select executes one case from a group of cases. for executes the loop once for each increment of a counter.. while executes a loop until a test condition (boolean expression) is false. we can add logic and robustness to a recorded testcase. Conditionally execute a statement block if. By using 4Test flow-of-control statements.except handles an exception (error) rather than having it halt the script. reraise reraises an . 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.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Sign up to vote on this title
UsefulNot useful