What is Test Suite?

Test suites are normally used to group similar test cases together. The collection of individual test cases that will be run in a test sequence is called a test suite. The collection of individual test cases that will be run in a test sequence until some stopping criteria are satisfied is called a test suite. Test suite preparation involves the construction and allocation of individual test cases in some systematic way based on the specific testing techniques used. Another way to obtain a test suite is through reuse of test cases for earlier versions of the same product. This kind of testing is commonly referred to as regression testing. It ensures that common functionalities are still supported satisfactorily in addition to satisfactory performance of new functionalities. Special types of formal models are typically used to make the selection from existing test cases. Test suite management includes managing the collection of both the existing test cases and the newly constructed ones. At a minimum, some consistent database for the test suite needs to be kept and shared by people who are working on similar areas. Some personnel information can also be kept in the test suite, such as the testers who designed specific test cases, to better supported future use of this test suite.

An object as we know is a graphic user element in an application e.g. a button or a list or an edit box and the special characteristics of an object within the QuickTest are called object properties. QTP stores the recorded object properties in Object Repository. Object Repositories are of two types Local and shared . If objects are stored in a Local Object Repository then these are available to specific actions but not to all the actions. But if these objects are stored in one or more Shared Object Repositories then multiple actions or tests can use them. By default QTP makes and uses Local Object Repository. If we create a new blank test and do a recording on it, QTP automatically creates a Local Object Repository for that test or action and stores the information about any object it finds in that corresponding Object Repository. In QTP 9 we can associate multiple Shared Object Repositories with an action. If multiple Shared Object Repositories are associated with an action then also while recording QTP stores objects in corresponding Local Object Repository on the condition that those objects are not already stored in any corresponding associated Shared Object Repositories. This is the default that every time we create a new action QTP creates a new corresponding Local Object Repository. It is also true that Object Repositories are associated with actions and no matter how many times we learn or record on the same object in our application in different actions the object will be stored as separate test object in each of the Local Object Repository. Local Object Repository is automatically saved with the test when we save it. The extension of the Local

Object Repository is .mtr, but it is not accessible as a separate file as in case of the Shared Object Repository. We can also manipulate some aspects of Local Object Repository using Quick test Object Repository Automation Object Model. For example we can add, remove, rename test objects in Local Object Repository. [QuickTest Object Repository Automation documents the Object Repository automation object model that enables you to manipulate QuickTest object repositories and their contents from outside of QuickTest.] When we open a test that was created using a version of QTP earlier that version 9 we are asked whether we want to convert it or view it in read only format. In any case if the test previously used per-action Object Repository, the objects in each per action repository are moved to the Local Object Repository of each action in the test. If the test previously used a shared object repository, the same shared object repository is associated with each of the actions in the test, and the local object repository is empty. While learning or recording we can specify Shared Object Repository for the selected action. We can specify and associate one or more Shared Object Repositories with each action. We can also create new Shared Object Repository and associate it with our action. In case of Shared Object Repository, QTP uses existing information and does not add objects to the Object Repository if we record operations on an object that already exists either in Shared or Local Object Repository. As said earlier QTP does not add objects directly to the associated Shared Object Repository as we record, instead it adds new objects in Local Object Repository (if that object does not already exist in associated Shared Object Repository). We can surely export Local objects to Shared Object Repository. There are different ways in which we can move objects from Local Object Repository to Shared Object Repository: 1) Exporting the objects to the Shared Object Repository from the Local Object Repository: In Object Repository window choose the action whose local objects you want to move. Choose File-> Export Local Objects.Select the location in which you want to save the file. Click on save. 2) We can update the Shared Object Repository with the Local Object Repository: If we create a new test it will be created with Local Object Repository, we can associate any new or old Shared Object Repository with it, and so we can update that Shared Object Repository with Local Object Repository. In Object Repository Manager open the Shared Object Repository (clear open in read only check box). The test in this case should not be open. In Object Repository Manager go to Tools –> Update From Local Repository. Select the test who's Local Object Repository you want to use. Click update all. It will move all the objects to the Shared Object Repository.

3) We can also merge objects from two Object Repositories (called as primary and secondary in QTP 9) into a new single Object Repository (target Object Repository in QTP 9). The original source files are not changed. It also enables you to merge objects from Local Object Repository of one or more action(s) into a Shared Object Repository. It is recommended to use as a primary Object Repository the file in which you have invested alot of your effort, like which has more number of objects. If we do not specify a file extension for Shared Object Repository when creating a new Shared Object Repository QTP automatically appends a default extension name for Shared Object Repository as .tsr. This means that we can create Shared Object Repository with any extension other than .tsr, it should work fine (I have tried that and it works fine), I think it may create problems while merging two Object Repositories (I haven't tried that yet). We can compare two Object Repositories using the Object Repository Comparison Tool. The tool enables you to identify similarities, variations or changes between two Object Repositories. We can also copy objects to Local Object Repository from the Shared Object Repository. We can copy, paste and move objects in Local Object Repository and copy, paste and move objects within Shared Object Repository and between Shared Object Repositories.As said earlier we can also copy objects from shared Object Repository to Local Object Repository to modify them locally. We cannot remove an association between the action and its Local Object Repository. According to QTP user guide: You can associate as many object repositories as needed with an action, and the same object repository can be associated with different actions as needed. You can also set the default object repositories to be associated with all new actions in all tests. Whenever we make any changes to an Object Repository those changes are automatically updated in all the associated tests open on the same computer as soon as we make the change even if the Object Repository is not yet saved and if we close the same Object Repository without saving the changes the changes are rolled back in any open tests. For the test that was not open when we changed Object Repository, when we open the test on the same machine on which we modified the Object Repository the test is automatically updated with all the saved changes. To see saved changes in a test or repository open on a different computer, you must open the test or object repository file or lock it for editing on your computer to load the changes. Important points about Object Repositories It is a point to consider while planning and creating test that how you want to store objects; either you want to store them in Local Object Repository or Shared Object Repository. 1) For each action, we can also use a combination of objects from the Local and Shared Object Repositories, according to our needs. Local objects can also be transferred to a shared object repository, if necessary. This will cut maintenance and increase the reusability of the tests because it will enable us to maintain the objects in a single, shared location instead of multiple locations. 2) If there is a same name object in both the Local Object Repository and in a Shared Object

Repository associated with the same action, the action uses the local object definition i.e. the local object is given preference over the shared object. If an object with the same name is stored in more than one Shared Object Repository associated with the same action, the object definition is used from the first occurrence of the object, according to the order in which the Shared Object Repositories are associated with the action. 3) When we open an existing test, it always uses the object repositories that are specified in the Associated Repositories tab of the Action Properties dialog box or in the Associate Repositories dialog box. When we access Shared Object Repositories from tests they are read-only; we can edit them only using the Object Repository Manager. 4) As and when an application under test changes, such as when a "Log in" button is renamed "Sign Into," we can make one update to an XML-based Shared Object Repository (within the new Object Repository Manager), and the update will circulate (propagate) to all tests that reference this object. QuickTest Professional keeps object-level changes synchronized among users throughout test creation efforts. Object Repository dialog box Object Repository dialog box window shows a tree of all the objects (either Local or Shared) on its left hand side in the selected action. On selecting any object in the tree Object Repository window shows the information about the object like the name, repository in which it is stored etc. On the left hand side in a tree local objects are editable while the shared ones are grayed out (non-editable). To view the test object properties, to modify test object properties and to add objects to Local Object Repository we can use Object Repository window. We can also delete objects from Object Repository window; this is needed as when an object is removed form the test it is not automatically removed from the Local Object Repository. Object Repository in QTP is XML based means that if we change something related to the object in Shared Object Repository., the change will be propagated to all the tests that reference this object, in real time. Adding Objects to Repositories
[Please see QTP user guide for in-depth information on these below points.]

We can add objects to Shared Object Repository or Local Object Repository in a number of different waysWe can decide whether to add only a selected object, or to add all objects of a certain type, such as all button objects, or to add all objects of a specific class, such as all WebButton objects. We can modify objects stored in a Local Object Repository using the Object Repository Window and objects in a Shared Object Repository using the Object Repository Manager. It is possible to add objects to the object repository before they exist in an application. We can also add objects to the Local Object Repository while editing our test.

The Documentation column of the Keyword View also displays a description of each step in easy-to-understand sentences. or submitting a data form.We can add the object directly to a Shared Object Repository using the Object Repository Manager. We can also add objects to a Shared Object Repository while navigating through the application ("Adding Objects Using the Navigate and Learn Option"). 1) First step is Planning Before starting to build a test. We can add objects to the object repository using the Add Objects to Local or Add Objects option. We can also add an object to the Local Object Repository by choosing it from the application in the Select Object for Step dialog box (from a new step in the Keyword View or from the Step Generator). QTP (QuickTest Professional) lets you create tests and business components by recording operations as you perform them in your application. A step is something that causes or makes a change in your site or application. so that it is available in all actions that use this Shared Object Repository. If needed. We can add objects to the Local Object Repository of the current action by selecting the required object in the Active Screen.A compilation of steps organized into one or more actions. we can merge test objects from the Local Object Repository into a Shared Object Repository. QuickTest graphically displays each step we perform as a row in the Keyword View. Reusable action and External action). Decide how you want to organize your object repositories. determine the functionality you want to test. which we can use to verify that our application performs as expected. As we navigate through the application or site. such as clicking a link or image. you should plan it and prepare the required infrastructure. short tests that check specific functions of the application or complete site. For example. A test is composed of actions (3 kinds of actions are there in QTP Non-reusable action. 2) Second step in QTP is Creating Tests or Components We can create a test or component by a) Either recording a session on your application or Web site. Test . OR .

QuickTest substitutes the fixed values in your test or component with parameters Each run session that uses a different set of parameterized data is called an iteration. To check how your application performs the same operations with different data you can parameterize your test or component. We can use the Step Into. 4) Fourth step is Broaden the scope of your test or component by replacing fixed values with parameters. When we run the test or component. An output value is a value retrieved during the run session and entered into the Data Table or saved as a variable or a parameter. And Step Out commands to run a test or component step by step. Run test or component to check the site or application. Run the test or component to debug it. If we parameterized the test with Data Table parameters. This enables you to identify whether the Web site or application is functioning correctly. We can also set breakpoints to pause the test or component at pre-determined points. We can also use output values to extract data from our test or component. QuickTest connects to your Web site or application and performs each operation in a test or component. We can control the run session to identify and eliminate defects in the test or component. We can use many functional testing features of QuickTest to improve your test or component and/or add programming statements to achieve more complex testing goals. We can subsequently use this output value as input data in your test or component. 3) Third step is Inserting checkpoints into your test or component. 5) Fifth step is running the test After creating test or component. QuickTest repeats the test (or specific actions in your test) for each set of data values we defined.b) Build an object repository and use these objects to add steps manually in the Keyword View or Expert View. checking any text strings. objects. or tables you specified. When you parameterize your test or component. A checkpoint is a verification point that compares a recent value for a specified property with the expected value for that property. We can then modify your test or component with special testing options and/or with programming statements. . Step Over. we run it.

