P. 1
SilkTest_trg

SilkTest_trg

|Views: 198|Likes:
Publicado porbiswajit800

More info:

Published by: biswajit800 on Oct 28, 2011
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

11/08/2012

pdf

text

original

Sections

  • Different kinds of testing
  • Error testing
  • Stress testing
  • White - Box testing
  • Black - Box testing
  • Distributed testing
  • Multi - User testing
  • SilkTest:
  • 1. Record testcase 2
  • 2. Write the testcase manually
  • Other Segue products
  • SilkTest Features:
  • SilkTest architecture
  • SilkTest host software
  • The Agent
  • Limitations of SilkTest:
  • The automated testing process
  • Creating a testplan
  • Creating testcases
  • Running testcases and interpreting results
  • A Test Frame
  • A Test Plan
  • A Test Suite
  • SilkTest installation tips
  • Procedure To use the wizard:
  • Configuring the settings
  • To start the SilkTest tool
  • To compile & run scripts
  • To open a new or existing files
  • To write a new plug & play testcase (using Action)
  • Customization of scripts by runtime options
  • Declaring a window:
  • A Sample Testcase with the declaration file
  • Brief Description:
  • Running the silkscripts
  • Naming conventions
  • Debugging the scripts
  • Using do...except
  • Application State
  • Recording the Events / Action
  • Basic Object-oriented features
  • Classes
  • Methods
  • Objects
  • Properties
  • Inheritance
  • Methods in 4Test
  • Click() method (HtmlLink)
  • SetText method (TextField)
  • Notes
  • Example
  • Exists() method
  • LoadPage() method
  • Maximize() method
  • Minimize() method
  • Arithmetic operators Definition
  • OperationResulting set
  • -- (operator) and ++ (operator)
  • Examples
  • Logical Operators Definition
  • Scope resolution operator
  • Bitwise operators Definition
  • Result type
  • Statements in SilkTest
  • For statement numeric iteration
  • If Statement
  • Select method (PageList)
  • To write a testcase using 4test include file & 4test script file
  • To declare the window objects
  • To write testscript using the above include file
  • Note:
  • Differentiating the Window & Dialog box
  • Using the OOPS concept in Silk Test
  • Advantages of Oops:
  • Writing a testcase using classes & declarations:
  • Using Structures
  • DECLARING A STRUCTURE:
  • More on 4test language
  • Built-in data types
  • C data types for DLL functions
  • User-defined types
  • Built-in functions
  • Sample script for 4Test statements
  • Sample code with description
  • To make programming clear
  • A Testcase
  • When to change the tag:
  • How to change the tag:
  • To write a testcase using classes
  • Platform Independent
  • Browser Independent
  • Technology Independent
  • How to use the same code for multiple browsers:
  • An Include file
  • Testing the Windows based applications
  • Testing the Java based applications
  • Database tester
  • Overview of DBTester
  • An example showing the database testing functions used together
  • Source code for a simple Java application
  • Frequently Asked Questions

http://www.geocities.

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

verifies the response of the system when a large number of users are connected to the database. Other types of tests verify that a process on one machine is capable of initiating a process on another machine. SilkTest overview SilkTest: SilkTest is a tool specifically designed for doing regression1 and functionality testing. It is developed by Segue Software Inc. SilkTest is the industry's leading functional testing product for e-business applications, whether Window based, Web, Java, or traditional client/server-based. SilkTest also offers test planning and management, direct database access and validation, the flexible and robust 4Test scripting language, a built-in recovery system for unattended testing, and the ability to test across multiple platforms, browsers, and technologies. The version of SilkTest which is being used is the 5.0.3. You have two ways to create automated tests using silktest:

1. Use the Record Testcase command to record actions and verification steps as
you navigate through the application.

2. Write the testcase manually using the Visual 4Test scripting language.
1. Record testcase 2 The Record/Testcase command is used to record actions and verification steps as you navigate through the application. Tests are recorded in an object-oriented language called Visual 4Test. The recorded test reads like a logical trace of all of the steps that were completed by the user. The SilkTest point-and-click verification system allows you to record the verification step by selecting from a list of properties that are appropriate for the type of object being tested. For example, you can verify the text that is stored in a text field. 2. Write the testcase manually We can write tests that are capable of accomplishing many variations on a test. The key here is re-use. A testcase can be designed to take parameters including input data and expected results. This “data-driven” testcase is really an instance of a class of testcases that performs certain steps to drive and verify the application-undertest. Each instance varies by the data that it carries. Since far fewer tests are written with this approach, changes in the GUI will result in reduced effort in updating tests. A data-driven test design also allows for the externalization of testcase data and makes it possible to divide the responsibilities for developing testing requirements and for developing test automation. For example, it may be that a group of domain experts create the Testplan Detail while another group of test engineers develop tests to satisfy those requirements.
1

A set of baseline tests that are run against each new build of an application to determine if the current build has regressed in quality from the previous one. 2 In a script file3 , an automated testcase that ideally addresses one test requirement. Specifically, a 4Test function that begins with the testcase keyword and contains a sequence of 4Test statements. It drives an application to the state to be

tested, verifies that the application works as expected, and returns the application to its base state. 3 A script file is a file that contains one or more related testcases. A script file has a .t extension, such as find.t. Other Segue products The Silk products include SilkTest for functional and regression testing SilkPerformer for load and performance simulation SilkPilot for functional and regression testing CORBA and EJB servers SilkRadar for automated defect tracking SilkVision for enterprise application health monitoring SilkExpress for a scalability and load testing consulting

solution

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

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

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

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

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

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

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

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

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

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

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

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

inc )  //decregistration.Yahoo! Mail" parent Browser [-] HtmlLink SignUpNow tag "Sign up"  [-] window BrowserChild WelcomeToYahoo o o o o o o o tag "Welcome to Yahoo!" parent Browser [+] HtmlTextField SignUpForYourYahooID1 [+] HtmlTextField SignUpForYourYahooID2 [-] HtmlButton SubmitThisForm tag "Submit this *" //------------------------------------------------------------------------------------------------------// a sample script file ( registration.inc" testcase registration() .inc"  [-] window BrowserChild SignInYahooMail o o o o tag "Sign in . 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.inc  use "c:\scripts\clsregistration. //------------------------------------------------------------------------------------------------------// a sample Window Declaration include file ( decregistration. Using this declaration file.• • • • tag "Yahoo . we can start writing testscripts. Creating simple scripts A Sample Testcase with the declaration file Let us consider the sample testcase for registering in the yahoo mail site.t ) use "c:\scripts\decregistration.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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. including enumerated types and records. • • • • • • • • • • • • • • 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 .• • • TABLEROW TIME WINDOW C data types for DLL functions In addition to the 4Test data types. The third column corresponds to the REAL data type. User-defined types You can also create new data types.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

You're Reading a Free Preview

Descarga
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->