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.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

GetState ()) // prints WS_MAXIMIZEDTextEditor. 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.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.TextEditor.Restore ()Print (TextEditor.Minimize ( ) Notes Minimize does nothing if the window is already an icon.Minimize ()TextEditor. exponentiation. subtraction. multiplication. Addition+Adds one operand to the other Subtraction -Subtracts the second operand from the first Multiplication *Multiplies one operand by the other Division /Divides the first operand by the second Modulo%Divides the first INTEGER operand by the second.Maximize ()Print (TextEditor. division. Example TextEditor. Syntax window. The most commonly used operators are discussed in here briefly These can be classified as • • • Arithmetic Operators Logical Operators Bit wise Operators Arithmetic operators Definition The arithmetic operators perform addition.

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

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

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

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

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

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

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

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

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

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

• • • • • • • • • • •

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

• • • • • • • • •

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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 .// connect to Powersoft Demo DB hdbc = DB_Connect ("dsn=Powersoft Demo DB V5.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 . 4Test timers are accurate to the millisecond (.001 seconds). It can be used like a stop watch to measure elapsed time. There are set of timer functions to accomplish the above tasks . id.UID=dba") // retrieve info from Department table hstmnt = DB_ExecuteSql (hdbc. sDeptName. 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 . "SELECT * FROM department") // process the information that came back print ("Here's the info in the Department table:") print () while (DB_FetchNext (hstmnt.

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

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

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

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

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

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

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

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)//-->