we can view the results. Netscape for Netscape objects). or we can report them manually from the Test Results window. We can instruct QuickTest to automatically report each failed step in the test or component. Test Object Class Properties Methods A test object is an object that QuickTest creates in the test to correspond to (represent) the actual object in the application. A test object class comprises of a list of properties that can individually (uniquely) identify objects of that class and a set of appropriate methods that QuickTest can record for it.We can view the value of variables in the test or component each time it stops at a breakpoint in the Debug Viewer. we can report the defects fond out to a database. QuickTest uses the stored information about the object during the run session to identify and check the object. A run-time object is the real (actual) object in the application or Web site on which methods are performed during the run session. We can view a summary of the results as well as a detailed report. After running the test or component. and that QuickTest executes when the test or component runs. 6) Sixth step is analyzing the results After we run test or component. The property set for each run-time object is created and maintained by the object architect (creator) (Microsoft for Internet Explorer objects. If Quality Center is installed. Similarly. Methods of Run-time object are the methods of the object in the . ➤ View the results in the Results window. ➤ Report defects identified during a run session. methods of test objects are methods that QuickTest recognizes and records when they are executed (performed) on an object while we are recording. Properties and methods of objects: The property set for each test object is created and maintained by QuickTest. we can view the results of the run in the Test Results window. SettingsPrivacyAddThis Test object Model is a set of object types or Classes that QuickTest uses to represents the objects in our application.

application as defined by the object architect (creator). We can access and execute run-time object methods using the Object property. Some important points to remember about methods and properties :  Each test object method we execute (perform) while recording is recorded as a separate step in the test. When we run the test, QuickTest executes (performs) the recorded test object method on the run-time object.  Properties of test object are captured from object while recording. QuickTest uses the values of these properties to identify runtime objects in the application during a run session.  Property values of objects in the application may change .To make the test object property values match the property values of the run-time object, we can modify test object properties manually while designing the test or component or using SetTOProperty statements during a run session. We can also use regular expressions to identify property values.  We can view or modify the test object property values that are stored with the test or component in the Object Properties or Object Repository dialog box.  We can view the syntax of the test object methods as well as the run-time methods of any object on our desktop using the Methods tab of the Object Spy.  We can retrieve or modify property values of the TEST OBJECT during the run session by adding GetTOProperty and SetTOProperty statements in the Keyword View or Expert View. We can retrieve property values of the RUNTIME OBJECT during the run session by adding GetROProperty statements. If the available test object methods or properties for an object are not sufficient or they do not provide the functionality we need, we can access the internal methods and properties of any runtime object using the Object property. We can also use the attribute object property to identify Web objects in the application according to user-defined properties.
qtp.blogspot.com
Bottom of Form

Checkpoints in QTP (QuickTest Professional)
A checkpoint enables you to identify whether the Web site or application under test is functioning correctly or not by comparing a current value for a particular property with the expected value for that property. After we add a checkpoint, QuickTest adds a checkpoint to the current row in the Keyword View and adds a Check CheckPoint statement in the Expert View. By default, the checkpoint name receives the name of the test object on which the checkpoint is being performed. We can change the name of the checkpoint if needed. Types of Checkpoints: 1. Standard checkpoint 2. Image checkpoints

3. Bitmap Checkpoint 4. Table checkpoints 5. Accessibility Checkpoint 6. Text Checkpoint 7. Page Checkpoint 8. Database Checkpoint 9. XML checkpoints Standard checkpoints allow checking the object property values in the Web site or application under test. Standard checkpoints evaluate (compare) the expected values of object properties captured during recording to the object's current values during a run session. For example we can check that a radio button is activated after it is selected. Standard checkpoints are supported for all add-in environments. Standard checkpoints can be used to perform checks on Images, Tables, Web page properties, and Other objects within your application or Web site. Standard checkpoints can be created for all supported testing environments (as long as the appropriate add-in(s) are loaded). Image checkpoints allow you to check the properties of an image in the application or Web page. For example, you can check that a selected image's source file is correct or not. An image checkpoint can also be created by inserting a standard checkpoint on an image object. Image checkpoints are supported for the Web add-in environment With Bitmap Checkpoint we can check an area of a Web page or application as a bitmap. While creating a test, we have to specify the area to check by selecting an object. An entire object or any area within an object can be checked. Bitmap checkpoints are supported for all add-in environments By adding table checkpoints to the test, we can check the content of tables displayed in the application. For example, we can check that a specified value is displayed in a certain cell. Certain environments also support checking the properties of the table object. For example, a check that a table has the expected number of rows and columns. A table checkpoint can also be created by inserting a standard checkpoint on a table object. Accessibility Checkpoint recognizes areas of your Web site that may not conform to the World Wide Web Consortium (W3C) Web Content Accessibility Guidelines. For example, check if the

images on a Web page include ALT properties, required by the W3C Web Content Accessibility Guidelines. Accessibility checkpoints are supported for the Web add-in environment QuickTest can check that a text string is displayed in the appropriate place in an application or on a Web page with Text Checkpoint. Text checkpoints are supported for the Web add-in environment, plus some Web-based add-in environments Page Checkpoint checks the features of a Web page. For example, you can check how long a Web page takes to load or whether a Web page contains broken links. A page checkpoint can also be created by inserting a standard checkpoint on page object. Page checkpoints are supported for the Web add-in environment The contents of a database accessed by your application can be checked by Database Checkpoint. Database checkpoints are supported for all add-in environments By adding XML checkpoints to your test, you can check the contents of individual XML data files or documents that are part of your Web application. The XML Checkpoint option is supported for all add-in environments.
Top of Form

qtp.blogspot.com
Bottom of Form

QTP Tutorials 4 - Standard Checkpoint
Checkpoints cannot be added manually, they are inserted using QTP's interface. Results of the checkpoint can be viewed in the Test Results Window. Checkpoint information is stored in the Local Object Repository. It is in the Resource.mtr file which is in the action folder (if you created checkpoint in action1 then it will be action 1 folder under the folder in which you are saving the test/script, if you created checkpoint in action 2 then it will be action 2 folder and so on) . In the expert view, on any blank line type Checkpoint and put "(". As soon as you put the starting bracket it will show all the checkpoints you have used in the test. Now we will start with checkpoints. I will try to show easy to understand example of each and every checkpoint. Lets start with simple example of standard checkpoint which checks a variety of objects such as buttons, radio buttons, combo boxes etc. Standard checkpoints are supported for all add-in environments 1. Open a blank test.
2. Make sure that Flight application is open.

(Now only QTP with blank test and Flight application should be open). 3. Click on Record. When we click on Record, "Record and Run Settings" window opens up. Go to "Windows Applications" tab and choose first option "Record and run test on any open Windows based application." and click ok. 4. Go to Insert (menu)->Checkpoint->Standard Checkpoint (or press F12).The mouse pointer will become hand and QTP will be minimized.

5. Click on the "Flights..." button which is on the Right Hand Side of the "Fly To" combo box in the Flight application. 6. It will open "Object Selection - Checkpoint Properties" window (with WinButton:FLIGHT highlighted). Click ok. 7. It will open checkpoint properties window. (only one property will be checked in it i.e. 'enabled' with a value of False.) 8. Click ok. Click on Stop in order to stop the Recording. 9. Save the test. This is a small test in which we have used standard checkpoint and captured the disabled button on the Flight application. Now we can run the test in two ways to see how it fails and passes the results of the checkpoint. To see a pass test result: Make sure that this test and Flight application is open. Click on run. It will Run the test and show you the result as pass. To see a Fail test result: Make sure that this test and Flight application is open. In the Flight application enter the Date of Flight, Fly From and Fly To fields and nothing else. (The reason for doing this is that it will enable the 'Flight...' button) Click on run in order to run the test. It will Run the test and show you the result as Fail. This is because QTP was looking for a disabled 'Flight...' button for which it recorded the information at the record time, but now since the button was enabled at run time, so it failed.
qtp.blogspot.com

This will help you in understanding the standard checkpoint in QTP more deeply.
Bottom of Form

Simple example of QTP Existing Checkpoint
QuickTest (QTP) now makes it possible for you to reuse an existing checkpoint in your test. For example you can use bitmap checkpoint to verify your company's logo on each page of your application or website. Let’s see a very simple example to accomplish this.

Click OK. 5. Open a new test and Save it with the Name testtwo.1.Checkpoint Properties window opens. 6. Click on the Flights. Checkpoint Properties window opens.g.. qtp. Close that Object Repository. Go to Resources->Object Repository (OR associated with this particular action will open) 9. Associate Shared Object Repository Rep1 with it also.blogspot. Go to Insert->Checkpoint->Standard Checkpoint. 12. 8. Enter any filename e. Go to Associated Repositories tab. button which is on the right hand side of Fly To dropdown. Click on Record in order to start recording. Click on the ‘+’ sign to locate the shared Object Repository and associate it. (If it asks for Automatic Relative Path Conversion Click Yes) Click Ok to close that Action Properties window. (If not already associated) In the keyword view. Click OK. 13. Click Stop in order to stop recording. Save the test as testone. right click on action 1 and choose Action Properties. 14. (Standard checkpoint will be added) 7.) 2. Go to File-> Export and Replace Local Objects (Export Object Repository dialog opens) 10. Open a new test (Make sure that Flight Reservation Window in open. Now (in testtwo) you can see when you go to Insert-> Checkpoint. Object Selection . (QTP will be minimized and mouse pointer will take the shape of a hand.com . rep1 and click Save (All the objects in Local Object Repository will be grayed) 11. 3..) 4. Existing Checkpoint will be enabled to let you insert any checkpoints already saved to the shared Object Repository (Rep1 in our case).

The mouse pointer will become hand and QTP will be minimized. In the Expert view it will add just one line: Browser("Google"). 6.google.google. in the results window. Go to "Web" tab and choose first option "Record and run test on any open browser. 9.Checkpoint Properties" window." and click ok. When we click on Record. 2. Make sure thathttp://www.google. I ran this test by opening www. Click ok. 1. 10.Page Checkpoint Page checkpoint:It is for web applications only. 5.co. 4.Page("Google"). Let all the options be default. on left hand side. A 'Page Checkpoint Properties' window opens up. Go to Insert (menu)->Checkpoint->Standard Checkpoint (or press F12). "Record and Run Settings" window opens up.in should be open.google. Click anywhere on the white space on the Google. It recorded the following properties: Property Name load time number of images number of links Property Value "0" "2" "20" Here it shows the load time as 0 because I did not open Google at the time of running the test.co. it was already open. Open a blank test. 8. Click on Record.co.(Now only QTP with blank test and www.) 3. broken links etc.in/ is open. Click on 'Page : Google' option which has a page icon on left of it with right corner of the page slightly folded. it will show (when every option is expanded): Test Checkpoint-page Summary (where Checkpoint-page is the name with which I saved the test Run-Time Data Table Checkpoint-page Iteration 1 (Row 1) Action1 Summary Google (This will be the browser) Google (This will be the Page) Checkpoint "Google" If you run this test on www.co. Click on Stop in order to stop the Recording. When you run it. 7.Check CheckPoint("Google") We will explore this line later on.Common things to check with this are load time.com it may fail.Bottom of Form QTP Tutorials 5 . It will Open "Object Selection . .in page. Click ok.in in offline mode (not on internet).

Click on Record." and click on ok. 3. "Record and Run Settings" window opens up. 6. Click Next. If successful it will show 'Testing Connection' window with 'Connection Successful' written on it. 5.qtp. 2. Enter 'description' (I entered "SQL") 12. 15. 8. Enter 'Data Source name' ( I entered "oracle") 11. Click Finish. A Database Query Wizard opens. Enter your password for Oracle. Now we will record a test. 13. Click on New Button. It will show all the data source drives it could find. 9. 14. 2. This completes our task of Connecting QTP with Oracle. 1. Click Next. When we click on Record. 7. Click on 'Machine Data Source' Tab 4.blogspot. 'Create New Data Source' window opens. For this go to Insert -> Checkpoint -> Database Checkpoint. Click 'Test Connection' Button.Database Checkpoint Now we will try out Database checkpoint: using Oracle 9i First of all you have to connect oracle 9i to QTP 9. Select Oracle (on my machine it was 'Oracle in OraHome9'). my oracle database name) from combo box. Open a blank test. Select ' Specify SQL statement manually' from the Query definition area. Click Next. Here click on 'Create' button which is on the right of "Connection String:" It will open 'Select Data Source' window. Select 'User Data Source' from Select a type of data source.com Bottom of Form QTP Tutorials 6 .It will ask for a Password. Enter userid (I used SCOTT). Select 'TNS Service Name' ( I selected 'DB02'. Go to "Windows Applications" tab and choose first option "Record and run test on any open Windows based application.(before doing any recording) 1. 3. 10. It will open 'Oracle ODBC Driver Configuration' window. Go to Insert (menu)->Checkpoint->Database Checkpoint .

A 'Database Query Wizard' opens. Click Next.CSR=F.UID=SCOTT.) Just try to think how QTP is comparing the expected results with the actual one. Click ok 9. Lets run it. Click Stop in order to stop the Recording.) When it is passed it will show following in the Result window: Test Checkpoint-database Summary (where Checkpoint-database is the name with which I saved the test) Run-Time Data Table Checkpoint-database Iteration 1 (Row 1) Action1 Summary DbTable Checkpoint "DbTable" ( when you click on this.APA=T.GDE=F. 6. in details it will show checked 112 cells (in your case number of cells may differ).DBQ=DB02.com Bottom of Form .FRC=10. ( we don't need to open any other window or application to run this as our Oracle is running at the back end as a service .RST=T. Click on Run.Check CheckPoint "DbTable")" This is the simplest database checkpoint example.FRL=F.FEN=T. 5. 10.TLO=0.4. It will come to Database Query Wizard window with 'Connection String' field filled with: "DSN=oracle. MDI=F.MTS=F. Click Finish. Click Ok. Select Oracle from data source name. Select ' Specify SQL statement manually' from the Query definition area." In the SQL Statement area type "select * from emp. Enter password. Click Ok.BAM=IfAllSuccessful.PWD=TIGER. Go to 'Machine Data Source' Tab 7.blogspot.FWC=F.PFC=10. it just adds one line "DbTable("DbTable"). In the Expert View.DBA =W.EXC=F. with the count of cells. LOB=T.QTO=T. 12. It will open 'Oracle ODBC Driver Connect' 8. It means if you go to the oracle and add or delete any row and run this test again it will fail. 11. qtp.nothing special. It will open 'Database Checkpoint Properties' window with the result of the query.". Click Create.FDL=10.default way in which it was installed.

In the result window on the left hand side when you click on Checkpoint "Fly To:"..e. instead of clicking on the "Fly To" combo box. 8. in the "Flight Schedule" area. Click ok. just fail the test. This time it will have "Flight schedule" area instead of just the "Fly To" combo box. Go to Insert (menu)->Checkpoint->Bitmap Checkpoint 4. Go to "Windows Applications" tab and choose first option "Record and run test on any open windows based application. Click on the "Fly To" combo box. If you have recorded in the style A then just select any value in the "Fly To" combo box and then run the test.Bitmap Checkpoint Now we will look at the bitmap checkpoint which is different from the image checkpoint. I will have "WinComboBox:Fly To" highlighted. (note: it will show that only in case of Failed result) . To see how it stores the results. STYLE B Above. 3. "Object Selection. 2. Click stop to stop recording the test. it will show you the expected bitmap and actual bitmap on the right hand side. STYLE A 1. Click stop to stop recording the test. "Record and Run Settings" window opens up. Click ok 6. so that we will have no wait time while running the test. Click ok. i. so that we will have no wait time while running the test. Change the "Checkpoint timeout" at the bottom of the window to 0 seconds. Now click on the "Select Area. Now you can run the test it will pass.Bitmap Checkpoint Properties" window opens up. Click ok It will open "Bitmap Checkpoint Properties" winodow.. Open a blank test.QTP Tutorials 7 . after 3rd point. Just select "Fly From" combo box by dragging.Bitmap Checkpoint Properties" window opens up. When we click on Record. It will have "WinObject:Flight Schedule" highlighted. Change the "Checkpoint timeout" at the bottom of the window to 0 seconds. 5. click somewhere in the empty space above the "Fly From" Combo box but below the line. Mouse pointer will change so that you can select any area by dragging. Click on Record." button." and click Ok. 9. Make sure that QTP and the Flight application are open. 7. "Object Selection. It will open "Bitmap Checkpoint Properties" window.

Go to Insert (menu)->Checkpoint->Standard Checkpoint(or press F12). html tag etc and only check last property which is src. Click OK." and click on Ok.Sunset. Rest every thing will be default.Blue Hills. It is just checking that the image in the explorer is in the same location in which it was when the test was recorded and its name is Sunset. On your system under My Documents.blogspot. It will Open 'Image Checkpoint Properties' Window.Image Checkpoint We will look at the Image checkpoint. Click on the image which is opened in the explorer. In this window just uncheck all the property values like href.qtp. Winter. Go to "Web" tab and choose first option "Record and run test on any open browser. Go to My Documents->My Pictures-> Sample Pictures and right click on image named 'Sunset' and open it with internet explorer. If you change the name of some other picture in that folder to Sunset and run the test with that it will also pass.com Bottom of Form .com Bottom of Form QTP Tutorials 8 . Click on Record. It will open 'Object Selection Checkpoint Properties' window with Image: Sunset highlighted. Open a blank test. Click stop to stop recording the test. Water lilies) We will run this test with one of the image there. "Record and Run Settings" window opens up. Now only a new blank test and internet explorer with this image should be open.Sample Pictures( containing 4 pictures . This test is not intelligent enough. Click Ok. In this way you can test for some or all the properties of the image which it showed in the 'Image Checkpoint Properties' Window. there will be a folder named My Pictures.Page("file:///C:/Documents%20and%20S"). When we click on Record.blogspot. under this you will will find a folder.The mouse pointer will become hand and QTP will be minimized.Check CheckPoint("Sunset") If you run it with that image open in internet explorer it will pass. In the expert view it will just add one line Browser("file:///C:/Documents%20and %20S").Image("Sunset"). Sunset. QTP Tutorials & Interview Questions qtp.

Checkpoint properties" window opens. but for now just click ok. Click on Record. qtp.php" in offline mode.The mouse pointer will become hand and QTP will be minimized..co. Select "WebTable: Software Testing Life Cycle" which has a table icon on its left.com Bottom of Form QTP Tutorials 10 . "Record and Run Settings" window opens up. It will show the text to be checked in "Checkpoint Summary" area in red color and also show in blue color the text which is displayed before and after the selected text. "Object Selection . Try to understand those. . Go to Insert (menu)->Checkpoint->Standard Checkpoint (or press F12). Click on stop in order to stop recording. At the bottom of the "Text Checkpoint Properties" window change 'Checkpoint timeout' to 0 seconds. "Text Checkpoint Properties" window opens up. 3. Go to "Web" tab and choose first option "Record and run test on any open browser. Click on Record. Click ok. Click on Configure -here you can change your selected text.editorial. Run the test and when it is passed just go to the results window and on the left hand side just expand every option and click on last option Checkpoint "Cannot find server". Go to Insert (menu)->Checkpoint->Text Checkpoint. 5.in/software/software-testinglife-cycle. Click somewhere inside the table. change before and after text and so on." and click on ok. 4. Open a blank test and a web page in offline mode like this below: 2. where "Software Testing Life Cycle" is the name of the table.Click on the first paragraph (which starts with-The page you are looking.Table Checkpoint In this tutorial we will look at a table Checkpoint just to get familiar with it.) of that web page.Text Checkpoint Now we will look at the Text Checkpoint: 1. 6. "Record and Run Settings" window opens up. The mouse pointer will become hand and QTP will be minimized. On the right hand side it will show you the details. When we click on Record. When we click on Record. This website has a table at the bottom of the page.QTP Tutorials 9 . Again Click ok to come out of "Text Checkpoint Properties" window. Go to "Web" tab and choose first option "Record and run test on any open browser.blogspot. Open a blank test and also open a website "http://www." and click on ok.

In the expert view of the test you will see only one line i. Open that test that contains the standard Checkpoint. Window("Flight Reservation"). So the final version looks like this: Dim return return = Window("Flight Reservation"). It will show all the rows and columns of the selected table.Check CheckPoint("FLIGHT") Now we will make some changes in this one line so that it can return some value. NOTE: Checkpoint always returns a value. mainly the checkpoint results to see how QTP verifies the result.WinButton("FLIGHT"). according to specified criteria. qtp.WinButton("FLIGHT"). Text Area Checkpoint Text Area Checkpoint checks that a text string is displayed within a defined area in a Windows-based application. Lets now capture it.Check CheckPoint("FLIGHT") msgbox (return) One thing more we need to do here is that we have to enclose Checkpoint ("FLIGHT") in brackets.blogspot.'Table Checkpoint properties' window opens. Click stop in order to stop recording.WinButton("FLIGHT"). Run the test and analyze the results in the result window. Declare a variable and catch the return value in that variable: Dim return return = Window("Flight Reservation").Check (CheckPoint("FLIGHT")) msgbox (return) Now run the test and see the msgbox appearing with the return value.com Bottom of Form QTP Tutorials 11 .com Bottom of Form Difference Between Text & Text Area Checkpoint Text Checkpoint Text Checkpoint checks that a text string is displayed in the appropriate place on a Web page or application. We will manipulate test results in later tutorials.blogspot.e. qtp. This time we will not do any extra setting.Checkpoint Return Value We will use the Standard Checkpoint which we did in tutorial 4. . it depends on us whether we capture it or not. Just change the Checkpoint timeout at the bottom of this window to 0 seconds and click ok .

. and ActiveX.You can add a text checkpoint while You can add a text area checkpoint only while recording or editing steps in a Windows. Click Cancel. Visual Basic. Text Checkpoint Properties window opens. such or Web-based application. A small & simple example to get a feel of both Text and Text Area Checkpoint: Make sure that the Flight Reservation window is open as shown below. With the pointing hand click on $110. Click OK. Object Selection window opens. (See Screenshot for Text Checkpoint Properties window below). as Standard Windows.recording a test on Windows-based applications. Go to Insert (Menu) ->Checkpoint->Text Area Checkpoint QTP will be minimized and the mouse pointer will change into crosshairs. Open a New test in QTP and click Record. Go to Insert (Menu) ->Checkpoint->Text Checkpoint QTP will be minimized and the mouse pointer will change into pointing hand.00 in the above Flights Table. Java.

Click Cancel. (See Screenshot for Text Area Checkpoint Properties window below).With the crosshairs select $110. the Checkpoint Summary area displays [complex value] instead of the selected text string. Click OK. Object Selection Window for "Text Area checkpoint" will also be similar as the below one for "Text Checkpoint": Text Checkpoint Properties window [In Windows-based environments. if there is more than one line of text selected. You can then click Configure to view and manipulate the actual selected text for the checkpoint.00 in the above Flights Table. Text Area Checkpoint Properties window opens.] Text Area Checkpoint Properties window: . Object Selection window opens.

use Low Level Recording. There are other recording modes also like Analog Recording or Low Level Recording.blogspot. Low Level Recording : At any time. as it recognizes the objects in the application regardless of their location on the screen. if an environment or on an object not recognized by QuickTest. Analog Recording steps are not editable from within QuickTest. Normal mode is the default and takes full advantage of the QuickTest test object model. QuickTest records all parent level objects as Window test objects and all other objects as WinObject test objects. analyze yourself: Which one is better (if any) and Which one is to be used in which situation? qtp. Analog Recording : Exact mouse and keyboard operations are recorded in relation to either the screen or the application window. Each step recorded in Low Level Recording mode is shown in the Keyword View and Expert View.Now considering both Text and Text Area checkpoints.com Bottom of Form QTP (QuickTest Professional) Recording The default mode of recording is the Normal recording mode. In this QTP also records and tracks every movement of the mouse for example. . It records at object level and records all run-time objects as Window or WinObject test objects. recording a signature produced by dragging the mouse.

To use a value within a specific action.com Bottom of Form Parameterizing Tests in QTP (QuickTest Professional) By replacing fixed values with parameters QuickTest enables you to enlarge the scope of a basic test. and then parameterize the required step using this action input parameter value (that was passed through . in normal mode QuickTest performs the step on an object even if it has moved to a new location on the screen. Analog Recording and Low Level Recording require more disk space than normal recording mode. It is known as parameterization. Action parameters enable us to pass values from other actions in your test. For example. we can switch to either Analog Recording or Low Level Recording in the middle of a recording session for specific steps and then return to normal recording mode. Values in steps and checkpoints and also the values of action parameters can be parameterize. There are four types of parameters: Test/action parameters: Test parameters make possible for us to use values passed from the test. QuickTest adds to your test a RunAnalog statement that calls the recorded analog file. Parameters let us check how the application performs the same operations with multiple sets of data. In Analog Recording mode. Exact location of the operation on your application screen is necessary. We can then use that parameter value to parameterize a step in the test.All the three modes of recording can be used in a single test e.blogspot. Use Low Level Recording when : Environments or objects not supported by QuickTest. the value must be passed down through the action hierarchy of the test to the required action. suppose that we want to parameterize a step in Action3 using a value that is passed into the test from the external application that runs (calls) the test. switch to Low Level Recording qtp.g. We can pass the value from the test level to Action1 (atop-level action) to Action3 (a nested action of Action1). Recording in Analog mode can be relative to the screen or relative to a specific window (see user guide for detail) In Analog Recording a separate file is saved and stored with the action. Use Analog Recording when : The actual movement of the mouse is what you want to record. If the location of the object is important to your test. A parameter is a variable that is assigned a value from an external data source or generator. greatly increases the power and flexibility of a test.

After recording all the operations. Data Table parameters allow us to create a data-driven test (or action) that runs several times using the data that we supply. We can parameterize a call to Action4 based on an output value retrieved from Action2 or Action3.com Bottom of Form QTP (QuickTest Professional) keyword view In QTP (QuickTest Professional) we first of all record a test. We can then use these parameters in the action step. For example. When the value of an object property for a local object is parameterized. and Action4 are sibling actions at the same hierarchical level. The highest level of the tree is actions. Parameterizing the value of a checkpoint property enables us to check how an application or Web site performs the same operation based on different data qtp. for example. or iteration. and that these are all nested actions of Action1. The values of the operation (method or function arguments) defined for the step can also be parameterized. or values that QuickTest generates for us based on conditions and options we choose. function call. QuickTest displays them as steps in the Keyword View. . all occurrences of the specified object within the action are parameterized.from the external application). Operation The operation (methods or functions) to be performed on the item selected in the Item column. In the keyword view there are 4 visible columns – (For other valuable information on below points please see QTP user guide pg 92 and pg 114) Item The item on which we want to perform the step and it can be a test object. Therefore. In each repetition. and all steps are contained within the relevant branch of the tree. These may be values that we supply. Random number parameters Enable us to insert random numbers as values in your test. suppose that Action2. Environment variable parameters allow us to use variable values from other sources during the run session. and generates them in a script (in an Expert View). Values in steps and checkpoints can be parameterized while recording or editing the test. Alternatively. we are amending the test object description in the local object repository. QuickTest uses a different value from the Data Table. then run a test and then analyze the results.blogspot. we can pass an output action parameter value from an action step to a later sibling action at the same hierarchical level. or statement. but before running the test we can also enhance it with checkpoints and parameters. utility object. Click or Select. Action3. First of all let's talk a little about keyword view in QTP and then we will talk about recording in QTP and then we will move on to other things. The values of object properties can be parameterized for a selected step. This column shows a hierarchical icon-based tree.

Comment Any textual information you want to add regarding the step. By breaking up the tests into calls to multiple actions. This column is not visible by default. If there is a process that needs to be included in several tests. Reusable action Reusable actions are like functions in any programming language. for example.com Bottom of Form Actions in QTP 9 (QuickTest Professional) Actions break up the test into logical sections/units such as specific activities that we perform in our application. modify. for example. your test might be structured as shown—one test calling three separate actions: Test 1 Call to action 1 Call to action 2 Call to action 3 Actions stored with Test 1 Action 1(Logging In) Action 2(Checking Inbox Mails) Action 3(Logging Out) ---> ---> ---> Actions make it possible to parameterize and iterate over specific elements of a test. Store in cCols would store the return value of the current step in a variable called cCols so you can use the value later in the test. This column is also not visible by default. Assignment The assignment of a value to or from a variable for example. QuickTest creates a corresponding action sheet in the Data Table so that we can enter Data Table parameters that are specific to that action only. When we create a new test. we can record. An action is stored with the test in which you created it. They also make it easier to re-record steps in one action when part of your application changes. Documentation It is a Read-only auto-documentation of what the step does in an easy-tounderstand sentence. and enhance the steps .Value The argument values for the selected operation. the mouse button to use when clicking the image. it contains a call to one action. we can design more modular and well organized and professional tests. Click the "findFlights" image. check inbox. and then log out of the system (email). containing all of the steps recorded in that action. If you create a test in which you log into the system (email). An action has its own test script. Three types of actions are: Non-reusable action This non reusable action can be called only once and that too in the test with which it is stored.blogspot. For every action called in the test. and all objects in its local object repository. qtp.

Wait and Synchronization Synchronization makes available specified amount of time for an object to process prior to moving on to the next step. When a call to an external action is inserted. It can be called several times by the test with which it is stored (the local test). but we can choose to use a local. Then we can call the action from other tests.g. Deleting a reusable action that is called by other tests will cause those tests to fail. new actions are non-reusable.of the process and save them in a reusable action. but in case of wait. If you expect other users to open your tests and all actions in your tests are stored in the same drive. . modifying. For a button to become enabled or disabled. External actions are read-only in the calling test. Synchronization is possible in many ways: 1) We can insert a synchronization point for example for a progress bar to reach 100%. Each action created in a test can be marked as reusable or non-reusable. Wait is like forcing the QTP to wait for a specified amount of time while synchronization is not a 'forced' wait e.com Bottom of Form QTP Sync. and can view the detailed results for each action individually. as well as by other tests. For client-server communications to finish. editable copy of the Data Table information for the external action. External action is a reusable action stored with another test. Examples where synchronization can be used: For a web page to load. the action is inserted in readonly format We can create an additional call to any reusable or external action in the test by pressing CTRL while we drag and drop the action to another location at a parallel (sibling) level within the test. and enhancing the same steps each time. When we run a test with multiple actions. you should use relative paths for your reusable actions so that other users will be able to open your tests even if they have mapped their network drives differently. the test results are divided by actions within each test iteration so that we can see the outcome of each action. qtp. By default. Synchronization is there to take care of the timing problems between QTP and the AUT.blogspot. whenever a specific page loads QTP moves forward in case of synchronization. rather than recording. if the wait is for 10 seconds and a webpage loads in 3 seconds then it still waits for 7 seconds. QTP will generate a WaitProperty statement in the Expert View in case of synchronization.

and double quotation marks e. 'Object Selection . qtp. we can increase the default timeout settings for a test to instruct QuickTest to allow more time for objects to appear. Click on that 'Insert Done. 3) We can also modify the default amount of time that QTP waits for a Web page to load. button which is on the R.) Click Ok. 'Add Synchronization Point' window will open.." (Don't forget to put those 3 dots. (Object Synchronization Timeout. "Record and Run Settings" window opens up." and click on ok.' selected.Synchronization Point' window will open with 'ActiveX: Threed Panel Control. Go to Insert (menu)-> Synchronisation Point. In Fly From choose Denver.' text.. In Flight application go to File (menu)-> New Order. File(menu)-> Settings-> Run tab) Synchronization is enabled only during recording.H. Let the first option remains selected in that and just click on ok. Click Ok. Click on Insert Order and let it complete uptill 100% untill you see the 'Insert Done.. When we click on Record. Click on Flights. In Fly To Choose Frankfurt... Enter your name in the Name field. Click Stop in order to stop the recording.g. Enter the Date of flight as tommorrows date. Go to "Windows Applications" tab and choose first option "Record and run test on any open windows based application. File(menu)-> Settings-> Web tab) 4) When working with tests. QTP will be minimized and cursor will take the shape of a hand. (Browser Navigation Timeout..S of the Fly To combo box.2) We can use Exist or Wait statements.com Bottom of Form Example of Synchronization Make sure that only QTP and Sample Flight application are open.. It will automatically fill some of the fields. Flights Table window open up.' text in the Flight application. Exist statements always return a Boolean (0 or 1) value. Choose Property name as 'text' and Property value as "Insert Done.blogspot. " in the Property value text box. . Click on Record..

WaitProperty Waits until the particular object property attain the specified value or exceeds the specified timeout before continuing to the next step.".This whole process will add WaitProperty.WinComboBox("Fly From:").Set "axc" Window("Flight Reservation").. "Insert Done.WinButton("Button").ActiveX("Threed Panel Control").Click Window("Flight Reservation")."sync on Insert Done.Select "Denver" Window("Flight Reservation"). The code in the Expert view looks like this: Window("Flight Reservation"). Reporter is an Object used for sending info to test results and it uses ReportEvent method to accomplish this.Type "092407" Window("Flight Reservation").Click I have modified the above script a little bit to capture the WaitProperty value.WinComboBox("Fly To:"). 10000) If rc=true Then reporter.WinComboBox("Fly To:").WinButton("Button").ActiveX("MaskEdBox").Click 1.WinButton("Insert Order").WinEdit("Name:").ActiveX("Threed Panel Control").Dialog("Flights Table").WinButton("OK").Dialog("Flights Table").Select "Frankfurt" Window("Flight Reservation").WaitProperty ("text".WinButton("FLIGHT"). For more info on these plase see QTP help.Click Window("Flight Reservation").Click Window("Flight Reservation"). "Insert Done.Click Window("Flight Reservation").ActiveX("MaskEdBox").Set "axc" Window("Flight Reservation").ReportEvent micPass.WinButton("OK").. 10000 Window("Flight Reservation").WinComboBox("Fly From:").Select "Frankfurt" Window("Flight Reservation").".WinEdit("Name:").WaitProperty "text".ActiveX("MaskEdBox").. ReportEvent method sends the results to the result window. .WinButton("Insert Order")..Select "Denver" Window("Flight Reservation").ActiveX("MaskEdBox"). Window("Flight Reservation").9 Window("Flight Reservation"). "Property of text is true" End If msgbox rc Window("Flight Reservation").com Bottom of Form Example of WAIT Make sure that only QTP should be open.blogspot..9 Window("Flight Reservation").Click qtp.".Click 1.Click rc=Window("Flight Reservation")..Type "092407" Window("Flight Reservation").Click Window("Flight Reservation").WinButton("FLIGHT").

Select "File.google.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a. .com Bottom of Form Example of Sync Make sure that your internet is On and QTP is open. so that when you open internet explorer. Go toFile(Menu)->Exit.SetSecure "46ed14b628c7ae93e3a3ab35576f08fc424a6fb9" 6) Dialog("Login"). when you see 'Done' on the status bar at the bottom) . It will record the code as below but one thing which I have added extra is Wait(5) in step 4 (just go to the expert view and add this line before the line which includes encrypted password). When www.Set "sachin" 3) Dialog("Login"). When we click on Record. (use tab to move to password textbox.' Click Ok." and click on ok. Go to "Windows Applications" tab and choose first option "Record and run test on any open windows based application.blogger. When Flight Reservation window is open."C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\".exe". "Record and Run Settings" window opens up."". Click on Record.Click 7) Window("Flight Reservation")."open" 2) Dialog("Login"). click on Back toolbar button (below File menu) to go back to google.WinButton("OK"). When we click on Record. Go to "Web" tab and choose first option "Record and run test on any open browser.WinMenu("Menu").com.blogspot.WinEdit("Agent Name:"). Open internet explorer (make sure your default page is www.com is open (i. Enter Username as your first name (make sure to enter 4 or more characters). It will record the following code with sync automatically recorded by QTP (see 4th step)." and click on ok.) Enter password as 'mercury. 1)SystemUtil.Click on Record.Type micTab 4) wait(5) 5)Dialog("Login"). "Record and Run Settings" window opens up.com again. go to File(Menu)->Exit.) Type Blogger in the search text box and click on "I'm Feeling Lucky" button instead of Search button. it by default opens google.. Go to Start->AllPrograms->QuickTest Professional->Sample Applications->Flight.WinEdit("Agent Name:").e.com as homepage.WinEdit("Password:").Exit" qtp.

"". It will fail because sync method waits for the browser to complete the current navigation. but here we have set the browser navigation timeout to 2 seconds. but it finds it disabled as it gets enabled only when www.Page("Google"). which is too short for a browser to complete the navigation i. Environment Variables in QTP Random Variables in QTP Test parameters Action Parameter Global and Action data sheet Parameters QTP Output Values Parameterize a checkpoint . Keep 'Browser navigation Timeout' to 10 seconds in File(Menu)->Settings and then it should pass because in 10 seconds it surely makes the back button enabled after the 3rd step of clicking "I'm Feeling Lucky".WinMenu("ContextMenu").WebButton("I'm Feeling Lucky").Page("Google").e. to open www.Page("Blogger: Create your Blog").Sync 5) Browser("Google"). so that you can go ahead and do wonders with parameters in QTP on your own."C:\Documents and Settings\Sachin". it works fine.Press "&File" 7) Browser("Google").Select "Close" Try to run this code. Web tab and change the 'Browser navigation Timeout' to 2 seconds for example and then run the above code again.blogspot. qtp. my internet connection is average).Back 6) Browser("Google"). This is just to give you a startup on parameters in QTP.blogger.Set "blogger" 3) Browser("Google").WebEdit("q"). because what happens is. Now go to File(Menu)->Settings.WinToolbar("ToolbarWindow32").com after clicking on "I'm Feeling Lucky" button (I am not on T1 lines.1)SystemUtil\Program files\Internet Explorer\IEXPLORE.EXE". after the 3rd step it just waits for 2 second after which it goes to the Back button.blogger.com is open.Click 4) Browser("Google")."open" 2) Browser("Google").com Bottom of Form QTP Parameters This is not an exhaustive material on parameterization.

User-Defined External.qtp. Built-in are the types of environment variables available in QTP. 2. Click on the '+' which is on the right of Variable type dropdown. By default Built-in variable type is selected and you will be able to see Name and Description of Built-in variables below Variable type dropdown box. And Run the test. Now Run the test. 6. 7. You can click on any of those variables to see their current value. Go to expert view and type: msgbox(environment("a")) 8. In the Expert View type: a = environment("ActionName") & " is running on " & environment("OS") msgbox (a) 8. Open a new Test. Examples of such variables are OS. Go to Environment Tab. 5. . a Test Settings window opens.g. Lets look at an example of this: 1.com Bottom of Form QTP Environment Variables User-Defined Internal. 7. 4. User Defined Internal variables are the variables defined by you (the user) within the test and which are saved within the test and also accessible from within the test. 2. Go to File (Menu)->Settings. Open a new Test. ActionName which are for Operating System. Built-in variables as the name suggests are predefined by QTP. 3. in Name type 'a' and in Value type 'hello' (without quotes. 4. 6. I have added quotes just for clarity) and click on OK. 'Add New Environment Parameter' window opens up. Go to Environment Tab. a Test Settings window opens. Lets look at an example of this: 1. OSVersion. I just did the above four steps in order to show you from where you can access Built-in variables. Now close this Test Settings window and go to test. respectively. It is just a simple way to show how a Built-in environment variable works. 5.Go to File (Menu)->Settings. 3. From Variable type dropdown select User-defined.blogspot. It will add the variable with its type as 'internal'. Click Apply and OK to come out of Test Settings window. It will show you the value of variable 'a' in the message box. type the name and value of the variable e. Operating System Version and name of the action which is currently running.

5. 6. 3. Click Ok. 'Action Properties' window opens. 4.) 1. Go to expert view and type: msgbox(environment("Address")) 7. In the keyword View right-click on Action1. Again right-click on Action1 in the keyword View . select 'Action Call Properties'. From Variable type dropdown select User-defined. 6. 'Action Call Properties' window opens.User-Defined external variables are the variables which are defined in the file outside of test.com Bottom of Form QTP Random Variables First example of Random Numbers: When you define parameters for an action you can set the parameter's value as Random numbers. qtp. 5. it will become a button '<#>'. 2. You can create as many files for environment variables as you want and choose them for your test. There are many different ways in which you can use Random numbers in QTP. Go to File (Menu)->Settings. Open a new Test. Now lets look at an example of this: Open a new text file and type the following lines in it and save it with . 4. In the 'Input Parameters' area click on the '+' sign and enter the Name of the input parameter as 'a'.xml extension. Lets jump at the examples straightway. These act as read only for the test. Click on "Load variables and values from external file" check box and import that external xml file that we created above. It will open 'Value Configuration Options' window. Type as Number. select Action Properties. 25 yellow Road under Value and External under Type). It will show you the value of variable 'Address' in the message box. Value and Type heading (in our case it will show Address under Name. 2. Now run the test. Open a new test. Click on this button. Go to Environment Tab.blogspot. and Default value as 1. Go to 'Parameters' Tab. Example 1: 1. Click on Apply and Ok to come out of it. ( I saved it in 'tests' folder in the 'QuickTest Professional' folder under C:\Program files. As soon as it is imported the complete path of that file will be shown in the File text box and the variable in it will show under Name. a Test Settingswindow opens. . Make a single click under 'Value' column in the 'Input Parameter's' area. 3. Go to 'Parameter Values' Tab.

If we select the second option 'For each test iteration' then a message box will show same values. Click on Name Checkbox and choose arg_a from the dropdown. 10. RandomNumber("arg_a") Next 14. Second example of Random Numbers: Here is another way of generating random numbers: Open a new test and in the Expert view write these lines and run the test: For i=1 to 5 var1=RandomNumber (0. Go to Expert view of action1 and type: msgbox "action1" msgbox(parameter("a")) 13. a different value at each test run. Now Go to Insert (Menu)-> Call to New Action. but different values if you run it next time i. 8. 9. Again Click ok to come out of 'Action Call Properties' window. then it will show you which step it is currently running by pointing to that particular step with yellow color arrow and then you will be able to understand it in a better way. Click on 'Parameter' radio button. click ok to insert a new action. oneIteration. 11.EndNumber]) EndNumber is optional above. 15. 'Insert Call to New Action' window opens. (It would be better if you run it by activating the expert view. select first option-For each action iteration.) RandomNumber is an Object. 12. Now Run the test. just click ok. RandomNumber(ParameterNameOrStartNumber [. When you copy the above text to Expert View of Action2.e.7. Go to Expert View of Action2 and type: For i=1 to 3 RunAction "Action1". it will show you a message that it has made Action1 Reusable. In the Numeric Range enter 0 against From and 100 against To.action2. select 'Random Number' from the dropdown. You will see that it shows a different value in each msgbox() because we selected 'For each action iteration' from the 'Generate new random number' area. Click ok. 100) msgbox(var1) Next Third example of Random Numbers: (This is more or less same as the first one) . In the 'Generate New Random Number' area.

select first option-For each action iteration. If Randomize is not used. 4. the value returned by the system timer is used as the new seed value. Go to 'Parameters' Tab. And Run the Test.One more way is to define a Random Number parameter in the 'Parameter Options' or 'Value Configuration Options' dialog box. select 'Action Call Properties'. Click Ok. select 'Random Number' from the dropdown. Go to 'Parameter Values' Tab. it will become a button '<#>'. MsgBox var1 next Let's talk about Randomize and Rnd for some time: Randomize [number] We use a number with Randomize to initialize the Rnd function's random-number generator. 2. It will open 'Value Configuration Options' window. Again right-click on Action1 in the keyword View . Open a new test. 11. 3. Fourth example of Random Numbers: Another VBScript method of generating a random number: For i= 1 to 3 var1 = int((101*rnd)+0) ' Generate random value between 0 and 100. In the 'Input Parameters' area click on the '+' sign and enter the Name of the input parameter as 'a'. Make a single click under 'Value' column in the 'Input Parameter's' area. the Rnd function (with no arguments) uses the same number as a seed the first time it is called. 10. 8. Click on 'Parameter' radio button. Again Click ok to come out of 'Action Call Properties' window. In the Numeric Range enter 0 against From and 100 against To. If the number is omitted. giving it a new seed value. In the 'Generate New Random Number' area. Click ok. 9. Type as Number. Now in the Expert View of action1 type: x=RandomNumber("arg_a") msgbox(x) 12. In the keyword View right-click on Action1. Click on 'Name' Checkbox and choose arg_a from the dropdown. 'Action Properties' window opens. 6. In simple terms Rnd is a function and Randomize is used to initialize this function. 7. Click on this button. 1. No matter how many times you Run the below code it generates the same values: For i= 1 to 3 randomize(2) . 'Action Call Properties' window opens. and Default value as 1. 5. select 'Action Properties'.

For i= 1 to 3 randomize var1 = Int((6 * Rnd) + 1) ' Generate random value between 1 and 6. The Rnd function returns a value less than 1 but greater than or equal to 0. MsgBox var1 next But if you omitt randomize(2) from the above code and instead put only randomize then at each run it generates different values.' For i= 1 to 3 x=rnd() msgbox(x) Next . Rnd(number)If the number is Less than zero (< 0) then Rnd generates 'The same number' every time. For i= 1 to 3 x=rnd(1) msgbox(x) Next If the number is Equal to zero (=0)then Rnd generates 'The most recently generated' number. For i= 1 to 3 x=rnd(0) msgbox(x) Next If the number is Not supplied then Rnd generates 'The next random number in the sequence. MsgBox var1 next Some light on Rnd: The following formula is used to produce a random number in a given range: Int((upperbound . For i= 1 to 3 x=rnd(-1) msgbox(x) Next If the number is Greater than zero(> 0) then Rnd generates 'The next random' number in the sequence.var1 = Int((6 * Rnd) + 1) ' Generate random value between 1 and 6. using number as the seed.lowerbound + 1) * Rnd + lowerbound) likewise Int((6 * Rnd) + 1) ' Generate random value between 1 and 6.

Make a single click under 'Value' heading. use the Randomize statement without an argument to initialize the randomnumber generator with a seed based on the system timer. 'Action Properties' window opens. the same number sequence is generated because each successive call to the Rnd function uses the previous number as a seed for the next number in the sequence.com Bottom of Form QTP Test parameters 1. Go to Expert View and type: msgbox(parameter("varaction")) 15. There you will see the 'varaction' action parameter we created earlier. The Type of this parameter is string. Before calling Rnd. Now run the test. Click Ok to come out of that window. 'Action Call Properties' window opens. Enter the Name of the parameter as 'varaction' and its Type as string and no default value. 4. This example show how to declare test parameters and how to access those. it will show a button like this <#>. 'Test Parameters' radio button will be selected by default and under 'Test Parameters' radio button select 'vartest' from Parameter dropdown. Click on '+' sign which is on the top right. Remember (taken from QTP guide): . Go to File->Settings. When you click on ok to come out of 'Value Configuration Options' window.blogspot. 9.Remember: For any given initial seed. 5. Click on '+' sign which is on the top right. 3. While running it will show 'hello' in the msgbox. Enter the Name of the parameter as 'vartest' and its Default Value as 'hello'. 11. Now in the Keyword View right click on Action1 and select 'Action Properties'. Go to 'Parameters' Tab. 10. qtp. Just click on this button to open 'Value Configuration Options' window. 7. go to 'Parameters' Tab. 14. in the 'Action Call Properties' window. Above we have created a Test Parameter. 12. Click on 'Parameter' radio button and select 'Test/action Parameter' from that dropdown. Go to 'Parameter Values' Tab. under 'Value' it will show <vartest>. Click Apply and then Ok. 8.[ remember this vartest is a test parameter we created at the beginning] 13. Open a New Test. Click Ok. a 'Test Settings' window will open. 6. 2. Again in the Keyword View right click on Action1 and select 'Action Call Properties'.

2. 3.You can directly access test parameters only when parameterizing the value of a top-level action input parameter or when specifying the storage location for a top-level output parameter. it will show you the sum 4 in msgbox. Open a new Test. In the keyword View right click on action2 and select 'Run from Step'. in the format: Parameter ("ParameterName"). 9. Just click ok to insert a new action. qtp. 2.com Bottom of Form QTP Global & Action Data Sheet Parameters Example 1 How. Alternatively. QTP iterates all rows of any action data sheet. you can enter the parameter name in the Expert View using the Parameter utility object. .2 10. qtp. 'Action Properties' window opens. 'Action Properties' window opens. In the Keyword View right click on Action1 and select 'Action Properties'. 1.blogspot. Go to Insert (menu)-> Call to New Action. 5. 3. you must pass the test parameter to the action containing the step. In the general tab. In the Expert View of action2 type: RunAction "Action1". In the same way create another Number parameter 'b'. oneIteration. Enter the Name of the parameter as 'a' and its Type as Number. Make action2 reusable as we did for action1. 2. To use values supplied for test parameters in steps within an action. 'Insert Call to New Action' window opens. In the Expert View of Action1 type: s1=parameter("a") s2=parameter("b") msgbox(s1+s2) 7. In the Keyword View right click on Action1 and select 'Action Properties'. 4. for each row. 8.blogspot. Click on Record.Go to Start->All Programs->QuickTest Professional->Sample Applications->Flight. click on 'Reusable Action' checkbox at the bottom to make the action reusable. Click Ok. Go to 'Parameters' Tab. 6. Click on '+' sign which is on the top right.com Bottom of Form QTP Action Parameter 1. in global data sheet.

In the Local Data Sheet (action2) add two more rows to make them a total of 3. Now my action1 looks like this:    SystemUtil.Type micTab Dialog("Login").WinEdit("Password:"). For this action2. In the Keyword View under 'Value' column. repeat steps from 2 to 7."". 16. Enter the Agent Name as 'mary' and Password as 'mercury'. click on this button to open 'Value Configuration Options' window. (This time I have used the Agent Name as 'bill') 12. both of them do the same job but their data is in different sheets."C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\". make sure you select Current action sheet (local) in the Location in Data Table area. Click Stop in order to stop recording the test. Do the same for action2. go to Run Tab and select "Run on all rows" radio button. Click Ok (make sure we click ok with mouse and not hit the return (enter) Key. go to File->Exit. 6. Go to Global Data Sheet and Add one more row in it below 'mary'. I added 'amar' and 'Sumit'. Go to Insert (menu) -> Call to New Action to insert action2."open" Dialog("Login"). Right click on action1 and select action call properties.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.WinEdit("Agent Name:"). a button like <#> will appear. as we did for action1. Click Ok to close that window. It will add a new column in action2 Data Sheet with 'bill ' (because I used bill as an Agent Name ) as its first row. when you click on 'Parameter' radio button and select Data Table from the dropdown.WinButton("OK").4. 11. 10.Click Window("Flight Reservation"). I added 'rama'.Exit"     19. When the Flight Reservation window is open. 13.Set DataTable("p_Text". 8. 9. Now you have two actions (action1 and action2). Click on Parameter radio button and select Data Table from the dropdown and let rest everything be default. make a single click on 'mary' (Agent Name).WinMenu("Menu"). Do the same for action2 and type msgbox("acton2") in its Expert view. dtGlobalSheet) Dialog("Login").Select "File.WinEdit("Agent Name:"). 14. 18. After repeating step 7. In the Global Data sheet it will add a new columns with 'mary' as its first value.) 5. click ok to come out of that window. .exe". 7.SetSecure "4725bcebeea3b6682d186bf7b15ae92cc4e6c0ba" msgbox("acton1") Dialog("Login"). 17. Go to Expert View of action one and type : msgbox("acton1"). 15.

dtGlobalSheet) 'accessing data from Global data sheet from action1 msgbox rc rc = DataTable.blogspot.Value("A". In Expert View of action1 type: msgbox("I am in action 1") rc = DataTable.1) type 'Global Data'.Value("A". In the Action1 Data table. 3. in cell(A.Value("A". in cell(A. 4. in cell(A.1) type 'Action1 Data'. Open a new test and also open a sample Flight application (Flight Reservation window) 2. 1. just to make you familiar with the process so that you can start on your own.20. 2) 'accessing data from action1 data sheet from action2 msgbox rc qtp. . For complete understanding of Output values please see QTP User Guide. dtGlobalSheet) 'accessing data from Global data sheet from action1 msgbox rc rc = DataTable. 2) 'accessing data from action1 data sheet from action1 msgbox rc In expert view of action2 type: msgbox("I am in action 2") rc = DataTable. Go to Insert (Menu)->Output Value->Standard Output Value. I have added the msgbox step in both the action just to make you understand how the QTP is picking up the rows from Data Sheets. Now Run the test. Open a new test. In the Global Data table. Example 2 This examples shows that each action can access data not only from Global Data Sheet or its own Local Data Sheet but also from other action's Data Sheet in the same test. In the Action2 Data table. otherwise it will be fast and some people may not able to understand. Click on Record in order to record a test.com Bottom of Form QTP Output Values This is a very small tutorial on output values.1) type 'Action2 Data'. Insert two actions.Make sure that both (new test and Flight Reservation window) are open and visible.Value("A".

"Output Value Properties" window opens with 'Insert Order' in the Name text field. 12. In this window just click Ok. Click on first checkbox (which is Property enabled and Value False). 14. 10. Click Ok. Click on 'Insert Order' button in 'Flight Reservation window.5. In the 'Configure Value' area click on Modify button. Go to Insert (Menu)->Output Value->Standard Output Value. QTP will show that value in Data Table (under Insert_Order_enabled_Out column) at Run time. 9. 5. Click Ok. 'Output Options' window opens. Click Stop in order to stop the test. 1. It will also show that captured value in the Results window. 9. 10. It will bring you back to "Output Value Properties" window. (It creates Insert_Order_enabled_Out column in Global datasheet in Data Table with a Value False in the first row) 11. Make sure that both (new test and Flight Reservation window) are open and visible. 13. These above steps show you how to use output values with Data Table. "Object Selection . 3.Output Value Properties" window opens with WinButton : Insert Order highlighted. Click on 'Insert Order' button in Flight Reservation window. 4. 6. 8. "Output Value Properties" window opens with 'Insert Order' in the Name text field. Open a new test and also open a sample Flight application (Flight Reservation window) 2.' 6. "Object Selection . 8.Output Value Properties" window opens with WinButton : Insert Order highlighted. 7. QTP will be minimized and mouse pointer will take the shape of a hand. Click on Record in order to record a test. Again Click Ok to come out of this "Output Value Properties" window. 7. Now earlier where under Value it was showing False (see step 8) now it will show Insert_Order_enabled_Out. Output Options window opens. . Now it means whatever the value of Insert Order button's Enable Property will be. Below tutorial shows how to use output values with Environment variables. It will show a true value in there at run time. In the Configure Value area click on Modify button. QTP will be minimized and mouse pointer will take the shape of a hand. Click on first checkbox (which is Property enabled and Value False). Just make that Insert Order button enable by putting some values in Flight Reservation window and then see that column (Insert_Order_enabled_Out ) in Data table.

It will add a column in the Global Data Sheet with "Sachin" as its first value. (You can check that environment variable by going to File->Settings. I added "aaaa" in the 2nd and "bbbb" in the 3rd. Environment Tab and choosing UserDefined from variable type) 14. Add two more values in the subsequent rows. When the Flight Reservation window is open Go to File (menu)->Exit. select Environment. Click Ok to come out of this "Output Value Properties" window. qtp. which you checked above. . Enter the Agent Name as "Sachin" and Password as "mercury". Make sure you use Tab key to move from one text box to another and hit Return (Enter) key after entering the Password.] In the "Checkpoint Properties" window just click on Ok to come out of it. It will show a true value in there at run time. It will also show that captured value in the Results window. In this area click on Parameter Radio button. Click on Record. This is all we need to do. Make sure only the Text property is checked which has a value of "Sachin" and rest all of the properties must be unchecked.blogspot. Just make that Insert Order button enable by putting some values in Flight Reservation window and then see that environment variable value (Insert_Order_enabled_Out ). For this tutorial I will take into account Text Checkpoint created through Standard Checkpoint while editing. In 'Output Options' window." "Checkpoint Properties" window opens.11. Click on Stop in order to stop the recording. 13. and click Ok. 12. Just add the below line in the Expert View at the end to see the value of the environment variable. Now you can Run the test. Right-click anywhere on that row and choose "Insert Standard Checkpoint. msgbox(environment("Insert_Order_enabled_out")) 15. Open a new test. [On the right hand side of Parameter Radio button you will see Parameter Options button (which has paper and pen image on it). in order to highlight it and make "Configure Value" area enabled. Now Insert_Order_enabled_out will be User-Defined internal environment variable. In the Keyword view go to the row which has "Sachin" under Value column. you can click on it to see the default values QTP has set for us. from 'Output Types' dropdown.com Bottom of Form Parameterize a Checkpoint You can create a Checkpoint while recording or editing a test. Go to Start-> All Programs->QuickTest Professional->Sample Applications->Flight. Just make a single click on Text Property.

Go to Insert (Menu) -> Call to New Action. to add a new action at the end of the test. Remember this is a Text Checkpoint on the "Agent Name" Text field. (To create an input variable. these act as a foundation for action input and output values (this is ONE of the many ways. Any value entered there first time will be compared by first row of the Global Data Sheet which has "Sachin" and any value entered there Second time will be compared by second row of the Global Data Sheet which has "aaaa" and so on.blogspot. Just try to enter some other value during second time like "xxxx" it will run the test but show you "Failed" in the Results window in the second iteration. qtp. 3) Action output value (value returned by a called action) can be stored in environment variable.com Bottom of Form QTP Action input output parameters Example 1 Action output value (value returned by a called action) can be stored in a variable Open a new test. you have to enter Agent Name all of the 3 times (Just enter the Agent Name.blogspot. Go to Parameters tab and create input variable in_a1_1 with Type as Number. Make sure you enter "Sachin" during first time. same as above. that's it. Create another input variable in_a1_2. We don't need to enter the Password. it will have Action1. 4) Action output value (value returned by a called action) can be stored in Any variable and RunAction Statement is not used. of course there can be other ways of doing the things I have done below). Now we have Action1 and Action2 in this test. 1) Action output value (value returned by a called action) can be stored in a variable 2) Action output value (value returned by a called action) can be stored in data table column. . In the Keyword View. just have a look at these examples. you have to click on ‘+’ sign which is on the right hand side of Input parameters section).com Bottom of Form QTP Action input output parameters Those who are still confused about input parameters to actions and output values from actions.Now when we run the test and it opens the window where we need to enter the Agent Name and Password. no Tab key or Return key). right click on Action1 and choose Action Properties. Rest everything be default. "aaaa" during second time and so on. By default. 5) Working with Four Actions qtp.

qtp. var1 msgbox var1 To Run this test make sure Action2 is selected / highlighted if you are in the Keyword View or Action2 is selected from the dropdown above if you are in the Expert View and then choose Automation (Menu) -> Run Current action. same as above. you have to click on ‘+’ sign which is on the right hand side of Output parameters section).com Bottom of Form QTP Action input output parameters Example 2 Action output value (value returned by a called action) can be stored in data table column. 2. just click on Ok) RunAction "Action1". you have to click on ‘+’ sign which is on the right hand side of Output parameters section). it will have Action1. to add a new action at the end of the test. By default. Open a new test.In the Parameters tab. right click on Action1 and choose Action Properties. In the Expert view of Action1 type: s1=parameter("in_a1_1") s2=parameter("in_a1_2") parameter("out_a1_1")=s1+s2 In the Expert view of Action2 type: (When you copy this below code in Expert view of Action2. also create one output variable out_a1_1 with Type as Number (To create an output variable. Rest everything be default. it may give you a warning that it will make Action1 reusable. you have to click on ‘+’ sign which is on the right hand side of Input parameters section). (To create an input variable. it may give you a warning that it will make Action1 reusable. Now we have Action1 and Action2 in this test.2. also create one output variable out_a1_1 with Type as Number (To create an output variable. In the Parameters tab. Create another input variable in_a1_2. Go to Parameters tab and create input variable in_a1_1 with Type as Number. Go to Insert (Menu) -> Call to New Action. In the Keyword View. just click on Ok) .blogspot. oneIteration. In the Expert view of Action1 type: s1=parameter("in_a1_1") s2=parameter("in_a1_2") parameter("out_a1_1")=s1+s2 In the Expert view of Action2 type: (When you copy this below code in Expert view of Action2.

In the Parameters tab.RunAction"Action1". Go to Parameters tab and create input variable in_a1_1 with Type as Number.com Bottom of Form QTP Action input output parameters Example 3 Action output value (value returned by a called action) can be stored in environment variable. 2. Open a new test. 2.dtGlobalSheet) In the Global Data Sheet. you have to click on ‘+’ sign which is on the right hand side of Input parameters section).blogspot. qtp. to add a new action at the end of the test. DataTable("Action1_out". It will open Change Parameter Name box. you have to click on ‘+’ sign which is on the right hand side of Output parameters section). where you have column names as A. 2. double click on A. (To create an input variable. right click on Action1 and choose Action Properties. Rest everything be default. B and so on. In the Expert view of Action2 type: (When you copy this below code in Expert view of Action2. Enter the Name of the parameter as env_var and let the 'Value' field be empty and click on Ok. By default. Enter the parameter name as Action1_out and click Ok. same as above. Click on the + sign which is on the right side. ‘Add New Environment Parameter’ window opens. Environment tab. oneIteration. Now we have Action1 and Action2 in this test. it may give you a warning that it will make Action1 reusable. in the 'Variable type' dropdown choose User-defined. To Run this test make sure Action2 is selected / highlighted if you are in the Keyword View or Action2 is selected from the dropdown above if you are in the Expert View and then choose Automation(Menu) -> Run Current action. just click on Ok) RunAction "Action1". In the Keyword View. Create another input variable in_a1_2. Environment ("env_var") msgbox Environment ("env_var") . oneIteration. it will have Action1. 2. Go to Insert (Menu) -> Call to New Action. In the Expert view of Action1 type: s1=parameter("in_a1_1") s2=parameter("in_a1_2") parameter("out_a1_1")=s1+s2 Go to File-> Settings. also create one output variable out_a1_1 with Type as Number (To create an output variable.

Then Action1 passes the sum (i. Go to Parameters tab and create output variable out_a1_1 with Type as Any.com To Run this test.com Bottom of Form QTP Action input output parameters Example 4 Action output value (value returned by a called action) can be stored in Any variable and RunAction Statement is not used. Automation (Menu) ->Run Current Action What these Actions will do: Action4 will call Action1 with two input values 2. right click on Action2 and choose Action Properties. always go to Action4 and then. Open a new test.e. Go to Insert-> Call to New Action. .blogspot. Go to Parameters tab and in the Value column enter var1. right click on Action2 and choose Action Call Properties. qtp. Action1 sums those values (2+2=4) and assigns the sum to out_a1_1 (Action1’s output parameter). Now we have Action1 and Action2 in this test. By default it will have Action1. In the Keyword View. In the Keyword View. 2. right click on Action1 and choose Action Call Properties. In the Keyword View. 4) along with another number (3) to Action2 by calling Action2 in its last line.blogspot. Go to Parameters tab and create input variable in_a2_1 with Type as Any. to add a new action at the end of the test.To Run this test make sure Action2 is selected / highlighted if you are in the Keyword View or Action2 is selected from the dropdown above if you are in the Expert View and then choose Automation (Menu) -> Run Current action. In the Keyword View. In the expert view of Action1 type: Parameter("out_a1_1") = 23 In the expert view of Action2 type: msgbox Parameter(" in_a2_1") qtp. right click on Action1 and choose Action Properties. Go to Parameters tab and in the ‘Store In’ column enter var1.

Although there are other methods like CloseProcessByName etc. . Go to Insert-> Call to New Action. 5. when ‘Insert Call to New Action’ window opens. In the Expert view of Action1 type: s1=parameter("in_a1_1") s2=parameter("in_a1_2") parameter("out_a1_1")=s1+s2 RunAction "Action2". output variable out_a3_1). output variable out_a2_1) and Action3 (input variables in_a3_1 & in_a3_2. Open a new test. click on the +. parameter("out_a2_1"). which is on the right hand side of input parameters.5 In the Expert view of Action3 type: parameter("out_a3_1")= parameter("in_a3_1") + parameter("in_a3_2") msgbox parameter("out_a3_1") In the Expert view of Action4 type: RunAction "Action1". parameter("out_a1_1").2 QTP SystemUtil Vs InvokeApplication SystemUtil is an object which is used to control applications and processes during a run session. 4. [dir]. Obviously Action1 will be there by default. Action Properties window opens and go to Parameters tab. 3) it got from Action1 and passes on the result of multiplication (12) and another number (5) to Action3. oneIteration. 2. Similarly add Action3 and Action4.Action2 multiplies those two values (4. 2. 1.Similarly add 2nd input variable in_a1_2 and one output variable out_a1_1 also a Number Type. a1 is for action1 and 1 is 1st variable) and keep its Type as Number. 3. oneIteration. where these passed on values are added and the result is shown in a message box.Run is “one of the methods” of SystemUtil object.[StartIn]) command: The path and command line options of the application to invoke. 6. 3 In the Expert view of Action2 type: parameter("out_a2_1")= parameter("in_a2_1") * parameter("in_a2_2") RunAction "Action3". oneIteration. [mode] The InvokeApplication method can open only executable files and is used primarily for backward compatibility InvokeApplication(Command . [op]. object. In the Keyword View right click on Action1 and choose Action properties. [params].Run file. In the Parameters tab. let all other things be default. Similarly add input and output parameters for Action2 (input variables in_a2_1 & in_a2_2. This adds Action2. file: The name of the file you want to run. Add 1st input variable as in_a1_1 (in means input. just click on Ok.

for complete list of modes. Print etc. op:: The action to be performed.exe". "Open". Example using all arguments except params: SystemUtil. "". Example using Command argument The following example uses the InvokeApplication function to open Internet Explorer on my machine. InvokeApplication "C:\Program Files\Internet Explorer\IEXPLORE. use the params argument to specify any parameters to be passed to the application.Notepad").EXE".Run "foo. (Make sure you have a file name foo. Other actions can be Edit. "". False is returned.Run statement is automatically added to your test when you run an application from the Start menu or the Run dialog box while recording a test. If this argument is blank ( "")." " .Run statement. Return Value Boolean.Close You can run any application from a specified location using a SystemUtil. "C:\". "1" wait(3) window("text:=foo .txt in C:\ drive) SystemUtil.txt". It should work fine. Example please see QTP User Guide.com" This below example opens a text file foo which is saved in C:\ drive and waits for sometime and then closes it.Close using both the arguments. Command path refers. InvokeApplication "\Program Files\Internet Explorer\IEXPLORE. dir The default directory of the application or file. "c:" Example using params: SystemUtil.params: If the specified file argument is an startIn:The working folder to which the executable file.Run "iexplore. If the function fails to open the application. This is especially useful if your test includes more than one application. You can specify one of the modes in the table below.google. Default = 1 Activates and displays the window. . You can type the below line in a new test in QTP and Run it. "" wait(3) window("text:=foo . and you selected the Record and run test on any application check box in the Record and Run Settings dialog box.txt".EXE" There are 10 modes.Notepad"). "http://www. A SystemUtil. the open operation is performed. You can write the below code in a new test in QTP and run it.Run "C:\foo. mode: Specifies how the application is displayed when it opens.

then the Run fails with an error message. QTP avoids that step and continues ahead during a Run session. Make sure that a new blank test and a blank Internet Explorer window is open. . Enter Username.If a Step in an optional dialog box does not open. 2. a message is displayed for the step that failed to open the dialog box. In QTP click on Record in order to start recording. 4. For example: OptionalStep.com Bottom of Form QTP Optional Step By default. QuickTest Professional deems steps that open the following dialog boxes or message boxes as Optional Steps: Dialog Box / Message Box Title Bar AutoComplete File Download Internet Explorer Netscape Enter Network Password Error Security Alert Security Information Security Warning Username and Password Required 1.Dialog("AutoComplete"). 3. 2. To COMPLETE a Run session an optional step is not necessarily required.WinButton("Cancel"). 5. 3.Browser("Browser"). Enter Password. However if QTP does not find an Object from the optional step in the Object Repository.blogspot.qtp.Click This is an Optional step icon A simple example for Optional Step: 1. You can also add an optional step in the Expert View by adding OptionalStep to the beginning of the VBScript statement. Here remember that the step does not cause the Run to fail. Go to Start-> Programs-> QuickTest Professional->Sample Applications-> Flight. At the end of the Run session.

7. for better understanding “test with reusable action"). qtp. 9. it will not show any error message or fail. it will just bypass the ‘browser closing’ step as we have marked it Optional and it will ignore any error for the optional step. Close the Internet explorer window also from the Cross button which is on the extreme top right. 2. Click Stop to stop the test recording.blogspot. It has just one line of code: Msgbox "I am a reusable action" In the Keyword View. When the Flight application is open go to File->Exit. (E. I created a test in QTP with the name "twra". 8. Hit the enter key. Select Action window opens. Now make sure that "call twra" test is open and go to Insert ->Call to Existing Action. check the ‘Reusable action’ checkbox in the General tab and click OK.6. I created another test in QTP with the name "call twra". right click on Action1 and choose Action Properties. In the Action Properties dialog box that opens.com Bottom of Form QTP Relative Path For this example assume that all of the tests are stored in C:\Program Files\Mercury Interactive\QuickTest Professional\Tests 1.twra" 3. But it shows you the warning in the test results. The idea is when you run the above test without IE. . In the Keyword view. follow the below steps: Finally it looks like this Now before you run the test make sure Internet Explorer window is NOT open.g. Try to run the same test by just removing the ‘Optional Step’ tag from the above lines and see that it will fail and show you the Run Error.. At present it also has just one line of code: Msgbox "I am going to call a reusable action in a test .

The relative path is relative to the location of the test currently being edited.Here you have to click on “…” button or type the complete path (in ‘From test:’ dropdown) to select the test that contains the reusable action. The paths that you specify here can be a full path or a relative path. Click on + to add a Path. In our case we will add C:\Program Files\Mercury Interactive\QuickTest Professional\Tests. Now without doing anything on Select Action window. . Now go to Tools -> Options and go to Folders tab. just close (Cancel) it. because all the tests are stored in Tests folder. 4.

Select Action window opens.) as relative path. then during the run session. 5. Now again go to Insert ->Call to Existing Action. path for Function Library or path for Object Repository etc.g.After entering the path click OK. QuickTest searches for the file in the folders listed in . Now in the “From test:” dropdown just type the name of the test from where you want to call a reusable action (twra in our case) and it will list all of its reusable actions. [If you enter any path (e.

This is because both the tests are located in C:\Program Files\Mercury Interactive\QuickTest Professional\Tests and we are currently in C:\Program Files\Mercury Interactive\QuickTest Professional\Tests\call twra. since both “twra” and “Call twra” are stored under Tests. [Just understand the below text very carefully:] We can also do the above steps like this: (Suppose “call twra” test is open) Above in the 3rd step when Select Action window opens. in the order in which the folders are listed. Above you saw just one way of doing things. Path of current test (<current test>) is always there in search list (Tools -> Options -> Folders tab).\twra in the “From test:” dropdown (No need of step 4 and 5 above) in order to access its reusable actions.the Folders pane of the Options dialog box.. we can simply write . .] Note: Use of relative path is possible anywhere in QuickTest Professional.

.\ and type twra.\.Locate statement in your test to retrieve the complete path that QuickTest will use for a specified relative path based on the folders specified in the Folders tab..\twra) in ‘From test:’ dropdown in Select Action window. PathFinder is an object which lets you to find file paths. Script on How to add any path in the Search List '(Tools -> Options -> Folders tab) through a script. Msgbox (PathFinder. . One more way to understand: (Still suppose we are in “call twra”) If on your system you go to C:\Program Files\Mercury Interactive\QuickTest Professional\Tests\ and cut the folder twra from here and paste it under C:\Program Files\Mercury Interactive\QuickTest Professional\ then in the above situation you have to go two folders back and type .Locate ("twra")) See how much you have learned about QTP Relative & Absolute Path by answering these Multiple Choice Questions .\... since we are in test C:\Program Files\Mercury Interactive\QuickTest Professional\Tests\call twra... PathFinder.Locate You can use a PathFinder.\ and then type twra (so in all we have to type . so to find twra which is under C:\Program Files\Mercury Interactive\QuickTest Professional\Tests\ we go one step back with .and our current path is C:\Program Files\Mercury Interactive\QuickTest Professional\Tests\call twra. So in all we type .\twra and it will find it. Locate is a method of PathFinder object which returns the full file path that QuickTest uses for the specified relative path based on the folders specified in the Folders tab search list (Tools -> Options -> Folders tab). Additionally you can add the below line in the "call twra" test to know which relative path it picked from the search list (Tools -> Options -> Folders tab).

In the Numeric Range enter 0 against From and 100 against To. and Default value as 1. 5. There are many different ways in which you can use Random numbers in QTP. 3. Type as Number. 9. . select 'Random Number' from the dropdown. In the 'Generate New Random Number' area. Example 1: 1. 7. Go to Expert View of Action2 and type: For i=1 to 3 RunAction "Action1". Click on 'Parameter' radio button. Lets jump at the examples straightway. Open a new test.qtp.blogspot. Go to 'Parameter Values' Tab. 10. Click on this button.action2. click ok to insert a new action. It will open 'Value Configuration Options' window. 'Insert Call to New Action' window opens. Again right-click on Action1 in the keyword View . Again Click ok to come out of 'Action Call Properties' window. just click ok. oneIteration. 12. 'Action Properties' window opens. 2. Now Go to Insert (Menu)-> Call to New Action. 8.com Bottom of Form QTP Random Variables First example of Random Numbers: When you define parameters for an action you can set the parameter's value as Random numbers. RandomNumber("arg_a") Next 14. When you copy the above text to Expert View of Action2. Go to 'Parameters' Tab. Now Run the test. select Action Properties. 15. Click on Name Checkbox and choose arg_a from the dropdown. 6. 'Action Call Properties' window opens. Make a single click under 'Value' column in the 'Input Parameter's' area. 4. In the 'Input Parameters' area click on the '+' sign and enter the Name of the input parameter as 'a'. In the keyword View right-click on Action1. select first option-For each action iteration. Go to Expert view of action1 and type: msgbox "action1" msgbox(parameter("a")) 13. 11. Click Ok. Click ok. it will show you a message that it has made Action1 Reusable. it will become a button '<#>'. select 'Action Call Properties'.

7.(It would be better if you run it by activating the expert view. Go to 'Parameters' Tab. Click on 'Parameter' radio button. In the 'Generate New Random Number' area.e. then it will show you which step it is currently running by pointing to that particular step with yellow color arrow and then you will be able to understand it in a better way. 4. 10. 'Action Call Properties' window opens. Type as Number. Go to 'Parameter Values' Tab.EndNumber]) EndNumber is optional above. Make a single click under 'Value' column in the 'Input Parameter's' area. 3. 6.) RandomNumber is an Object. Click ok. Click Ok. but different values if you run it next time i. 9. a different value at each test run. 100) msgbox(var1) Next Third example of Random Numbers: (This is more or less same as the first one) One more way is to define a Random Number parameter in the 'Parameter Options' or 'Value Configuration Options' dialog box. In the keyword View right-click on Action1. In the 'Input Parameters' area click on the '+' sign and enter the Name of the input parameter as 'a'. 2. Now in the Expert View of action1 type: x=RandomNumber("arg_a") msgbox(x) . select 'Random Number' from the dropdown. 'Action Properties' window opens. Open a new test. Click on 'Name' Checkbox and choose arg_a from the dropdown. Again Click ok to come out of 'Action Call Properties' window. You will see that it shows a different value in each msgbox() because we selected 'For each action iteration' from the 'Generate new random number' area. 8. If we select the second option 'For each test iteration' then a message box will show same values. In the Numeric Range enter 0 against From and 100 against To. and Default value as 1. 5. select 'Action Properties'. RandomNumber(ParameterNameOrStartNumber [. select first option-For each action iteration. It will open 'Value Configuration Options' window. it will become a button '<#>'. Second example of Random Numbers: Here is another way of generating random numbers: Open a new test and in the Expert view write these lines and run the test: For i=1 to 5 var1=RandomNumber (0. 1. Again right-click on Action1 in the keyword View . select 'Action Call Properties'. Click on this button. 11.

For i= 1 to 3 x=rnd(-1) msgbox(x) Next . No matter how many times you Run the below code it generates the same values: For i= 1 to 3 randomize(2) var1 = Int((6 * Rnd) + 1) ' Generate random value between 1 and 6. And Run the Test. MsgBox var1 next Some light on Rnd: The following formula is used to produce a random number in a given range: Int((upperbound . Rnd(number)If the number is Less than zero (< 0) then Rnd generates 'The same number' every time. MsgBox var1 next But if you omitt randomize(2) from the above code and instead put only randomize then at each run it generates different values. giving it a new seed value. If the number is omitted. the Rnd function (with no arguments) uses the same number as a seed the first time it is called. In simple terms Rnd is a function and Randomize is used to initialize this function. the value returned by the system timer is used as the new seed value. using number as the seed. For i= 1 to 3 randomize var1 = Int((6 * Rnd) + 1) ' Generate random value between 1 and 6. The Rnd function returns a value less than 1 but greater than or equal to 0. MsgBox var1 next Let's talk about Randomize and Rnd for some time: Randomize [number] We use a number with Randomize to initialize the Rnd function's random-number generator.lowerbound + 1) * Rnd + lowerbound) likewise Int((6 * Rnd) + 1) ' Generate random value between 1 and 6. Fourth example of Random Numbers: Another VBScript method of generating a random number: For i= 1 to 3 var1 = int((101*rnd)+0) ' Generate random value between 0 and 100. If Randomize is not used.12.

Example 1 of Crypt Object Type the below text in a new test in QTP and run it. You can also write the function (Crypt_Pass) in library and call it from a QTP test.Encrypt(pwd) msgbox e_pwd Example 2 of Crypt Object Type the below text in a new test in QTP and run it. pwd = "sachin" e_pwd = Crypt. For i= 1 to 3 x=rnd(1) msgbox(x) Next If the number is Equal to zero (=0)then Rnd generates 'The most recently generated' number. Crypt object has an Encrypt method which takes string (string to encrypt) as its parameter. pas = "Sachin" MsgBox Crypt_Pass(pas) . QTP Crypt Object Crypt Object is used to encrypt strings. use the Randomize statement without an argument to initialize the randomnumber generator with a seed based on the system timer.' For i= 1 to 3 x=rnd() msgbox(x) Next Remember: For any given initial seed. Before calling Rnd. the same number sequence is generated because each successive call to the Rnd function uses the previous number as a seed for the next number in the sequence.If the number is Greater than zero(> 0) then Rnd generates 'The next random' number in the sequence. For i= 1 to 3 x=rnd(0) msgbox(x) Next If the number is Not supplied then Rnd generates 'The next random number in the sequence.

Type micReturn Source . pwd = "sachin" e_pwd = Crypt.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a. Write the below 3 lines in a notepad and save it with .exe". I am entering the encrypted password (in e_pwd) in "Agent Name" field of the Login dialog box which shows up when you open the Flight Application.Encrypt(pwd) SystemUtil.vbs extension and run it from command prompt.vbs" under c:\ and ran it from command prompt by typing just "a" and pressing enter. For example I saved it as "a. Set a=CreateObject("Mercury.WinEdit("attached text:=Agent Name:").WinEdit("attached text:=Agent Name:")."C:\Program Files\HP\QuickTest Professional\samples\flight\app\".Type micTab Dialog("text:=Login").Function Crypt_Pass(epas) Crypt_Pass = Crypt."open" Dialog("text:=Login").SetSecure e_pwd Dialog("text:=Login").Encrypter") Msgbox a.WinEdit("attached text:=Password:"). Entering the encrypted text in a non-secured edit box lets you know the original text.WinEdit("attached text:=Password:")."".encrypt ("Sachin") Set a=Nothing Source Example 4 of Crypt Object There is one trick by which you can know the encrypted password.Encrypt(epas) End Function Example 3 of Crypt Object Use Encrypt outside of QTP in VBScript.Set "mercury" Dialog("text:=Login"). For example type the below lines in a new test in QTP and run them.

easier to maintain. User-defined functions can be stored in a function library or within an action in the test.blogspot. it will show all of the Built-in functions in Operation Combo box))] If the function is stored in a function library then we have to associate that function library to a test so that the test can call all the public functions listed in that library. in theStep Generator dialog box choose Built-in functions from Library Combo box. User-defined functions will make your tests look shorter. Time and resources can be saved by implementing and using user-defined reusable functions. Advantages of Function Library (functions) 1. 2. 3. Functions in an associated function library are accessible: . [It is advisable not to give user-defined functions same name as built-in functions (refer to the Built-in functions list in the Step Generator (Insert > Step Generator.qtp. read and design. A user-defined function can then be called from within an action.com Bottom of Form Function Library Function Libraries in QTP If you have repeatable steps in a test or an action then consider using a user-defined function. User-defined functions can be registered as a method for a QTP test object.

You are ready to go. (Resources->Associated Function Libraries.ReportEvent statement to the function code. 2. or c) Can be entered manually in the Expert View.a) From Step Generator (for tests and function libraries). the changes will take effect only after the test is reopened. Functions directly stored in an action in a test can be called from within that action only making them private from the outside world. If we use options like Run from step or Debug from step. Associate it with a test (File-> Associate Library with Test). b) From the Operation column in the Keyword View.Example of registering a function to a test object by creating a new operation Example 4 . Functions can be created manually or by using Function Definition Generator. you must include it in all the function libraries associated with the test otherwise QuickTest ignores all the Option Explicit statements in all function libraries.) You can save function library either from File->Save or right click on function library tab on the top of function library and choose save. It is easy to create a function library: 1. Many different function libraries can be opened simultaneously as each opens in its own separate window and you can work on them separately. QTP does not recognize the method registration because it occurred earlier to the beginning of the current run session and this all is due to the reason that QTP clears all method registrations at the beginning of each run session. Open a new function library (File->New->Function library). to begin running a test from a point after method registration was performed in a test step (and not in a function library).Simple example of a Function Library and test Example 2 . Example 1 . If you want to use Option Explicit statement in Function Library. Add content to it (your function). A Private function can also be created in a function library and this private function can only be called from within the function library itself in which it is defined. Steps using user-defined functions are not displayed in the test results tree of the Test Results window by default.Example using private and public functions in function library Example 3 . 3. you must add a Reporter. . it applies to an entire test object class and it's not possible to register a method for a specific test object.Example of overriding a copy operation of a WinEdit Class objects Some important points regarding Function Libraries. When we register a function. For function to appear in the test results tree. If a function library that is referenced by a test is modified by you or any other user using an external editor. If a test is open you can view all the function libraries associated with it.

so that tests calling your action will not be affected by the method registration. Most important of all: If you register a method within a reusable action. Include a Dim statement only in the last function library (since function libraries are loaded in the reverse order). We can re-register the same method with different user-defined functions without first unregistering the method. the Set method stops using the functionality defined in the MySet2 function.Always make sure that each function has a unique name. When it is unregistered it is reset to its original QTP functionality e. type the name of the function as my_sum. In the Arguments area click on ‘+’ and type the name of first argument as ‘var1’ and again click on ‘+’ and type the name of second argument as ‘var2’ and let the Pass Mode be the default which is ‘By Value’. If there are two associated function libraries that define the same variable in the global scope using a Dim statement or define two constants with the same name. Open a new function library. 2. 5.blogspot. In the Function Definition Generator window. Open a new test. 6. Go to File->New->Function library. Click on Ok to close that Function Definition Generator window. and returns to the original QuickTest Set functionality. qtp. Now it will add the function to your already open Library. QTP will always call the last function because QuickTest searches the test script for the function prior to searching the function libraries. In Additional Information area. "Set". and not to the functionality defined in the MySet function. enter the Description as ‘addition function’. it is strongly recommended to unregister the method at the end of the action (and then re-register it at the beginning of the next action if necessary). 7. "Set". If you need to use more than one variable with the same name in the global scope. "Set" After running the UnRegisterUserFunc statement. RegisterUserFunc "WebEdit". "MySet" RegisterUserFunc "WebEdit". 8. "MySet2" UnRegisterUserFunc "WebEdit". Go to Insert->Function Definition Generator.Example 1 1. Let the ‘Documentation’ be empty. if more than one function with the same name exists in the test script or function library. Now we have to write the function body (where it says TODO:) . the second definition causes a syntax error.) 3.g.com Bottom of Form Function Library Example 1 QTP Function Library . Go to File->New->Test. 4. (Now both new test and function library are open at the same time and we are in function library.

In the expert view of the test type: my_name("sachin") 7. it can be accessed from within the function library itself and cannot be accessed from outside of this function library. Private Function my_name_tell(name2) msgbox "Hello " & name2 End Function Public Function my_name(name1) msgbox(name1) my_name_tell(name1) End Function 4. (Save it by giving any name and extension either . (File-> Associate Library with Test) 12. qtp.txt) 11. Finally it will look like: '@Description addition function Public Function my_sum(var1.e. one from the public function and second from the private function.vbs or . Associate it. Save the function library. 2 qtp.9. Go to File->New->Function library.blogspot. it will show two message boxes. 5. In expert view of Associated test type: my_sum 1. 2.qfl (by default) or . 1. One of the functions is public which we will access from the test. Go to File->New->Test.com Bottom of Form Function Library Example 3 .blogspot. Open a new function library.com Bottom of Form Function Library Example 2 QTP Function Library . Associate the function library with the test which is open. When you run it. Save it. var2) sum=var1+var2 msgbox sum End Function 10. Write the below two functions in the function library. Open a new test. One of the functions is private i.Example 2 Another example which uses both public and private functions in the function library. 3.

go to File->'Associate Library with Test' to associate this function library with the already open test. just select New_operation_1 from there."function_1" Save the function library.WinEdit("Attached text:=Name:". var1) ' TODO: add function body here msgbox var1 End Function RegisterUserFunc "WinEdit". Type the name of the function in the 'Function definition' area (I entered function_1). After selecting New_operation_1 just supply one argument to it because while creating the function we provided one argument called var1. just type a new value 'New_operation_1' In the ‘Additional information’ area.e. Let Type and Scope be the default i. Finally it looks like this: '@Description my first operation on WinEdit Public Function function_1(test_object. Click on '+' in the ‘Arguments’ area and type 'var1' under Name to create a new variable and let the Pass Mode be default i. After it is associated go the ‘Expert View’ of the test already open and type: Window("title:=Filght Reservation"). Go to Insert-> Function Definition Generator. ‘Function’ and ‘Public’ respectively. (dot). Open a Function Library. as soon as you press .Example 3 Registering a Function to a test object by creating a new operation Open a new test. "height:=20"). Check the 'Register to a test object' checkbox.e. 'By Value'. the list of operations which WinEdit supports are displayed by default (also called IntelliSense). Once it is saved. Make sure that we are in Function Library.QTP Function Library . After it is copied to the already open library just complete the function body. It copies the whole code it generated in the Preview area to the open library. From Test Object dropdown select 'WinEdit' and in the Operation dropdown instead of selecting one of the values it already shows there. So the final line of code in the Expert View now looks like: . Click Ok. "New_operation_1". type 'my first operation on WinEdit' in Description text box.

It is displayed as an operation in the Keyword View Operation list when that test object is selected from the Item list. but it is not necessary] Just Run the test.com Bottom of Form Function Library Example 4 QTP Function Library . Click on Record. In the ‘Flight Reservation’ window. "height:=20"). "Copy".Window("title:=Filght Reservation"). in the Name text box enter any name. This New_operation_1 will be there for every object of class WinEdit. Stop recording.GetROProperty("text")) Edit.Type micCtrlDwn + "c" + micCtrlUp End Sub RegisterUserFunc "WinEdit". This is just a simple example to show how it works. If in this same test you go to ‘Keyword View’. qtp. But if we do the below steps it surely will show: We will record a simple step in a new action. But here we are not using any Object repository (we are using Descriptive Programming) so we cannot select any object from the Item list as the Object Repository is empty. Len(Edit.Click Edit. "height:=20"). It does nothing for the WinEdit object or anything special. It just displays a message box with the value which we have supplied to it at the time of writing the code. it will show you New_operation_1 under the Operation column.WinEdit("Attached text:=Name:".WinEdit("Attached text:=Name:". go to the row which has 'Name' under item. Now go to the ‘Keyword View’."Copy" . Now insert another new action in this test.Example 4 Below is an example that creates a new copy method for winedit object which copies the data from the text field to clipboard and then shows that data (which is copied to the clipboard) in a message box. Now QTP will not display New_operation_1unless otherwise you associate the library we created earlier to this new test. Now if you open any new test and again type Window("title:=Filght Reservation"). In this ‘Keyword View’.New_operation_1"merry" [You can open Flight Reservation window for this test. Make a single click under Operation column in that row (click where it shows Set) it will show a dropdown and you will be able to see New_operation_1 in that dropdown. (Insert->Call to New Action) Make sure ‘Flight Reservation’ window is open.SetSelection 0.blogspot. In a new library file type: Sub Copy (edit) Edit.

. "Copy" Associate the library with the test as we did earlier.Copy Set objhtml=Createobject("htmlfile") a=objhtml.getdata("text") msgbox a unRegisterUserFunc "WinEdit". you can call the functions in the file only from the current action. and you cannot debug a file that is called using an ExecuteFile statement).vbs.blogspot.winedit("attached text:=Agent Name:"). It will show the value of a as 5 in message box. We will start with a very simple example and go on to elaborate more on ExecuteFile. 3.parentwindow.vbs script as shown below. Now open a new test in QTP and write few lines as below and run the test. I saved it under c:\ as add. qtp. 2. 1. Make sure 'Login' window is open (Start-> All Programs -> QuickTest Professional -> Sample Applications ->Flight). Create a new . Resources pane of Test Settings (File->Settings) dialog (has advantages like files are in global scope –all the actions in a test can use those. In this login window type "sachin" in the Agent Name text field and run the test.clipboarddata.com Bottom of Form ExecuteFile ExecuteFile There are two ways (usually) to associate the library file to a test.Open a new test and type: Dialog("text:=Login").When you run an ExecuteFile statement within an action. ExecuteFile (Local scope . Another way (obviously it uses the first one in some way). can be debugged).

.vbs and QTP test are like as shown below. add the file name to the associated function libraries list in the Resources pane of the Test Settings dialog box. ExecuteFile . Now what do you think it will show (for z) when the test is run. when debugging a test that contains an ExecuteFile statement. In addition to the functions available in the associated function libraries.Important points from QTP Guide. or any of the functions contained in the file. You can also insert ExecuteFile statements within an associated function library.e. ExecuteFile .Above we are using ExecuteFile function to include the add. To make the functions in a VBScript file available to your entire test. When you run your test. you can call the functions in the file only from the current action. You cannot debug a file that is called using an ExecuteFile statement. In addition. When you run an ExecuteFile statement within an action. The ExecuteFile statement utilizes the VBScript ExecuteGlobal statement.Try this Now my add.vbs file we created earlier. After including that file we are calling the function from that file and showing its return value in a message box. the ExecuteFile statement executes all global code in the function library making all definitions in the file available from the global scope of the action's script. the execution marker may not be correctly displayed.the absolute or relative path of the file to execute. one more variable z is added. i. The syntax of ExecuteFile: ExecuteFile File Where File is a string . you can also call a function contained in any function library (or VBscript file) directly from any action using the ExecuteFile function.

And guess what will it show now for the msgbox z if the add.com Bottom of Form .On running this QTP test it will show 7 for msgbox z.blogspot.vbs and QTP test are as below: qtp.

Flight Reservation window opens. Click on Record in QTP to record a new test. GetTOProperty It will Return the value of a particular property for a test object which QTP recorded to identify an object during Run time.Click Window("Flight Reservation").. 3.Dialog("Flights Table"). delete all the lines.Select "Frankfurt" Window("Flight Reservation").. 5.Click Window("Flight Reservation"). Go to Start->All Programs->QuickTest Professional->Sample Applications->Flight 2.WinButton("OK").WinComboBox("Fly From:"). Click Flights. 11. I will show very easy to understand example of GetTOProperty. GetROProperty It will Return the current value (run time value) of the test object property from the object in the application. Enter Date of Flight.WinEdit("Name:"). 8. except one. Click stop in order to stop recording and Save the test. 6. Select value from "Fly From" dropdown.WinButton("FLIGHT"). GetROProperty.Type "120908" Window("Flight Reservation").WinRadioButton("Business").Set "sach" Window("Flight Reservation").Select "Denver" Window("Flight Reservation"). Flights Table window opens. GetROProperty. GetROProperty retrieves the current property value of the object in the application during the test run. GetTOProperties on a radio button object. Below is the Expert View script of above steps: Window("Flight Reservation"). The value is taken from the Object Repository. 10. GetTOProperties GetTOProperties Returns properties and values which QTP has recorded and will use to identify an object at run time. From Class area select Business radio button. 1. which sets the Business radio button as shown below.Set We did all the above steps just to enable the radio buttons in the Class area. . 4. button.QTP GetTOProperty.WinObject("Date of Flight:"). Enter Name. From the above script which QTP recorded in Expert View. Just record a simple test on Flight Reservation application. 7.WinComboBox("Fly To:"). Select value from "Fly To" dropdown. Click Ok 9. GetTOProperty retrieves the values of only those properties that are included in the test object description in Object Repository by QTP.

Value MsgBox Prop_Name & " = " & Prop_Value Next This above code which uses GetTOProperties shows all the properties of Business radio button which QTP recorded in order to identify it.Set Go to Resources (menu)->Object Repository.WinRadioButton("Business").GetTOProperties count_of_prop = a. In the same test delete or comment all of the above code (GetTOProperties) and write the below code for GetROProperty and run the test. set a=Window("Flight Reservation").WinRadioButton("Business"). Click on Business radio button as shown below It will show all the properties which QTP recorded for Business radio button.Window("Flight Reservation"). For GetROProperty & GetTOProperty you have to specify the property whose value you want to retrieve.GetROProperty("checked") msgbox a Select Economy radio button and then run the above code again to see a different value.Name Prop_Value = a(i).Count For i = 0 To count_of_prop .1 Prop_Name = a(i). GetROProperty a=Window("Flight Reservation").WinRadioButton("Business"). Now to view all these properties through a script (and use them later somewhere)use GetTOProperties as below: GetTOProperties Convert the remaining one line in the Expert view like this below and add a For Loop. . Object Repository window opens.

com Bottom of Form QTP SetTOProperty QTP SetTOProperty The SetTOProperty method enables you to modify a property value that QuickTest uses to identify an object. and do not affect the values stored in the test object repository.SetTOProperty Property. Object Repository shows that the text property of button named "7" has a value of 7. any changes you make using the SetTOProperty method apply only during the course of the run session. I added the following lines afterward. a=Window("Flight Reservation").GetTOProperty("text") msgbox a qtp. It recorded the first six lines of the script as seen below. Finally I closed the Calculator. then button (+).WinRadioButton("Business"). The Object Repository window is read-only during record and run sessions.Again in the same test delete or comment all of the above code (GetROProperty) and write the below code for GetTOProperty and run the test. Syntax of SetTOProperty method Object(description). I started Recording in QTP. Because QuickTest refers to the temporary version of the test object during the run session. . I clicked on button (7).WinRadioButton("Business").GetTOProperty("nativeclass") msgbox a a=Window("Flight Reservation").blogspot. GetTOProperty You can view the value for only those properties which QTP recorded for a particular object. then button (3) and finally button (=). Value Example 1 of SetTOProperty I opened a new test in QTP and opened Calculator (Start -> All Programs -> Accessories>Calculator).

Close below statement retrieves a value of the text property of a button named "7" using GetTOProperty from memory.Activate Window("Calculator").WinButton("7").Click Window("Calculator").WinButton("7").GetTOProperty("text") msgbox x After running the above statements the Object Repository will still be the same as it was before running the above statements.WinButton("=").WinButton("3").WinButton("+"). x=Window("Calculator").Click Window("Calculator").GetTOProperty("text") msgbox x the following statement would set the button's (named "7") text property value to seven (remember temporarily) Window("Calculator"). I saved it as a. x=Window("Calculator").'QuickTest refers to the temporary version of the test object during the run session.Click Window("Calculator").WinButton("7").html file.WinButton("7"). (See screenshot above) Example 2 of SetTOProperty Open a new Notepad. "seven" below statement retrieves a value of the text property of a button named "7" using GetTOProperty from memory. Write the below text in the Notepad and save it as . Window("Calculator").Click Window("Calculator").SetTOProperty "text".html .

Click So for this test. It will record the below line of code: Browser("Browser").Link("Link 1").When you open the file in IE it will look like as shown below: Make sure that this above file (a. Stop Recording. Click on Record.html) is open in IE and QTP is open.Page("Page"). Object Repository contains information only for Link 1 as can be seen below: . While recording click on Link 1.

Click Browser("Browser").blogspot.Link("Link 1").Click qtp.Page("Page").Link("Link 1").Page("Page"). it will click on Link 2 although Link 2 is not in Object Repository.Page("Page"). it will show error: Browser("Browser").Back Browser("Browser"). [Object Repository does not contain information on Link 2] Now if you write the below line in this test.Link("Link 2").Link("Link 1").Click But if you use SetTOProperty as below.And now if we run this test it will click only Link 1.Page("Page").SetTOProperty "text".com Bottom of Form Descriptive Programming in QTP . "Link 2" Browser("Browser"). Browser("Browser"). removing the above line (which clicks link 1) and run.

you will better understand it as you read more. So one of the other advantages is you can copy this script and Run this from any other machine (other than on which it was created) and it is supposed to work fine.Whenever you record on any object using QTP. [ I have given Example 1a's recorded version (which uses Object Repository)in Example 1b just for your comparison of the two so that you can better understand both ] Example 1a: uses DP We can describe the object directly by specifying property: =value pairs.WinEdit("AttachedText:=Agent Name:"). Dynamic: We have to add a collection of properties and values to a description object and then provide the statement with the description object's name. TYPE = check box.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4b. that describe the object.close Examle 1b: uses OR . Static is easier but Dynamic provides more power. First let’s take a look at Static: This below example uses Descriptive Programming to open Flight Application and does not use object repository at all. Descriptive Programming is also useful to perform the same operation on several objects with certain matching properties e. We can also instruct QTP to perform methods on objects without referring to the Object Repository. So it’s not a good idea to put these in an Object Repository. Suppose in a web site you have to generate a list of all the customer's email addresses. You don't know how many check boxes will be there based on the geographical information you provided. suppose there are 8 check boxes on a web page with names as chk_1. and flexibility. based on the geographical information you provided and then after the email addresses are provided as checkboxes you have to send a rebate letter to them.Set "sachin" window("Title:=Login"). This is possible with the help of Programmatic descriptions or descriptive programming. who brought iPhone from you. This implies that descriptive programming is very helpful if you want to perform an operation on an object that is not stored in Object Repository.winbutton("Text:=OK"). you can use a Descriptive programming to instruct QTP to perform a Set "ON" method for all objects that fit the description: HTML TAG = input. QTP finds the object in the Object Repository and uses the stored test object’s description to identify the object in your application/website. So in this case. We will see examples of both static and dynamic type of descriptive programming in QTP. QTP adds the test object to the Object Repository.Click window("Title:=Flight Reservation"). efficiency. SystemUtil. While running a test. Descriptive programming can be done in two ways: Static: We provide the set of properties and values. QTP can perform methods on those objects. directly.g.exe" window("Title:=Login").Set "mercury" window("Title:=Login"). Only after the object is found in the Object Repository. For this time just read the script and move on. chk_2 and so on. With the help of Descriptive Programming you can Set these check boxes ON or OFF according to your application needs. If you are dynamically creating test objects during the run session then also Descriptive Programming goes a long way to help you.WinEdit("AttachedText:=Password:").

Set "sachin" .Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.Click window("Title:=Flight Reservation")."".close Now let’s take a look at the dynamic type: .Set "Sachin" QTP tries to locate the WebEdit object based on its name. "Index:=3"). you can use the following statement since it uses programmatic descriptions throughout the entire test object hierarchy: Browser("Title:=Mercury Tours"). since it uses programmatic descriptions from a certain point in the description (starting from the Page object description): Browser("Mercury Tours").Set "sachin" var.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4b. Page.Click Window("Flight Reservation").Set "Sachin" Above line uses Descriptive Programming for all objects like Browser.exe".exe" With window("Title:=Login") .WinEdit("Password:"). window("Title:=Login") is being used several times so we do this: Set var = window("Title:=Login") SystemUtil.Set "sachin" Dialog("Login").Set "Sachin" Above line uses Object Repository for Browser object and Descriptive Programming for Page and WebEdit.Select "File."open" Dialog("Login"). WebEdit("Author"). However. WebEdit.Set "mercury" var. but cannot locate it in the repository because the parent objects were specified using programmatic descriptions.WinEdit("AttachedText:=Agent Name:"). you cannot use the following statement.WinEdit("Agent Name:"). QTP cannot identify the object.WinEdit("AttachedText:=Password:").WinEdit("AttachedText:=Password:").winbutton("Text:=OK").WebEdit("Name:=Author".Exit" Note: When using programmatic descriptions from a specific point within a test object hierarchy.winbutton("Text:=OK").Page("Title:=Mercury Tours"). You can also use the statement below. in the above Example 1a script.WinMenu("Menu"). If the same programmatic description is being used several times then we can assign the object to a variable: E.exe" var.WinEdit("AttachedText:=Agent Name:"). For example.close Or We can use 'With & End With' Statement like below: SystemUtil.WinEdit("Agent Name:").Set "mercury" .Page("Title:=Mercury Tours").Page("Title:=Mercury Tours").Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4b. you must continue to use programmatic descriptions from that point onwards within the same statement. If you specify a test object by its object repository name after other objects in the hierarchy have been specified using programmatic descriptions. since it uses programmatic descriptions for the Browser and Page objects but then attempts to use an object repository name for the WebEdit test object: Browser("Title:=Mercury Tours").WinButton("OK"). "Index:=3").Click End with window("Title:=Flight Reservation").g.Type micTab Dialog("Login").SystemUtil.WebEdit("Name:=Author"."C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\".SetSecure "476a9c021bc5a7422cf5a84ad08503823abcbaae" Dialog("Login").

Set myvar= description. I have just added those in order to make you understand this] SystemUtil.Create() Once Property Object (Myvar) is created.WinEdit(myvar ). This is just an example.Create" statement is used.QuickTest ProfessionalSample Applications. returned properties collection. edit.close Now modifying the above script using Description.In the below script childobjects method is being applied to dialog object and childobjects method uses mydescription property object we created.Create() myvar("AttachedText"). In this Flight reservation window go to File.value=20 myvar("width").count msgbox(a) Just try to understand the above code.exe" window("Title:=Login").Click window("Title:=Flight Reservation").exe" window("Title:=Login").Set "mercury" window("Title:=Login").Click window("Title:=Flight Reservation").Create() mydescription("Class Name").Understand it like this – A Property Object is a property name and value. Creating checkpoints programmatically: . I will straightway show you an example of how to do this: Make sure that Flight Reservation window is open (Start.winbutton("Text:=OK"). We will use this childobjects method to count the checkboxes in this 'Open Order' dialogbox.value=119 SystemUtil.winbutton("Text:=OK").Set "sachin" window("Title:=Login").close Retrieving child objects in Descriptive Programming: There is a ChildObjects method which can be used to get all objects located within a specific parent object or only those that match some criteria for programmatic description. can be specified in a statement.WinEdit("AttachedText:=Password:").Flight)."height:=20".ChildObjects(mydescription) a=Checkboxes. We use Description object to return a Properties collection object containing a set of Property Objects. Set mydescription=Description.WinEdit("AttachedText:=Password:").Programs. in real life you can use this count in some kind of loop. Our example can run without height and width properties. Set Myvar = Description.value="WinCheckBox" Set Checkboxes = window("text:=FLight Reservation").value="Agent Name:" myvar("height").Open Order. For creating Properties collection "Description. In short we first of all need to create a description and then use a particular syntax to retrieve all child objects that match that description and manipulate them according to our own wish.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4b. Then only in place of an object name.Set "sachin" window("Title:=Login").Create.Set "mercury" window("Title:=Login"). statements to add. Lets take a complete example of this: [these extra values (height & width) are not important in our example.dialog("text:=Open Order").WinEdit("AttachedText:=Agent Name:"."width:=119" ). remove and retrieve properties and values to or from properties objects can be entered during the run time.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4b.

For the below script make sure that Flight reservation window is open: a=window("Title:=Flight Reservation"). On the other hand if you use Index:=2 to describe a WebElement object. The value starts with 0." button in Flight Reservation window is enable or disable. regardless of type) because WebElement object is general object that applies to all objects. I have used a message box to show whether it is enable or disable. QTP will search for the third object on the page (it can be any. just open the website (http://newtours..webelement("name:=password".ReportEvent Statement to send the results to the result window of QTP.) As an example. For all the methods and properties of WebElement object please refer QTP User Guide.com/) and make sure the cursor is in the “User Name” text box and write the following line in the Expert View of new test: browser("title:=Welcome: Mercury Tours").Run-time value of a specified object property can be compared with expected value of that property by using programmatic description. [you can see an object's properties and methods from QTP help. can assign a value to test object’s index property to uniquely identify it. In the above line if you do Index:=0 then “hello” will be written in the “User Name” text box."index:=2").WebEdit("Index:=1").' button to check the 'enable' property of the button.demoaut. . Descriptive programming checks are helpful for the object whose properties you want to check but the object is not stored in Object Repository.page("title:=Welcome: Mercury Tours"). DP is also useful in case of programming WebElement objects (A WebElement is a general web object which can represent any web object. while learning an object. QTP will search for the second WebEdit object on a web page. As an example. Definitely there are other ways also to get these].demoaut. QTP also. you can use the Report.page("title:=Welcome: Mercury Tours"). just open the website (http://newtours.com/) and write the following line in the expert view of new test: browser("title:=Welcome: Mercury Tours").GetROProperty("enabled") msgbox (a) If a = True Then msgbox ("button is enable") else msgbox ("button is disable") End If In the above script GetROProperty method is being applied to 'Flight. Index property Index property is useful to identify a test object uniquely. If you use Index:=1 with WebEdit test object. Index property values are specific to an object and also the value is based on the order in which the object appears in the source code. I will show a small example here which checks if the "Flights.Set "hello" This will write “hello” in the “Password” text box.Click It will just click the “Password” text box which just highlights that text box and places the mouse cursor in that box.winbutton("Text:=FLIGHT")..

exe") This example uses Run and CloseProcessByName methods to open and close the application (Notepad).html under c:\) 2. Instead of closing the Notepad with CloseProcessByName method.exe" wait(3) SystemUtil. Open a new blank test in QTP and type the following code: Set myBrowser = Description. (I saved it as First.Close For opening the application we can use complete paths also e.com Bottom of Form How we can parameterize Descriptive Programming statements? Open a new blank Notepad and type <title>Hello World1</title> And save it with .blogspot.g. we can use the below line also which is mostly used. Also enter World1 and World2 in Cell A1 and A2 in Global Sheet.exe" This opens an Internet explorer.html extension. (I saved it as Second.CloseProcessByName("Notepad.html under c:\) 3.Run "C:\Program Files\Internet Explorer\iexplore.Run "Notepad.Last but not the least SystemUtil object SystemUtil object allows you to open and close application by writing its code manually in the Expert view of QTP. .Value("A") Browser(myBrowser).html extension. systemutil.Value = "Hello " & DataTable.Notepad"). Open another new blank notepad and type <title>Hello World2</title> And save it with . window("title:=Untitled . Below example shows how to open or close a Notepad using code: systemutil.close 4. qtp.Create() myBrowser("opentitle").

Highlighting an Object in Your Application etc are couple of features you can’t just resist and of course there are many more).html and Second. Running the test will close both the browsers. there can be many more) . qtp. So we have used data table in this example to parameterize the values. Below you can find some of the differences between object repository and descriptive programming. Above is a very small example that shows how we can data-drive a property value since the browsers have opentitle property values as “Hello World1” and “Hello World2” respectively.blogspot. (Differences between object repository and descriptive programming are not limited to what is shown below. Make sure that both First and Second are visible and run the test.5. 6. There are certain situations when using descriptive programming has its own benefits (with descriptive programming along with other features you also get code portability) while in some other typical situations object repository works like a charm (No need to adjust the script when an object properties change.html in order to open them in Internet Explorer.com Bottom of Form QTP Object Repository Vs Descriptive Programming There is no specific answer as to which of the two (object repository or descriptive programming) is better. Double click on First.

This below example clicks on File ->Open. QTP can also use Smart Identification (if enabled). It uses regular expression in the second line where value of regexpwndtitle in case of Notepad is Notepad and in case of WordPad is WordPad.. Set myobj = Description. You can write the below example in a new test in QTP and make sure either a new Notepad or a WordPad window is open and run the test.com Bottom of Form QTP Descriptive Programming Questions Can Descriptive Programming be used with Smart Identification? Smart Identification works with the help of Object Repository. Descriptive programming statements need to be Object repository in QTP is created put into operation manually. QTP starts with predefined mandatory and assistive properties in that order. How to use regular expressions with descriptive programming? Regular expressions can be used with descriptive programming. menu of either a new blank Notepad or WordPad which ever is open. So I have used regular expression for this where first four dots (. Finding a set of automatically (manual creation is also possible) properties to distinctively identify the object as and when you record on the application.Create() myobj("regexpwndtitle").Select ("<item 1="">.Value = ".[Pp]ad" Window(myobj). applications.<item 2="">") Or . qtp.. Object repository is considered relatively faster It is considered relatively slower to create and if you take into account the performance for performance wise also in case of large large applications.WinMenu("menuobjtype:= 2").. If the mandatory and assistive properties do not uniquely identify an object.blogspot. So the Smart Identification mechanism is not used with Descriptive Programming or Programmatic Description. Let us take a small example.Object Repository With object repository QTP automatically resolves which properties and values are required to uniquely identify an object. although you can use object spy to get help in selecting set of property/value pairs.) correspond to any four characters and after these four characters there can be capital or lower case p and then ad. QTP uses an ordinal identifier. Descriptive Programming With descriptive programming set of property/value pairs are created by you and all are mandatory. In case of Descriptive Programming we bypass the Object Repository. time and again can be time consuming.

Set myobj = Description.Create() myobj("regexpwndtitle"). Now in a new test in QTP type: Browser("text:=Welcome A* .Open… and Ctrl+O Is there a way to use special characters in descriptive programming? Let’s understand this with a very simple example: Open a new blank notepad and type <title>Welcome A*</title>And save it with . . It will show an error.WinMenu("menuobjtype:=2").Microsoft Internet Explorer").Refresh Make sure that “Welcome A*” Internet Explorer window is open.Value = "..html extension as I saved it as sac.Select "File.[Pp]ad" Window(myobj)...Open.. Run the test. Ctrl+O" In this above code there can be issues if there is no proper spacing between File..html under c:\ After it is saved just double click it to open it with Internet Explorer.

Refresh It will work fine.Now rewrite the above line with a backslash “\” in front of * Browser("text:=Welcome A\* .Page("Page").Exist Msgbox a Is it possible to use descriptive programming inside a checkpoint? No it is not possible to use descriptive programming with the checkpoint object as in the below line of code: Browser("Browser").check checkPoint("text:=sometext") .Microsoft Internet Explorer").Microsoft Internet Explorer"). You can try another example: a=Browser("text:=Welcome A\* .

Sign up to vote on this title
UsefulNot useful