You are on page 1of 94

Capturing backgroundcolor in QTP

Write the below code (either 1 or 2) in the expert view of a new test and run it. 1) Var=Browser("Title:=Google").Page("Title:=Google").webelement("html tag:=body", "height:=521").object.currentstyle.backgroundcolor msgbox Var OR 2) Var=Browser("Title:=Google").Page("Title:=Google).object.bgcolor msgbox Var

The first code works only with WebElement objects. WebElement object is a general web object that may represent any web object. It is never recorded, although we can use Description Programming with WebElement object to perform methods on any web objects in the website. For example: [Open www.google.com] If you write the below line in the expert view of a new test and Run it, it will click the "I'm Feeling Lucky" button on the google page. Browser("Google").Page("Google_2").WebButton("I'm Feeling Lucky").Click This same above line can be written using webelement object as: Browser("Google").Page("Google_2").Webelement("name:=I'm Feeling Lucky").Click

I think for getting the background color it all depends on the kind of objects you are working with because different applications have different objects which in turn have different properties (read both run-time and test). E.g. below you can see that when I tried to get the properties for a Label with the help of an Object Spy, it does not show any property related to color or BackColor in the Test Object Properties radio button,

but surely shows a BackColor property in Run-time Object Properties radio button. So make sure to check for both run-time and test properties before going to the conclusion that you cannot get the BackColor of an object. I got success with this line: a=SwfWindow(Teller).SwfLabel(window id:=98234).Object.backcolor Msgbox a

So the world does not end at object.currentstyle.backgroundcolor or object.bgcolor or Object.backcolor, just explore it.

QTP GetTOProperty, GetROProperty, GetTOProperties GetTOProperties

Returns properties and values which QTP has recorded and will use to identify an object at run time. GetROProperty It will Return the current value (run time value) of the test object property from the object in the application. GetROProperty retrieves the current property value of the object in the application during the test run. GetTOProperty It will Return the value of a particular property for a test object which QTP recorded to identify an object during Run time. The value is taken from the Object Repository. GetTOProperty retrieves the values of only those properties that are included in the test object description in Object Repository by QTP.

I will show very easy to understand example of GetTOProperty, GetROProperty, GetTOProperties on a radio button object. Just record a simple test on Flight Reservation application. 1. Go to Start->All Programs->QuickTest Professional->Sample Applications->Flight 2. Flight Reservation window opens. 3. Click on Record in QTP to record a new test. 4. Enter Date of Flight. 5. Select value from "Fly From" dropdown. 6. Select value from "Fly To" dropdown. 7. Click Flights... button. 8. Flights Table window opens. Click Ok 9. Enter Name. 10. From Class area select Business radio button. 11. Click stop in order to stop recording and Save the test. Below is the Expert View script of above steps: Window("Flight Reservation").WinObject("Date of Flight:").Type "120908" Window("Flight Reservation").WinComboBox("Fly From:").Select "Denver" Window("Flight Reservation").WinComboBox("Fly To:").Select "Frankfurt" Window("Flight Reservation").WinButton("FLIGHT").Click Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click Window("Flight Reservation").WinEdit("Name:").Set "sach" Window("Flight Reservation").WinRadioButton("Business").Set We did all the above steps just to enable the radio buttons in the Class area.

From the above script which QTP recorded in Expert View, delete all the lines, except one, which sets the Business radio button as shown below. Window("Flight Reservation").WinRadioButton("Business").Set Go to Resources (menu)->Object Repository. Object Repository window opens. Click on Business radio button as shown below

It will show all the properties which QTP recorded for Business radio button. 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. set a=Window("Flight Reservation").WinRadioButton("Business").GetTOProperties count_of_prop = a.Count For i = 0 To count_of_prop - 1 Prop_Name = a(i).Name Prop_Value = a(i).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.

For GetROProperty & GetTOProperty you have to specify the property whose value you want to retrieve. In the same test delete or comment all of the above code (GetTOProperties) and write the below code for GetROProperty and run the test. GetROProperty a=Window("Flight Reservation").WinRadioButton("Business").GetROProperty("checked") msgbox a Select Economy radio button and then run the above code again to see a different value. 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. GetTOProperty You can view the value for only those properties which QTP recorded for a particular object. a=Window("Flight Reservation").WinRadioButton("Business").GetTOProperty("nativeclass") msgbox a a=Window("Flight Reservation").WinRadioButton("Business").GetTOProperty("text") msgbox a

QTP SetTOProperty QTP SetTOProperty The SetTOProperty method enables you to modify a property value that QuickTest uses to identify an object. Because QuickTest refers to the temporary version of the test object during the run session, any changes you make using the SetTOProperty method apply only during the course of the run session, and do not affect the values stored in the test object repository. The Object Repository window is read-only during record and run sessions. Syntax of SetTOProperty method Object(description).SetTOProperty Property, Value

Example 1 of SetTOProperty I opened a new test in QTP and opened Calculator (Start -> All Programs -> Accessories->Calculator). I started Recording in QTP. I clicked on button (7), then button (+), then button (3) and finally button (=). Finally I closed the Calculator. It recorded the first six lines of the script as seen below. I added the following lines afterward. Object Repository shows that the text property of button named "7" has a value of 7.

'QuickTest refers to the temporary version of the test object during the run session.

Window("Calculator").Activate Window("Calculator").WinButton("7").Click Window("Calculator").WinButton("+").Click Window("Calculator").WinButton("3").Click Window("Calculator").WinButton("=").Click Window("Calculator").Close below statement retrieves a value of the text property of a button named "7" using GetTOProperty from memory. x=Window("Calculator").WinButton("7").GetTOProperty("text") msgbox x

the following statement would set the button's (named "7") text property value to seven (remember temporarily) Window("Calculator").WinButton("7").SetTOProperty "text", "seven" below statement retrieves a value of the text property of a button named "7" using GetTOProperty from memory. x=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. (See screenshot above) Example 2 of SetTOProperty Open a new Notepad. Write the below text in the Notepad and save it as .html file. I saved it as a.html

When you open the file in IE it will look like as shown below:

Make sure that this above file (a.html) is open in IE and QTP is open. Click on Record. While recording click on Link 1.

Stop Recording. It will record the below line of code: Browser("Browser").Page("Page").Link("Link 1").Click So for this test, Object Repository contains information only for Link 1 as can be seen below:

And now if we run this test it will click only Link 1. [Object Repository does not contain information on Link 2] Now if you write the below line in this test, removing the above line (which clicks link 1) and run, it will show error: Browser("Browser").Page("Page").Link("Link 2").Click

But if you use SetTOProperty as below, it will click on Link 2 although Link 2 is not in Object Repository. Browser("Browser").Page("Page").Link("Link 1").Click Browser("Browser").Back

Browser("Browser").Page("Page").Link("Link 1").SetTOProperty "text", "Link 2" Browser("Browser").Page("Page").Link("Link 1").Click

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. By default, it will have Action1. Go to Insert (Menu) -> Call to New Action, to add a new action at the end of the test. Now we have Action1 and Action2 in this test. In the Keyword View, right click on Action1 and choose Action Properties. Go to Parameters tab and create input variable in_a1_1 with Type as Number. Rest everything be default. (To create an input variable, you have to click on + sign which is on the right hand side of Input parameters section). Create another input variable in_a1_2, same as above. In the Parameters tab, also create one output variable out_a1_1 with Type as Number (To create an output variable, you have to click on + sign which is on the right hand side of Output parameters section). 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, it may give you a warning that it will make Action1 reusable, just click on Ok) RunAction "Action1", oneIteration, 2,2, 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.

QTP Action input output parameters Example 2 Action output value (value returned by a called action) can be stored in data table column. Open a new test. By default, it will have Action1. Go to Insert (Menu) -> Call to New Action, to add a new action at the end of the test. Now we have Action1 and Action2 in this test. In the Keyword View, right click on Action1 and choose Action Properties. Go to Parameters tab and create input variable in_a1_1 with Type as Number. Rest everything be default. (To create an input variable, you have to click on + sign which is on the right hand side of Input parameters section). Create another input variable in_a1_2, same as above. In the Parameters tab, also create one output variable out_a1_1 with Type as Number (To create an output variable, you have to click on + sign which is on the right hand side of Output parameters section). 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, it may give you a warning that it will make Action1 reusable, just click on Ok) RunAction"Action1", oneIteration, 2, 2, DataTable("Action1_out",dtGlobalSheet) In the Global Data Sheet, where you have column names as A, B and so on, double click on A, It will open Change Parameter Name box, Enter the parameter name as Action1_out and click Ok. 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.

QTP Action input output parameters Example 3 Action output value (value returned by a called action) can be stored in environment variable. Open a new test. By default, it will have Action1. Go to Insert (Menu) -> Call to New Action, to add a new action at the end of the test. Now we have Action1 and Action2 in this test. In the Keyword View, right click on Action1 and choose Action Properties. Go to Parameters tab and create input variable in_a1_1 with Type as Number. Rest everything be default. (To create an input variable, you have to click on + sign which is on the right hand side of Input parameters section). Create another input variable in_a1_2, same as above. In the Parameters tab, also create one output variable out_a1_1 with Type as Number (To create an output variable, you have to click on + sign which is on the right hand side of Output parameters section). 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, Environment tab, in the 'Variable type' dropdown choose User-defined. Click on the + sign which is on the right side. Add New Environment Parameter window opens. Enter the Name of the parameter as env_var and let the 'Value' field be empty and click on Ok. In the Expert view of Action2 type: (When you copy this below code in Expert view of Action2, it may give you a warning that it will make Action1 reusable, just click on Ok) RunAction "Action1", oneIteration, 2, 2, Environment ("env_var") msgbox Environment ("env_var") 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.

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. Open a new test. By default it will have Action1. Go to Insert-> Call to New Action, to add a new action at the end of the test. Now we have Action1 and Action2 in this test. In the Keyword View, right click on Action1 and choose Action Properties. Go to Parameters tab and create output variable out_a1_1 with Type as Any. In the Keyword View, right click on Action2 and choose Action Properties. Go to Parameters tab and create input variable in_a2_1 with Type as Any. In the Keyword View, right click on Action1 and choose Action Call Properties. Go to Parameters tab and in the Store In column enter var1. In the Keyword View, right click on Action2 and choose Action Call Properties. Go to Parameters tab and in the Value column enter var1.

In the expert view of Action1 type: Parameter("out_a1_1") = 23 In the expert view of Action2 type: msgbox Parameter(" in_a2_1") Difference between Image & Bitmap Checkpoint

QTP Sync, Wait and Synchronization Synchronization makes available specified amount of time for an object to process prior to moving on to the next step.

Wait is like forcing the QTP to wait for a specified amount of time while synchronization is not a 'forced' wait e.g. whenever a specific page loads QTP moves forward in case of synchronization, but in case of wait, if the wait is for 10 seconds and a webpage loads in 3 seconds then it still waits for 7 seconds. Synchronization is there to take care of the timing problems between QTP and the AUT. Examples where synchronization can be used: For a web page to load. For a button to become enabled or disabled. For client-server communications to finish. Synchronization is possible in many ways: 1) We can insert a synchronization point for example for a progress bar to reach 100%. QTP will generate a WaitProperty statement in the Expert View in case of synchronization.

2) We can use Exist or Wait statements. Exist statements always return a Boolean (0 or 1) value. 3) We can also modify the default amount of time that QTP waits for a Web page to load. (Browser Navigation Timeout, File(menu)-> Settings-> Web tab) 4) When working with tests, we can increase the default timeout settings for a test to instruct QuickTest to allow more time for objects to appear. (Object Synchronization Timeout, File(menu)-> Settings-> Run tab) Synchronization is enabled only during recording. I will be talking about Sync, Wait, WaitProperty-->result of synchronization). Example of Synchronization Make sure that only QTP and Sample Flight application are open. 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 on ok. Enter the Date of flight as tommorrows date. In Fly From choose Denver. In Fly To Choose Frankfurt. Click on Flights... button which is on the R.H.S of the Fly To combo box. Flights Table window open up. Let the first option remains selected in that and just click on ok. It will automatically fill some of the fields. Enter your name in the Name field. Click on Insert Order and let it complete uptill 100% untill you see the 'Insert Done...' text. Go to Insert (menu)-> Synchronisation Point. QTP will be minimized and cursor will take the shape of a hand. Click on that 'Insert Done...' text in the Flight application. 'Object Selection - Synchronization Point' window will open with 'ActiveX: Threed Panel Control.' selected.

Click Ok. 'Add Synchronization Point' window will open. Choose Property name as 'text' and Property value as "Insert Done..." (Don't forget to put those 3 dots, and double quotation marks e.g. " in the Property value text box.) Click Ok. In Flight application go to File (menu)-> New Order. Click Stop in order to stop the recording. This whole process will add WaitProperty. The code in the Expert view looks like this: Window("Flight Reservation").ActiveX("MaskEdBox").Click 1,9 Window("Flight Reservation").ActiveX("MaskEdBox").Type "092407" Window("Flight Reservation").WinComboBox("Fly From:").Select "Denver" Window("Flight Reservation").WinComboBox("Fly To:").Select "Frankfurt" Window("Flight Reservation").WinButton("FLIGHT").Click Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click Window("Flight Reservation").WinEdit("Name:").Set "axc" Window("Flight Reservation").WinButton("Insert Order").Click Window("Flight Reservation").ActiveX("Threed Panel Control").WaitProperty "text", "Insert Done...", 10000 Window("Flight Reservation").WinButton("Button").Click I have modified the above script a little bit to capture the WaitProperty value. WaitProperty Waits until the particular object property attain the specified value or exceeds the specified timeout before continuing to the next step. Reporter is an Object used for sending info to test results and it uses ReportEvent method to accomplish this. ReportEvent method sends the results to the result window. For more info on these plase see QTP help. Window("Flight Reservation").ActiveX("MaskEdBox").Click 1,9 Window("Flight Reservation").ActiveX("MaskEdBox").Type "092407" Window("Flight Reservation").WinComboBox("Fly From:").Select "Denver" Window("Flight Reservation").WinComboBox("Fly To:").Select "Frankfurt" Window("Flight Reservation").WinButton("FLIGHT").Click Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click Window("Flight Reservation").WinEdit("Name:").Set "axc" Window("Flight Reservation").WinButton("Insert Order").Click

rc=Window("Flight Reservation").ActiveX("Threed Panel Control").WaitProperty ("text", "Insert Done...", 10000) If rc=true Then reporter.ReportEvent micPass,"sync on Insert Done...", "Property of text is true" End If msgbox rc Window("Flight Reservation").WinButton("Button").Click Example of WAIT It is a simple forcible wait. Make sure that only QTP should be open. 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 on ok. Go to Start->AllPrograms->QuickTest Professional->Sample Applications->Flight. Enter Username as your first name (make sure to enter 4 or more characters). (use tab to move to password textbox.) Enter password as 'mercury.' Click Ok. When Flight Reservation window is open, go to File(Menu)->Exit. 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).

1)SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","open" 2) Dialog("Login").WinEdit("Agent Name:").Set "sachin" 3) Dialog("Login").WinEdit("Agent Name:").Type micTab 4) wait(5) 5)Dialog("Login").WinEdit("Password:").SetSecure "46ed14b628c7ae93e3a3ab35576f08fc424a6fb9" 6) Dialog("Login").WinButton("OK").Click 7) Window("Flight Reservation").WinMenu("Menu").Select "File;Exit" Example of Sync Make sure that your internet is On and QTP is open.

Click on Record. When we click on Record, "Record and Run Settings" window opens up. Go to "Web" tab and choose first option "Record and run test on any open browser." and click on ok. Open internet explorer (make sure your default page is www.google.com, so that when you open internet explorer, it by default opens google.com as homepage..) Type Blogger in the search text box and click on "I'm Feeling Lucky" button instead of Search button. When www.blogger.com is open (i.e. when you see 'Done' on the status bar at the bottom) , click on Back toolbar button (below File menu) to go back to google.com again. Go toFile(Menu)->Exit. It will record the following code with sync automatically recorded by QTP (see 4th step).

1)SystemUtil\Program files\Internet Explorer\IEXPLORE.EXE","","C:\Documents and Settings\Sachin","open" 2) Browser("Google").Page("Google").WebEdit("q").Set "blogger" 3) Browser("Google").Page("Google").WebButton("I'm Feeling Lucky").Click 4) Browser("Google").Page("Blogger: Create your Blog").Sync 5) Browser("Google").Back 6) Browser("Google").WinToolbar("ToolbarWindow32").Press "&File" 7) Browser("Google").WinMenu("ContextMenu").Select "Close" Try to run this code, it works fine. Now go to File(Menu)->Settings, Web tab and change the 'Browser navigation Timeout' to 2 seconds for example and then run the above code again. 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, which is too short for a browser to complete the navigation i.e. to open www.blogger.com after clicking on "I'm Feeling Lucky" button (I am not on T1 lines, my internet connection is average), because what happens is, after the 3rd step it just waits for 2 second after which it goes to the Back button, but it finds it disabled as it gets enabled only when www.blogger.com is open. 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". QTP Test parameters 1. Open a New Test. 2. Go to File->Settings, a 'Test Settings' window will open, go to 'Parameters' Tab. 3. Click on '+' sign which is on the top right.

4. Enter the Name of the parameter as 'vartest' and its Default Value as 'hello'. Click Apply and then Ok. The Type of this parameter is string. 5. Above we have created a Test Parameter. 6. Now in the Keyword View right click on Action1 and select 'Action Properties'. 'Action Properties' window opens. 7. Go to 'Parameters' Tab. Click on '+' sign which is on the top right. 8. Enter the Name of the parameter as 'varaction' and its Type as string and no default value. Click Ok to come out of that window. 9. Again in the Keyword View right click on Action1 and select 'Action Call Properties'. 'Action Call Properties' window opens. 10. Go to 'Parameter Values' Tab. There you will see the 'varaction' action parameter we created earlier. Make a single click under 'Value' heading, it will show a button like this <#>. Just click on this button to open 'Value Configuration Options' window. 11. Click on 'Parameter' radio button and select 'Test/action Parameter' from that dropdown. 12. 'Test Parameters' radio button will be selected by default and under 'Test Parameters' radio button select 'vartest' from Parameter dropdown.[ remember this vartest is a test parameter we created at the beginning] 13. When you click on ok to come out of 'Value Configuration Options' window, in the 'Action Call Properties' window, under 'Value' it will show <vartest>. Click Ok. 14. Go to Expert View and type: msgbox(parameter("varaction")) 15. Now run the test. While running it will show 'hello' in the msgbox. This example show how to declare test parameters and how to access those. Remember (taken from QTP guide): 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. To use values supplied for test parameters in steps within an action, you must pass the test parameter to the action containing the step. Alternatively, you can enter the parameter name in the Expert View using the Parameter utility object, in the format: Parameter ("ParameterName)

QTP Environment Variables User-Defined Internal, User-Defined External, Built-in are the types of environment variables available in QTP. Built-in variables as the name suggests are predefined by QTP. Examples of such variables are OS, OSVersion, ActionName which are for Operating System, Operating System Version and name of the action which is currently running, respectively. Lets look at an example of this: 1. Open a new Test. 2.Go to File (Menu)->Settings, a Test Settings window opens. 3. Go to Environment Tab. 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. 4. You can click on any of those variables to see their current value. 5. I just did the above four steps in order to show you from where you can access Built-in variables. 6. Now close this Test Settings window and go to test. 7. In the Expert View type: a = environment("ActionName") & " is running on " & environment("OS") msgbox (a) 8. And Run the test. It is just a simple way to show how a Built-in environment variable works. 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. Lets look at an example of this: 1. Open a new Test. 2. Go to File (Menu)->Settings, a Test Settings window opens. 3. Go to Environment Tab. From Variable type dropdown select User-defined. 4. Click on the '+' which is on the right of Variable type dropdown.

5. 'Add New Environment Parameter' window opens up, type the name and value of the variable e.g. in Name type 'a' and in Value type 'hello' (without quotes, I have added quotes just for clarity) and click on OK. It will add the variable with its type as 'internal'. 6. Click Apply and OK to come out of Test Settings window. 7. Go to expert view and type: msgbox(environment("a")) 8. Now Run the test. It will show you the value of variable 'a' in the message box. User-Defined external variables are the variables which are defined in the file outside of test. These act as read only for the test. You can create as many files for environment variables as you want and choose them for your 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 .xml extension. ( I saved it in 'tests' folder in the 'QuickTest Professional' folder under C:\Program files.)

1. Open a new Test. 2. Go to File (Menu)->Settings, a Test Settingswindow opens. 3. Go to Environment Tab. From Variable type dropdown select User-defined. 4. Click on "Load variables and values from external file" check box and import that external xml file that we created above. 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, Value and Type heading (in our case it will show Address under Name, 25 yellow Road under Value and External under Type). 5. Click on Apply and Ok to come out of it. 6. Go to expert view and type: msgbox(environment("Address")) 7. Now run the test. It will show you the value of variable 'Address' in the message box. 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. There are many different ways in which you can use Random numbers in QTP. Lets jump at the examples straightway.

Example 1: 1. Open a new test. 2. In the keyword View right-click on Action1, select Action Properties, 'Action Properties' window opens, Go to 'Parameters' Tab. 3. In the 'Input Parameters' area click on the '+' sign and enter the Name of the input parameter as 'a', Type as Number, and Default value as 1. Click Ok. 4. Again right-click on Action1 in the keyword View , select 'Action Call Properties', 'Action Call Properties' window opens. Go to 'Parameter Values' Tab. 5. Make a single click under 'Value' column in the 'Input Parameter's' area, it will become a button '<#>'. Click on this button. 6. It will open 'Value Configuration Options' window. 7. Click on 'Parameter' radio button, select 'Random Number' from the dropdown. In the Numeric Range enter 0 against From and 100 against To. 8. Click on Name Checkbox and choose arg_a from the dropdown. 9. In the 'Generate New Random Number' area, select first option-For each action iteration. Click ok. 10. Again Click ok to come out of 'Action Call Properties' window. 11. Now Go to Insert (Menu)-> Call to New Action, 'Insert Call to New Action' window opens, click ok to insert a new action- action2. 12. Go to Expert view of action1 and type: msgbox "action1" msgbox(parameter("a")) 13. Go to Expert View of Action2 and type:

For i=1 to 3 RunAction "Action1", oneIteration, RandomNumber("arg_a") Next 14. When you copy the above text to Expert View of Action2, it will show you a message that it has made Action1 Reusable, just click ok. 15. Now Run the test.

(It would be better if you run it by activating the expert view, 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. 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. If we select the second option 'For each test iteration' then a message box will show same values, but different values if you run it next time i.e. a different value at each test run.) RandomNumber is an Object. RandomNumber(ParameterNameOrStartNumber [,EndNumber]) EndNumber is optional above. 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, 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. 1. Open a new test. 2. In the keyword View right-click on Action1, select 'Action Properties', 'Action Properties' window opens, Go to 'Parameters' Tab. 3. In the 'Input Parameters' area click on the '+' sign and enter the Name of the input parameter as 'a', Type as Number, and Default value as 1. Click Ok. 4. Again right-click on Action1 in the keyword View , select 'Action Call Properties', 'Action Call Properties' window opens. Go to 'Parameter Values' Tab. 5. Make a single click under 'Value' column in the 'Input Parameter's' area, it will become a button '<#>'. Click on this button. 6. It will open 'Value Configuration Options' window.

7. Click on 'Parameter' radio button, select 'Random Number' from the dropdown. In the Numeric Range enter 0 against From and 100 against To. 8. Click on 'Name' Checkbox and choose arg_a from the dropdown. 9. In the 'Generate New Random Number' area, select first option-For each action iteration. Click ok. 10. Again Click ok to come out of 'Action Call Properties' window. 11. Now in the Expert View of action1 type: x=RandomNumber("arg_a") msgbox(x) 12. And Run the Test. 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. 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, giving it a new seed value. If the number is omitted, the value returned by the system timer is used as the new seed value. In simple terms Rnd is a function and Randomize is used to initialize this function. If Randomize is not used, the Rnd function (with no arguments) uses the same number as a seed the first time it is called. 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. 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 randomize var1 = Int((6 * Rnd) + 1) ' Generate random value between 1 and 6. MsgBox var1 next Some light on Rnd: The following formula is used to produce a random number in a given range: Int((upperbound - lowerbound + 1) * Rnd + lowerbound)

likewise 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.

Rnd(number)If the number is Less than zero (< 0) then Rnd generates 'The same number' every time, using number as the seed.

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.

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.'

For i= 1 to 3 x=rnd() msgbox(x) Next Remember: For any given initial seed, 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. Before calling Rnd, use the Randomize statement without an argument to initialize the random-number generator with a seed based on the system timer. QTP Global & Action Data Sheet Parameters Example 1 How, for each row, in global data sheet, QTP iterates all rows of any action data sheet. 1. Open a new Test. 2. Click on Record. 3.Go to Start->All Programs->QuickTest Professional->Sample Applications->Flight. 4. Enter the Agent Name as 'mary' and Password as 'mercury'. Click Ok (make sure we click ok with mouse and not hit the return (enter) Key.)

5. When the Flight Reservation window is open, go to File->Exit. 6. Click Stop in order to stop recording the test. 7. In the Keyword View under 'Value' column, make a single click on 'mary' (Agent Name), a button like <#> will appear, click on this button to open 'Value Configuration Options' window. 8. Click on Parameter radio button and select Data Table from the dropdown and let rest everything be default. click ok to come out of that window.

9. In the Global Data sheet it will add a new columns with 'mary' as its first value. 10. Go to Insert (menu) -> Call to New Action to insert action2.

11. For this action2, repeat steps from 2 to 7. (This time I have used the Agent Name as 'bill') 12. After repeating step 7, when you click on 'Parameter' radio button and select Data Table from the dropdown, make sure you select Current action sheet (local) in the Location in Data Table area. Click Ok to close that window. 13. It will add a new column in action2 Data Sheet with 'bill ' (because I used bill as an Agent Name ) as its first row. 14. Now you have two actions (action1 and action2), both of them do the same job but their data is in different sheets. 15. Go to Global Data Sheet and Add one more row in it below 'mary'. I added 'rama'. 16. In the Local Data Sheet (action2) add two more rows to make them a total of 3. I added 'amar' and 'Sumit'. 17. Right click on action1 and select action call properties, go to Run Tab and select "Run on all rows" radio button. Do the same for action2. 18. Go to Expert View of action one and type : msgbox("acton1"). Now my action1 looks like this:

SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","open" Dialog("Login").WinEdit("Agent Name:").Set DataTable("p_Text", dtGlobalSheet) Dialog("Login").WinEdit("Agent Name:").Type micTab Dialog("Login").WinEdit("Password:").SetSecure "4725bcebeea3b6682d186bf7b15ae92cc4e6c0ba" msgbox("acton1") Dialog("Login").WinButton("OK").Click Window("Flight Reservation").WinMenu("Menu").Select "File;Exit"

19. Do the same for action2 and type msgbox("acton2") in its Expert view, as we did for action1. 20. Now Run the test. 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, otherwise it will be fast and some people may not able to understand.

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. Open a new test. Insert two actions. In the Global Data table, in cell(A,1) type 'Global Data'. In the Action1 Data table, in cell(A,1) type 'Action1 Data'. In the Action2 Data table, in cell(A,1) type 'Action2 Data'. In Expert View of action1 type: msgbox("I am in action 1") rc = DataTable.Value("A", dtGlobalSheet) 'accessing data from Global data sheet from action1 msgbox rc rc = DataTable.Value("A", 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.Value("A", dtGlobalSheet) 'accessing data from Global data sheet from action1 msgbox rc rc = DataTable.Value("A", 2) 'accessing data from action1 data sheet from action2 msgbox rc QTP Action Parameter 1. In the Keyword View right click on Action1 and select 'Action Properties'. 'Action Properties' window opens. 2. Go to 'Parameters' Tab. Click on '+' sign which is on the top right. 3. Enter the Name of the parameter as 'a' and its Type as Number. In the same way create another Number parameter 'b'. 4. Click Ok.

5. In the Keyword View right click on Action1 and select 'Action Properties'. 'Action Properties' window opens. In the general tab, click on 'Reusable Action' checkbox at the bottom to make the action reusable. 6. In the Expert View of Action1 type: s1=parameter("a") s2=parameter("b") msgbox(s1+s2) 7. Go to Insert (menu)-> Call to New Action. 'Insert Call to New Action' window opens. Just click ok to insert a new action. 8. Make action2 reusable as we did for action1. 9. In the Expert View of action2 type: RunAction "Action1", oneIteration, 2,2 10. In the keyword View right click on action2 and select 'Run from Step', it will show you the sum 4 in msgbox. QTP Output Values This is a very small tutorial on output values, just to make you familiar with the process so that you can start on your own. For complete understanding of Output values please see QTP User Guide. 1. Open a new test and also open a sample Flight application (Flight Reservation window) 2.Make sure that both (new test and Flight Reservation window) are open and visible. 3. Click on Record in order to record a test. 4. Go to Insert (Menu)->Output Value->Standard Output Value. 5. QTP will be minimized and mouse pointer will take the shape of a hand. Click on 'Insert Order' button in 'Flight Reservation window.' 6. "Object Selection - Output Value Properties" window opens with WinButton : Insert Order highlighted. Click Ok. 7. "Output Value Properties" window opens with 'Insert Order' in the Name text field. 8. Click on first checkbox (which is Property enabled and Value False). 9. In the 'Configure Value' area click on Modify button.

10. 'Output Options' window opens. In this window just click Ok. (It creates Insert_Order_enabled_Out column in Global datasheet in Data Table with a Value False in the first row) 11. It will bring you back to "Output Value Properties" window. Now earlier where under Value it was showing False (see step 8) now it will show Insert_Order_enabled_Out. 12. Again Click Ok to come out of this "Output Value Properties" window. 13. Click Stop in order to stop the test. 14. Now it means whatever the value of Insert Order button's Enable Property will be, QTP will show that value in Data Table (under Insert_Order_enabled_Out column) at Run time.

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 show a true value in there at run time. It will also show that captured value in the Results window. These above steps show you how to use output values with Data Table. Below tutorial shows how to use output values with Environment variables. 1. Open a new test and also open a sample Flight application (Flight Reservation window)

2. Make sure that both (new test and Flight Reservation window) are open and visible. 3. Click on Record in order to record a test. 4. Go to Insert (Menu)->Output Value->Standard Output Value. 5. QTP will be minimized and mouse pointer will take the shape of a hand. Click on 'Insert Order' button in Flight Reservation window. 6. "Object Selection - Output Value Properties" window opens with WinButton : Insert Order highlighted. Click Ok. 7. "Output Value Properties" window opens with 'Insert Order' in the Name text field. 8. Click on first checkbox (which is Property enabled and Value False). 9. In the Configure Value area click on Modify button. 10. Output Options window opens. 11. In 'Output Options' window, from 'Output Types' dropdown, select Environment, and click Ok.

12. Now Insert_Order_enabled_out will be User-Defined internal environment variable. 13. Click Ok to come out of this "Output Value Properties" window. (You can check that environment variable by going to File->Settings, Environment Tab and choosing User-Defined from variable type) 14. Just add the below line in the Expert View at the end to see the value of the environment variable. msgbox(environment("Insert_Order_enabled_out")) 15. Now you can Run the test. 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 ). It will show a true value in there at run time. It will also show that captured value in the Results window. Parameterize a Checkpoint You can create a Checkpoint while recording or editing a test. For this tutorial I will take into account Text Checkpoint created through Standard Checkpoint while editing. Open a new test. Click on Record. Go to Start-> All Programs->QuickTest Professional->Sample Applications->Flight. 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. When the Flight Reservation window is open Go to File (menu)->Exit. Click on Stop in order to stop the recording. In the Keyword view go to the row which has "Sachin" under Value column. Right-click anywhere on that row and choose "Insert Standard Checkpoint." "Checkpoint Properties" window opens. Make sure only the Text property is checked which has a value of "Sachin" and rest all of the properties must be unchecked. Just make a single click on Text Property, which you checked above, in order to highlight it and make "Configure Value" area enabled. In this area click on Parameter Radio button. This is all we need to do. [On the right hand side of Parameter Radio button you will see Parameter Options button (which has paper and pen image on it). you can click on it to see the default values QTP has set for us.] In the "Checkpoint Properties" window just click on Ok to come out of it.

It will add a column in the Global Data Sheet with "Sachin" as its first value. Add two more values in the subsequent rows. I added "aaaa" in the 2nd and "bbbb" in the 3rd. Now when we run the test and it opens the window where we need to enter the Agent Name and Password, you have to enter Agent Name all of the 3 times (Just enter the Agent Name, that's it, no Tab key or Return key). Make sure you enter "Sachin" during first time, "aaaa" during second time and so on. We don't need to enter the Password. Remember this is a Text Checkpoint on the "Agent Name" Text field. 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. 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. Descriptive Programming in QTP Whenever you record on any object using QTP, QTP adds the test object to the Object Repository. While running a test, QTP finds the object in the Object Repository and uses the stored test objects description to identify the object in your application/website. Only after the object is found in the Object Repository, QTP can perform methods on those objects. We can also instruct QTP to perform methods on objects without referring to the Object Repository. This is possible with the help of Programmatic descriptions or descriptive programming. 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. Descriptive Programming is also useful to perform the same operation on several objects with certain matching properties e.g. suppose there are 8 check boxes on a web page with names as chk_1, chk_2 and so on. So its not a good idea to put these in an Object Repository. 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. Suppose in a web site you have to generate a list of all the customer's email addresses, who brought iPhone from you, 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. You don't know how many check boxes will be there based on the geographical information you provided. So in this case, 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, TYPE = check box. Descriptive programming can be done in two ways: Static: We provide the set of properties and values, that describe the object, directly. 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.

Static is easier but Dynamic provides more power, efficiency, and flexibility. We will see examples of both static and dynamic type of descriptive programming in QTP. First lets take a look at Static: This below example uses Descriptive Programming to open Flight Application and does not use object repository at all. 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. For this time just read the script and move on, you will better understand it as you read more. [ 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. SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4b.exe" window("Title:=Login").WinEdit("AttachedText:=Agent Name:").Set "sachin" window("Title:=Login").WinEdit("AttachedText:=Password:").Set "mercury" window("Title:=Login").winbutton("Text:=OK").Click window("Title:=Flight Reservation").close Examle 1b: uses OR SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","open" Dialog("Login").WinEdit("Agent Name:").Set "sachin" Dialog("Login").WinEdit("Agent Name:").Type micTab Dialog("Login").WinEdit("Password:").SetSecure "476a9c021bc5a7422cf5a84ad08503823abcbaae" Dialog("Login").WinButton("OK").Click Window("Flight Reservation").WinMenu("Menu").Select "File;Exit" Note: When using programmatic descriptions from a specific point within a test object hierarchy, 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, QTP cannot identify the object. For example, you can use the following statement since it uses programmatic descriptions throughout the entire test object hierarchy: Browser("Title:=Mercury Tours").Page("Title:=Mercury Tours").WebEdit("Name:=Author", "Index:=3").Set "Sachin"

Above line uses Descriptive Programming for all objects like Browser, Page, WebEdit. You can also use the statement below, since it uses programmatic descriptions from a certain point in the description (starting from the Page object description): Browser("Mercury Tours").Page("Title:=Mercury Tours").WebEdit("Name:=Author", "Index:=3").Set "Sachin" Above line uses Object Repository for Browser object and Descriptive Programming for Page and WebEdit. However, you cannot use the following statement, 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").Page("Title:=Mercury Tours"). WebEdit("Author").Set "Sachin" QTP tries to locate the WebEdit object based on its name, but cannot locate it in the repository because the parent objects were specified using programmatic descriptions. If the same programmatic description is being used several times then we can assign the object to a variable: E.g. in the above Example 1a script, window("Title:=Login") is being used several times so we do this: Set var = window("Title:=Login") SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4b.exe" var.WinEdit("AttachedText:=Agent Name:").Set "sachin" var.WinEdit("AttachedText:=Password:").Set "mercury" var.winbutton("Text:=OK").Click window("Title:=Flight Reservation").close Or We can use 'With & End With' Statement like below: SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4b.exe" With window("Title:=Login") .WinEdit("AttachedText:=Agent Name:").Set "sachin" .WinEdit("AttachedText:=Password:").Set "mercury" .winbutton("Text:=OK").Click End with window("Title:=Flight Reservation").close Now lets take a look at the dynamic type:

Understand it like this A Property Object is a property name and value. We use Description object to return a Properties collection object containing a set of Property Objects. Then only in place of an object name, returned properties collection, can be specified in a statement. For creating Properties collection "Description.Create" statement is used.

Set Myvar = Description.Create() Once Property Object (Myvar) is created, statements to add, edit, remove and retrieve properties and values to or from properties objects can be entered during the run time. Lets take a complete example of this: [these extra values (height & width) are not important in our example. Our example can run without height and width properties. I have just added those in order to make you understand this] SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4b.exe" window("Title:=Login").WinEdit("AttachedText:=Agent Name:","height:=20","width:=119" ).Set "sachin" window("Title:=Login").WinEdit("AttachedText:=Password:").Set "mercury" window("Title:=Login").winbutton("Text:=OK").Click window("Title:=Flight Reservation").close Now modifying the above script using Description.Create. Set myvar= description.Create() myvar("AttachedText").value="Agent Name:" myvar("height").value=20 myvar("width").value=119 SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4b.exe" window("Title:=Login").WinEdit(myvar ).Set "sachin" window("Title:=Login").WinEdit("AttachedText:=Password:").Set "mercury" window("Title:=Login").winbutton("Text:=OK").Click window("Title:=Flight Reservation").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. 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. I will straightway show you an example of how to do this:

Make sure that Flight Reservation window is open (Start- Programs- QuickTest Professional- Sample Applications- Flight). In this Flight reservation window go to File- Open Order. We will use this childobjects method to count the checkboxes in this 'Open Order' dialogbox.In the below script childobjects method is being applied to dialog object and childobjects method uses mydescription property object we created. Set mydescription=Description.Create() mydescription("Class Name").value="WinCheckBox" Set Checkboxes = window("text:=FLight Reservation").dialog("text:=Open Order").ChildObjects(mydescription) a=Checkboxes.count msgbox(a) Just try to understand the above code. This is just an example, in real life you can use this count in some kind of loop. Creating checkpoints programmatically: Run-time value of a specified object property can be compared with expected value of that property by using programmatic description. Descriptive programming checks are helpful for the object whose properties you want to check but the object is not stored in Object Repository. I will show a small example here which checks if the "Flights.." button in Flight Reservation window is enable or disable. I have used a message box to show whether it is enable or disable, you can use the Report.ReportEvent Statement to send the results to the result window of QTP. For the below script make sure that Flight reservation window is open: a=window("Title:=Flight Reservation").winbutton("Text:=FLIGHT").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..' button to check the 'enable' property of the button. [you can see an object's properties and methods from QTP help. Definitely there are other ways also to get these].

DP is also useful in case of programming WebElement objects (A WebElement is a general web object which can represent any web object.) As an example, just open the website (http://newtours.demoaut.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").page("title:=Welcome: Mercury Tours").webelement("name:=password","index:=2").Click It will just click the Password text box which just highlights that text box and places the mouse cursor in that box. For all the methods and properties of WebElement object please refer QTP User Guide. Index property Index property is useful to identify a test object uniquely. QTP also, while learning an object, can assign a value to test objects index property to uniquely identify it. 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. The value starts with 0. If you use Index:=1 with WebEdit test object, QTP will search for the second WebEdit object on a web page. As an example, just open the website (http://newtours.demoaut.com/) and write the following line in the expert view of new test: browser("title:=Welcome: Mercury Tours").page("title:=Welcome: Mercury Tours").WebEdit("Index:=1").Set "hello" This will write hello in the Password text box. In the above line if you do Index:=0 then hello will be written in the User Name text box. On the other hand if you use Index:=2 to describe a WebElement object, QTP will search for the third object on the page (it can be any, regardless of type) because WebElement object is general object that applies to all objects. 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. Below example shows how to open or close a Notepad using code: systemutil.Run "Notepad.exe" wait(3) SystemUtil.CloseProcessByName("Notepad.exe")

This example uses Run and CloseProcessByName methods to open and close the application (Notepad). Instead of closing the Notepad with CloseProcessByName method, we can use the below line also which is mostly used. window("title:=Untitled - Notepad").Close For opening the application we can use complete paths also e.g. systemutil.Run "C:\Program Files\Internet Explorer\iexplore.exe" This opens an Internet explorer. [I would suggest you to understand complete syntax of systemutil.Run from QTP help] QTP Descriptive Programming Questions Can Descriptive Programming be used with Smart Identification? Smart Identification works with the help of Object Repository. In case of Descriptive Programming we bypass the Object Repository. So the Smart Identification mechanism is not used with Descriptive Programming or Programmatic Description. How to use regular expressions with descriptive programming? Regular expressions can be used with descriptive programming. Let us take a small example. This below example clicks on File ->Open, menu of either a new blank Notepad or WordPad which ever is open. 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. 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. So I have used regular expression for this where first four dots (.) correspond to any four characters and after these four characters there can be capital or lower case p and then ad. Set myobj = Description.Create() myobj("regexpwndtitle").Value = "....[Pp]ad" Window(myobj).WinMenu("menuobjtype:= 2").Select ("<item 1="">;<item 2="">") Or Set myobj = Description.Create() myobj("regexpwndtitle").Value = "....[Pp]ad" Window(myobj).WinMenu("menuobjtype:=2").Select "File;Open... Ctrl+O"

In this above code there can be issues if there is no proper spacing between File;Open and Ctrl+O Is there a way to use special characters in descriptive programming? Lets understand this with a very simple example: Open a new blank notepad and type <title>Welcome A*</title>And save it with .html extension as I saved it as sac.html under c:\ After it is saved just double click it to open it with Internet Explorer.

Now in a new test in QTP type: Browser("text:=Welcome A* - Microsoft Internet Explorer").Refresh Make sure that Welcome A* Internet Explorer window is open. Run the test. It will show an error.

Now rewrite the above line with a backslash \ in front of * Browser("text:=Welcome A\* - Microsoft Internet Explorer").Refresh It will work fine. You can try another example: a=Browser("text:=Welcome A\* - Microsoft Internet Explorer").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").Page("Page").check checkPoint("text:=sometext")

QTP Object Repository Vs Descriptive Programming There is no specific answer as to which of the two (object repository or descriptive programming) is better. 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, Highlighting an Object in Your Application etc are couple of features you cant just resist and of course there are many more). Below you can find some of the differences between object repository and descriptive programming. (Differences between object repository and descriptive programming are not limited to what is shown below, there can be many more)

Object Repository

Descriptive Programming

With object repository QTP automatically resolves which properties and values are required to uniquely identify an object. QTP starts with predefined mandatory and assistive properties in that order. If the mandatory and assistive properties do not uniquely identify an object, QTP

With descriptive programming set of property/value pairs are created by you and all are mandatory, although you can use object spy to get help in selecting set of property/value pairs.

uses an ordinal identifier. QTP can also use Smart Identification (if enabled). Object repository in QTP is created automatically Descriptive programming statements need to be (manual creation is also possible) as and when you put into operation manually. Finding a set of properties to distinctively identify the object time record on the application. and again can be time consuming. Object repository is considered relatively faster if you take into account the performance for large applications. It is considered relatively slower to create and performance wise also in case of large applications.

Object Repositories in QTP 9 (QuickTest Professional) 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. In this article I will be talking about Object Repositories to an extent. [For more information on Object Repositories you can see the QTP user guide.] 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 peraction 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. I had one question which I asked in the forum also and still I am unable to get an answer to this: http://www.sqaforums.com/showflat.php?Cat=&Board=UBB20&Number=376862&Searchpage=1&Mai n=376848&Words=+sachxn&topic=&Search=true The answer to the question which I asked above is: 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. We can add the object directly to a Shared Object Repository using the Object Repository Manager, so that it is available in all actions that use this Shared Object Repository. If needed, we can merge test objects from the Local Object Repository into a Shared Object Repository. We can also add objects to a Shared Object Repository while navigating through the application ("Adding Objects Using the Navigate and Learn 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). We can add objects to the object repository using the Add Objects to Local or Add Objects option. We can add objects to the Local Object Repository of the current action by selecting the required object in the Active Screen.

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.

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.

This will help you in understanding the standard checkpoint in QTP more deeply. 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. Lets see a very simple example to accomplish this.

1. Open a new test (Make sure that Flight Reservation Window in open.) 2. Click on Record in order to start recording. 3. Go to Insert->Checkpoint->Standard Checkpoint. (QTP will be minimized and mouse pointer will take the shape of a hand.) 4. Click on the Flights... button which is on the right hand side of Fly To dropdown. 5. Object Selection - Checkpoint Properties window opens, Click OK. 6. Checkpoint Properties window opens, Click OK. (Standard checkpoint will be added) 7. Click Stop in order to stop recording. 8. Go to Resources->Object Repository (OR associated with this particular action will open) 9. Go to File-> Export and Replace Local Objects (Export Object Repository dialog opens) 10. Enter any filename e.g. rep1 and click Save (All the objects in Local Object Repository will be grayed) 11. Close that Object Repository. 12. Save the test as testone.

13. Open a new test and Save it with the Name testtwo. Associate Shared Object Repository Rep1 with it also. (If not already associated) In the keyword view, right click on action 1 and choose Action Properties. Go to Associated Repositories tab. 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.

14. Now (in testtwo) you can see when you go to Insert-> Checkpoint, Existing Checkpoint will be enabled to let you insert any checkpoints already saved to the shared Object Repository (Rep1 in our case).

QTP Tutorials 6 - Database Checkpoint Now we will try out Database checkpoint: using Oracle 9i First of all you have to connect oracle 9i to QTP 9.(before doing any recording)

For this go to Insert -> Checkpoint -> Database Checkpoint.

A Database Query Wizard opens. 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. Click on 'Machine Data Source' Tab Click on New Button. 'Create New Data Source' window opens. Select 'User Data Source' from Select a type of data source. Click Next. It will show all the data source drives it could find. Select Oracle (on my machine it was 'Oracle in OraHome9'). Click Next. Click Finish. It will open 'Oracle ODBC Driver Configuration' window. Enter 'Data Source name' ( I entered "oracle") Enter 'description' (I entered "SQL") Select 'TNS Service Name' ( I selected 'DB02', my oracle database name) from combo box.

Enter userid (I used SCOTT). Click 'Test Connection' Button.It will ask for a Password. Enter your password for Oracle. If successful it will show 'Testing Connection' window with 'Connection Successful' written on it.

This completes our task of Connecting QTP with Oracle.

Now we will record a test.

Open a blank test.

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 on ok. Go to Insert (menu)->Checkpoint->Database Checkpoint A 'Database Query Wizard' opens.

Select ' Specify SQL statement manually' from the Query definition area. Click Next. Click Create. Go to 'Machine Data Source' Tab Select Oracle from data source name. Click Ok. It will open 'Oracle ODBC Driver Connect'

Enter password. Click ok It will come to Database Query Wizard window with 'Connection String' field filled with: "DSN=oracle;UID=SCOTT;PWD=TIGER;DBQ=DB02;DBA =W;APA=T;EXC=F;FEN=T;QTO=T;FRC=10;FDL=10; LOB=T;RST=T;GDE=F;FRL=F;BAM=IfAllSuccessful;MTS=F; MDI=F;CSR=F;FWC=F;PFC=10;TLO=0;" In the SQL Statement area type "select * from emp;". Click Finish. It will open 'Database Checkpoint Properties' window with the result of the query. Click Ok. Click Stop in order to stop the Recording.

In the Expert View, it just adds one line "DbTable("DbTable").Check CheckPoint "DbTable")"

This is the simplest database checkpoint example. Lets run it. Click on Run. ( 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 - default way in which it was installed- nothing special.) 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, in details it will show checked 112 cells (in your case number of cells may differ). It means if you go to the oracle and add or delete any row and run this test again it will fail.) Just try to think how QTP is comparing the expected results with the actual one, with the count of cells. QTP Tutorials 9 - Text Checkpoint Now we will look at the Text Checkpoint: 1. Open a blank test and a web page in offline mode like this below:

2. Click on Record. When we click on Record, "Record and Run Settings" window opens up. Go to "Web" tab and choose first option "Record and run test on any open browser." and click on ok. 3. Go to Insert (menu)->Checkpoint->Text Checkpoint.The mouse pointer will become hand and QTP will be minimized.Click on the first paragraph (which starts with-The page you are looking..) of that web page.

4. "Text Checkpoint Properties" 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. 5. Click on Configure -here you can change your selected text, change before and after text and so on, but for now just click ok. At the bottom of the "Text Checkpoint Properties" window change 'Checkpoint timeout' to 0 seconds. Again Click ok to come out of "Text Checkpoint Properties" window. 6. Click on stop in order to stop recording. 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". On the right hand side it will show you the details. Try to understand those.

QTP Tutorials 5 - Page Checkpoint Page checkpoint:It is for web applications only.Common things to check with this are load time, broken links etc. 1. Open a blank test.

2. Make sure thathttp://www.google.co.in/ is open.(Now only QTP with blank test and www.google.co.in should be open.) 3. Click on Record. When we click on Record, "Record and Run Settings" window opens up. Go to "Web" tab and choose first option "Record and run test on any open browser." and click ok. 4. Go to Insert (menu)->Checkpoint->Standard Checkpoint (or press F12). 5. The mouse pointer will become hand and QTP will be minimized. 6. Click anywhere on the white space on the Google.co.in page. 7. It will Open "Object Selection - Checkpoint Properties" window. Click on 'Page : Google' option which has a page icon on left of it with right corner of the page slightly folded. 8. Click ok. 9. A 'Page Checkpoint Properties' window opens up. Let all the options be default. Click ok. 10. Click on Stop in order to stop the Recording. In the Expert view it will add just one line: Browser("Google").Page("Google").Check CheckPoint("Google") We will explore this line later on. I ran this test by opening www.google.co.in in offline mode (not on internet). 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, it was already open. When you run it, in the results window, on left hand side, 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.google.com it may fail. QTP Tutorials 7 - Bitmap Checkpoint Now we will look at the bitmap checkpoint which is different from the image checkpoint. Make sure that QTP and the Flight application are open. STYLE A 1. Open a blank test.

2. 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. 3. Go to Insert (menu)->Checkpoint->Bitmap Checkpoint 4. Click on the "Fly To" combo box. 5. "Object Selection- Bitmap Checkpoint Properties" window opens up. I will have "WinComboBox:Fly To" highlighted. Click ok 6. It will open "Bitmap Checkpoint Properties" window. 7. Change the "Checkpoint timeout" at the bottom of the window to 0 seconds, so that we will have no wait time while running the test. 8. Click ok. 9. Click stop to stop recording the test. STYLE B Above, after 3rd point, instead of clicking on the "Fly To" combo box, click somewhere in the empty space above the "Fly From" Combo box but below the line, i.e. in the "Flight Schedule" area.

"Object Selection- Bitmap Checkpoint Properties" window opens up. It will have "WinObject:Flight Schedule" highlighted. Click ok It will open "Bitmap Checkpoint Properties" winodow. This time it will have "Flight schedule" area instead of just the "Fly To" combo box. Now click on the "Select Area..." button. Mouse pointer will change so that you can select any area by dragging. Just select "Fly From" combo box by dragging. Change the "Checkpoint timeout" at the bottom of the window to 0 seconds. so that we will have no wait time while running the test. Click ok. Click stop to stop recording the test. Now you can run the test it will pass. To see how it stores the results, just fail the test. If you have recorded in the style A then just select any value in the "Fly To" combo box and then run the test. In the result window on the left hand side when you click on Checkpoint "Fly To:", it will show you the expected bitmap and actual bitmap on the right hand side. (note: it will show that only in case of Failed result) QTP Tutorials 10 - Table Checkpoint In this tutorial we will look at a table Checkpoint just to get familiar with it. Open a blank test and also open a website "http://www.editorial.co.in/software/software-testing-lifecycle.php" in offline mode. This website has a table at the bottom of the page. Click on Record. When we click on Record, "Record and Run Settings" window opens up. Go to "Web" tab and choose first option "Record and run test on any open browser." and click on ok. Go to Insert (menu)->Checkpoint->Standard Checkpoint (or press F12). The mouse pointer will become hand and QTP will be minimized. Click somewhere inside the table. "Object Selection - Checkpoint properties" window opens. Select "WebTable: Software Testing Life Cycle" which has a table icon on its left, where "Software Testing Life Cycle" is the name of the table. Click ok.

'Table Checkpoint properties' window opens. It will show all the rows and columns of the selected table. This time we will not do any extra setting. Just change the Checkpoint timeout at the bottom of this window to 0 seconds and click ok . Click stop in order to stop recording. Run the test and analyze the results in the result window, mainly the checkpoint results to see how QTP verifies the result. We will manipulate test results in later tutorials. QTP Tutorials 11 - Checkpoint Return Value We will use the Standard Checkpoint which we did in tutorial 4. Open that test that contains the standard Checkpoint. In the expert view of the test you will see only one line i.e. Window("Flight Reservation").WinButton("FLIGHT").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, it depends on us whether we capture it or not. Lets now capture it. Declare a variable and catch the return value in that variable: Dim return return = Window("Flight Reservation").WinButton("FLIGHT").Check CheckPoint("FLIGHT") msgbox (return) One thing more we need to do here is that we have to enclose Checkpoint ("FLIGHT") in brackets. So the final version looks like this: Dim return return = Window("Flight Reservation").WinButton("FLIGHT").Check (CheckPoint("FLIGHT")) msgbox (return) Now run the test and see the msgbox appearing with the return value. Difference Between Text & Text Area Checkpoint Text Checkpoint Text Area Checkpoint

Text Checkpoint checks that a text string is Text Area Checkpoint checks that a text string is displayed

displayed in the appropriate place on a Web page or application.

within a defined area in a Windows-based application, according to specified criteria.

You can add a text checkpoint while You can add a text area checkpoint only while recording a recording or editing steps in a Windows- or test on Windows-based applications, such as Standard Web-based application. Windows, Java, Visual Basic, and ActiveX.

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.

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. With the pointing hand click on $110.00 in the above Flights Table. Object Selection window opens. Click OK. Text Checkpoint Properties window opens. (See Screenshot for Text Checkpoint Properties window below). Click Cancel.

Go to Insert (Menu) ->Checkpoint->Text Area Checkpoint QTP will be minimized and the mouse pointer will change into crosshairs. With the crosshairs select $110.00 in the above Flights Table. Object Selection window opens. Click OK. Text Area Checkpoint Properties window opens. (See Screenshot for Text Area Checkpoint Properties window below). Click Cancel.

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, the Checkpoint Summary area displays [complex value] instead of the selected text string. You can then click Configure to view and manipulate the actual selected text for the checkpoint.]

Text Area Checkpoint Properties window:

Now considering both Text and Text Area checkpoints, analyze yourself: Which one is better (if any) and Which one is to be used in which situation?

QTP Regular Expression Example 2 1. Open QTP and a new test. 2. Open Internet Explorer and open this URL http://www.worldtimeserver.com/current_time_in_IN.aspx 3. Click on Record in order to start recording. 4. Go to Insert-> Checkpoint->Text Checkpoint. 5. QTP will be minimized and mouse pointer will change into hand shape. 6. Click on time as shown in below screenshot.

7. Text Checkpoint Properties window will open with the text on which we clicked on, in red color. 8. In this window, on the right hand side of 'Constant' radio button click on pencil and paper button to open "Constant Value Options" button. 9. Check Regular Expression checkbox and in the value field type:(1[012]|[1-9]):[0-5][0-9] (am|pm) . Click OK. Again click Ok to come out of Text Checkpoint Properties window. 10. Click on Stop in order to stop recording. It will record only one line in the expert view: Browser("India current local time").Page("India current local time").Check CheckPoint("India current local time from WorldTimeServer.com") Now you can refresh that website so as to see the current time and run this test again. It should pass. QTP Regular Expression Example 3 1. Open QTP and a new test.

2. Open Internet Explorer and open this URL http://www.worldtimeserver.com/current_time_in_IN.aspx 3. Click on Record in order to start recording. 4. Go to Insert-> Checkpoint->Text Checkpoint. 5. QTP will be minimized and mouse pointer will change into hand shape. 6. Click on time as shown in below screenshot.

7. Text Checkpoint Properties window will open with the text on which we clicked on, in red color. 8. On the right hand side of 'Parameters' radio button, click on that pen and paper icon, to open Parameter Options dialog box. 9. Make sure Parameters Type is Data Table. In the Advanced Configuration area click on Regular Expression checkbox. Click Ok. Again click ok to come out of Text Checkpoint Properties window. 10. Click Stop in order to stop recording. In the expert view it will write this code: Browser("India current local time").Page("India current local time").Check CheckPoint("India current local time from WorldTimeServer.com") In the global data sheet it will add a new column heading "India_current_local_timeChecked_Text" and will add in the first row- the current time. Now in place of this current time enter this (1[012]|[1-9]):[05][0-9] (am|pm) and save it. Run the test. It should work fine. QTP Regular Expression Example 1

[This is just an example using Yahoo mail inbox. Your inbox unread mails may differ from the one shown in this example] 1. Launch QTP and open a new test. 2. Open Internet Explorer. [Now we have QTP with a blank test and Google open.] 3. Click on Record in order to start recording. 4. Copy and paste this URL (https://login.yahoo.com/config/login_verify2?&.src=ym) in the browser's address bar to open Yahoo mail login. 5. Type your user name and password to login to Yahoo mail. 6. When Yahoo mail is open, click on the Inbox link as shown in the screenshot below.

7. Click on Stop in order to stop recording. My recorded code looks like this: Browser("Browser").Page("Page").Sync Browser("Browser").Navigate "https://login.yahoo.com/config/login_verify2?&.src=ym" Browser("Browser").Page("Yahoo! Mail: The best").WebEdit("login").Set "sach2n" Browser("Browser").Page("Yahoo! Mail: The best").WebEdit("passwd").SetSecure "4801a2cbf793b46aad67194b5cbc961c071f" Browser("Browser").Page("Yahoo! Mail: The best").WebButton("Sign In").Click Browser("Browser").Page("Yahoo! Mail - sach2n@yahoo.com").Link("Inbox (6)").Click Now if you don't check any mail in your inbox and log out and then again run this code it will work fine. But if you check any mail like if I check one mail in my inbox then it will be Inbox(5) in the above screen shot, then if I run this code it will fail and show the below error.

Now we will change the above code with the help of regular expression so that it will work even if there is only one unread mail. In QTP go to Resources (menu) ->Object Repository. Object Repository window will open. Now follow the screen shots below.

When you click on the button as in above screen shot it will open 'Value Configuration Options' window. On this window click on Regular Expression check box. When you click on checkbox it will show warning as in the screen shot below. Just click on Yes.

Now in the Constant text box (above screenshot) enter what I have entered "Inbox \([5-6]\)" and click Ok and close Object Repository window. This Regular Expression setting which we have done works for inbox unread mails between 5 and 6 e.g. if your inbox says inbox(5) or inbox(6). Run the test. It passes for me because I had 5 unread mails in my inbox (inbox(5)). You can do this setting according to your convenience e.g. [1-5] for unread mails between 1 and 5 and so on.

Important points you must remember regarding QTP Run Results.


1. The default is that the Test Results window opens at the end of a run. To change this behavior, check (or uncheck) View results when run session ends in the Run tab of Options window (Tools->Options). 2. For a test that does not contain Data Table parameters, the Test Results window shows single test iteration.

On the contrary, if the test contains Data Table parameters, and the test settings are configured to run multiple iterations, the Test Results window displays details for each iteration of the test run. The results are grouped by the actions in the test.

The Run-Time Data Table is also shown in Test Results.

3. The Test Results window displays all aspects of the run session and can include: 3a. A high-level results overview report (pass/fail status)

3b. The data used in all runs

3c. An expandable tree of the steps, specifying exactly where application failures occurred

3d. The exact locations in the test or component where failures occurred

3e. A still image of the state of your application at a particular step. *I intentionally removed r from Denver and made it Denve from the recorded script in order to make it fail]

For setting this go to Tools->Option and go to Run tab. 3f. A movie clip of the state of your application at a particular step or of the entire test or component

For setting this go to Tools->Option and go to Run tab. 3g. Detailed explanations of each step and checkpoint pass or failure, at each stage of the test or component

4 You can view the results of previous runs of the current test or component, and results of other tests or components.

Choose File-> Open from within the Test Results window.

To update the results list after you change the specified test or component path, click Refresh

5 You can filter the information displayed in the Test Results window. In the Test Results window go to View->Filters.

6 When you run your test or component, you can specify a different location to store the results, using the Results Location tab of the Run dialog box. 7 By default, result files for tests are stored in <Test>\<ResultName>\Report. For example C:\Program Files\HP\QuickTest Professional\Tests\Test7\Res1\Report 8 The Test Results window contains a graphic and text summary of the results of a run as well as details of each step in the run. 9 If the Test Results window is not already open choose Automation > Results. 10 You can view the results of an individual iteration, an action, or a step.

Iterations, actions, and steps that contain checkpoints are marked Passed or Failed in the right part of the Test Results window and are identified by the icon or in the tree pane.

Iterations, actions, and steps that ran successfully, but do not contain checkpoints, are marked Done in the right part of the Test Results window. (Not relevant for components)

Steps that were not successful, but did not cause the test or component to stop running, are marked Warning in the right part of the Test Results window and are identified by the icon or

A test, component, iteration, or action containing a step marked Warning may still be labeled Passed or Done.

11 The Test Results window can show results with up to 300 levels in the tree hierarchy. If you have results with more than 300 nested levels, you can view the entire report by manually opening the results.xml file. 12 You can use the Test Results Deletion Tool (Start > Programs > QuickTest Professional > Tools > Test Results Deletion Tool) to view a list of all the test results in a specific location in your file system or in a Quality Center project. You can then delete any test results that you no longer require.

13 You can print test results from the Test Results window. You can select the type of report you want to print, and you can also create and print a customized report. You can preview test results on screen before you print them. 14 You can instruct QuickTest to automatically submit a defect to a Quality Center project for each failed step in your test. You can also manually submit a defect for a specific step to Quality Center directly from within your QuickTest Test Results window. These options are only available when you are connected to a Quality Center project. 15

If the test was run from Quality Center, the name of the test set and the test instance are also shown. Note: A test set is a group of tests selected to achieve specific testing goals. For example, you can create a test set that tests the user interface of the application or the application's performance under stress. You define test sets when working in Quality Center's test run mode. Test instance: Specifies the instance number of the test in the business process test. For example, if the same test is included twice in the business process test, you can view the results of Test instance 1 and Test instance 2.

16 [For use in Expert View] Reporter Object The object used for sending information to the test results. Filter Property Retrieves or sets the current mode for displaying events in the Test Results. You can use this property to completely disable or enable reporting of steps following the statement, or you can indicate that you only want subsequent failed or failed and warning steps to be included in the report. Reporter.Filter retrieves or sets the current mode for displaying events in the Test Results. You can use the Report.Filter method to determine which steps or types of steps are included in the Test Results. You can completely disable or enable reporting of steps following the statement, or you can indicate that you only want subsequent failed or failed and warning steps to be included in the report.

17 [For use in Expert View] ResultsLocation Property: The path in which the run results will be stored. 18

The results of each QuickTest run session are saved in a single .xml file (called results.xml). You can take test result information from the .xml file and use XSL to display the information you require in a customized format (either when printing from within the QuickTest Test Results window, when displaying test results in your own customized results viewer, or when exporting the test results to an HTML file). XSL provides you with the tools to describe exactly which test result information to display and exactly where and how to display, print or export it. You may find it easier to modify the existing .xsl and .css files provided with QuickTest, instead of creating your own customized files from scratch. The files are located in \dat, and are named as follows: PShort.xsl. Specifies the content of the test results report printed, or exported to an HTML file, when you select the Short option in the Print or Export to HTML File dialog boxes. PDetails.xsl. Specifies the content of the test results report printed, or exported to an HTML file, when you select the Detailed option in the Print or Export to HTML File dialog boxes. PSelection.xsl. Specifies the content of the test results report printed, or exported to an HTML file, when you select the Selection option in the Print or Export to HTML File dialog boxes. PResults.css. Specifies the appearance of the test results print preview. This file is referenced by all three .xsl files.

Export QTP test results to HTML file with the help of Registry Editor ->Run.

HKEY_LOCAL_MACHINE->SOFTWARE->Mercury Interactive->QuickTest Professional->Logger->Media>Log.

click on "Active". Change the Value data from 0 to 1.

When you run a test, the results folder that is created by QTP will now contains a Log folder too. This

will contain LogFile.html, which will be the HTML version of the report. Source: http://forums13.itrc.hp.com/service/forums/questionanswer.do?admit=109447627+1231412262014+2 8353475&threadId=1222546 QTP Script 21 - How to Export QuickTest Professional (QTP) test results to HTML file? The results of each QuickTest run session are saved in a single .xml file (called results.xml). As an example C:\Program Files\HP\QuickTest Professional\Tests\Test7\Res1\Report. Here under Report you will see a Results.xml file. This below code will convert this xml file into html file.

Source: http://www.codeproject.com/KB/vbscript/xml2csv.aspx Dim xmlSource Dim xmlXForm Dim strErr Dim strResult

Dim fso, file Dim strPath Const ForWriting = 2

[Source: http://www.ida.liu.se/~TDDB65/laboration/resultat.html

A better approach to retrieving information from XML files is to use an XML parser. An XML parser is, quite simply, software that reads an XML file and makes available the data in it.

We will use a parser that supports the XML Document Object Model (DOM). The DOM defines a standard set of commands that parsers should expose so you can access HTML and XML document content from your programs. An XML parser that supports the DOM will take the data in an XML document and expose it via a set of objects that you can program against.

A DOM for XML is an object model that exposes the contents of an XML document.

There are many ways to use the XML DOM. We will access the DOM by setting a reference to the MSXML type library, provided in Msxml.dll

For example Create an instance of the Parser object like this below

Dim xDoc As MSXML.DOMDocument Set xDoc = New MSXML.DOMDocument

Once you obtain a valid reference, open a file using the Load method.]

Set xmlSource = CreateObject("MSXML.DOMDocument") Set xmlXForm = CreateObject("MSXML.DOMDocument")

[validateOnParse: This property contains a boolean value indicating whether this document should be validated by the parser. The default is true. If false, only well-formed XML will be parsed. The async property specifies whether downloading of an XML file should be handled asynchronously or not. True means that the load() method returns the control to the caller before the download is complete. False means that the download must be completed before the caller gets the control back.]

xmlSource.validateOnParse = True xmlXForm.validateOnParse = True xmlSource.async = False xmlXForm.async = False

Type the path of your own Results.xml file xmlSource.Load "C:\Program Files\HP\QuickTest Professional\Tests\sachin-tr\Res2\Report\Results.xml"

If Err.Number <> 0 Then strErr = Err.Description & vbCrLf strErr = strErr & xmlSource.parseError.reason & " line: " & _ xmlSource.parseError.Line & " col: " & _ xmlSource.parseError.linepos & _ " text: " & xmlSource.parseError.srcText MsgBox strErr, vbCritical, "Error loading the XML" End If

Type the path of your own PDetails.Xsl file

xmlXForm.Load "C:\Program Files\HP\QuickTest Professional\dat\PDetails.Xsl"

If Err.Number <> 0 Then strErr = Err.Description & vbCrLf strErr = strErr & xmlSource.parseError.reason & " line: " & _ xmlSource.parseError.Line & " col: " & _ xmlSource.parseError.linepos & _ " text: " & xmlSource.parseError.srcText MsgBox strErr, vbCritical, "Error loading the Transform" End If

transformNode() method is used to apply the XSL style sheet to the xml document

strResult = xmlSource.transformNode(xmlXForm)

If Err.Number <> 0 Then

strErr = Err.Description & vbCrLf

strErr = strErr & xmlSource.parseError.reason & _ " line: " & xmlSource.parseError.Line & _ " col: " & xmlSource.parseError.linepos & _ " text: " & xmlSource.parseError.srcText MsgBox strErr, vbCritical, "Error executing the Transform"

End If

Set fso = CreateObject("Scripting.FileSystemObject")

This will be the resultant html file strPath = "c:\TestResult.html"

open the file Set file = fso.opentextfile(strPath, ForWriting, True)

write the info to the file

file.write strResult

close and clean up file.Close

QTP WebTable Object


WebTable Object is a table containing a variable number of rows and columns. We will see most of the methods and properties of WebTable object with examples below. Write the below code in a notepad and save it with .html extention. I saved it as "a.html" as can be seen in the below screenshot (in IE). Also note that first checkbox is named as team and second as team1 in the code. Most of the examples below are done using this below table.

CaptureBitmap Method CaptureBitmap will save a screen capture of an object as a .png or .bmp image, depending on the specified file extension at the below mentioned location. Browser("Browser").Page("Page").WebTable("html tag:=TABLE").CaptureBitmap "C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\table.png" You can write the above used browser and page objects in descriptive programming also. If you run the above line on the example table, it will take a screenshot of the WebTable and save it as a .png file in Sample Pictures folder. Check Method Checks whether the actual value of an item matches the expected value. As an example Make sure that both IE with that table and QTP are open . Click record. Go to Insert (Menu) -> Checkpoint-> Standard Checkpoint. Click on checkbox (QTP checkbox). Make sure you click on checkbox and not on text "QTP". Object Selection: Checkpoint Properties Window opens with "WebCheckBox: team" highlighted. Click OK. Checkpoint Properties window opens. Uncheck all checkboxes except "Checked". Click OK. Click Stop in order to stop recording. It recorded this below line :

Browser("Browser").Page("Page").WebCheckBox("team").Check CheckPoint("team") And I changed it to: a= Browser("Browser").Page("Page").WebCheckBox("name:=team").Check (CheckPoint("team")) msgbox a Now you can run the above two lines and see the value of a. If the QTP checkbox is checked it will show True else False. Above you can use Descriptive Programming for all objects also. I have used Descriptive Programming only for WebCheckBox object. CheckProperty Method Checks whether the specified object property achieves the specified value within the specified timeout. Here we are checking if the WebCheckbox objects checked property achieves a value of 1 i.e. if checkbox is checked and in our case it will show True as both checkboxes are checked. 20 is the time in milliseconds. a=Browser("Browser").Page("Page").WebCheckBox("name:=team").CheckProperty ("checked", 1, 20) msgbox a ChildItem Method Returns a test object from the cell by type and index. Here it is returning QTP checkbox and we are clicking it afterwards. Set a = Browser("Browser").Page("Page").WebTable("html tag:=TABLE").ChildItem(2, 1, "WebCheckBox", 0) a.click ChildItemCount Method Returns the number of objects of a specific type in the specified cell. Here it is returning the count of checkboxes. 2 is the row and 1 is the columns below. a=Browser("Browser").Page("Page").WebTable("html tag:=TABLE").ChildItemCount(2, 1, "WebCheckbox") msgbox a ChildObjects Method

Returns the collection of child objects contained within the object. Here it shows the names of all the child objects one by one in a message box. Set a = Browser("Browser").Page("Page").WebTable("html tag:=TABLE").ChildObjects msgbox a.count For i=0 to a.count-1 msgbox i & " " & a(i).getroproperty("name") Next Click Method Clicks the object. Here it is clicking the first checkbox. Browser("Browser").Page("Page").WebTable("html tag:=TABLE").WebCheckBox("name:=team").Click ColumnCount Method Returns the number of columns in the table. Below "2" is the row number. msgbox (Browser("Browser").Page("Page").WebTable("html tag:=TABLE").ColumnCount(2)) FireEvent Method Triggers an event. Here it is firing the onclick event for first checkbox. Browser("Browser").Page("Page").WebTable("html tag:=TABLE").WebCheckBox("name:=team").FireEvent "onclick" GetCellData Method Returns the text contained in the specified cell. msgbox (Browser("Browser").Page("Page").WebTable("html tag:=TABLE").GetCellData(1,1)) GetROProperty Method Returns the current value of the test object property from the object in the application. Checks the checked property of first checkbox and returns it. msgbox Browser("Browser").Page("Page").WebTable("html

tag:=TABLE").WebCheckBox("name:=team").GetROProperty("Checked") GetRowWithCellText Method Returns the number of the first row found that contains a cell with the specified text. See what the below line shows in case of our example WebTable. msgbox Browser("Browser").Page("Page").WebTable("html tag:=TABLE").GetRowWithCellText("Hello") GetTOProperties Method Returns the collection of properties and values used to identify the object. Below code runs for first checkbox and return its name and value as seen below in the screenshot. Set a= Browser("Browser").Page("Page").WebTable("html tag:=TABLE").WebCheckBox("name:=team").GetTOProperties msgbox a.count For i=0 to a.count-1 msgbox (a(i).Name & " " & a(i).value) Next

GetTOProperty Method Returns the value of the specified property from the test object description. Clearly understand the difference between this and above method. Below line will show "team" in the message box when run. msgbox Browser("Browser").Page("Page").WebTable("html

tag:=TABLE").WebCheckBox("name:=team").GetTOProperty("name") Output Method Retrieves the current value of an item and stores it in a specified location. Below example shows retrieving the value and storing it in runtime data table. Make sure that both IE with that table and QTP are open. Click record. Go to Insert (Menu) -> Output Value-> Standard Output Value. Click on checkbox (QTP checkbox). Make sure you click on checkbox and not on text "QTP". Object Selection: Output Value Properties Window opens with "WebCheckBox: team" highlighted. Click OK. Output Value Properties window opens. Uncheck all checkboxes except "Checked". Click OK. Click Stop in order to stop recording. It recorded this below line: Browser("Browser").Page("Page").WebCheckBox("name:=team").Output CheckPoint("team_3") And I changed it to: Browser("Browser").Page("Page").WebCheckBox("name:=team").Output CheckPoint("team_3") msgbox a I just added the message box line so that you can see the runtime value of "QTP Checkbox" in the Global data sheet, otherwise there is no need of message box. Now you can run the above two lines and see the value of checkbox in Global data sheet. If the QTP checkbox is checked it will show 1, else 0. See DataTable in the below screenshot:

RowCount Method Returns the number of rows in the table. msgbox Browser("Browser").Page("Page").WebTable("html tag:=TABLE").RowCount ToString Method Returns a string that represents the current test object. Below example shows the name of the test object (checkbox) and its type. a=Browser("Browser").Page("Page").WebCheckBox("name:=team").ToString msgbox a

WaitProperty Method Understand WaitProperty. Submit Method Submits a form. This method simulates pressing the Enter key, while the focus is on the object specified in the statement. Suppose this page is open: http://newtours.demoaut.com/ Now if we run this below code in QTP: Browser("name:=Welcome: Mercury Tours").Page("title:=Welcome: Mercury Tours").Image("alt:=SignIn").Submit Then this below page opens: http://newtours.demoaut.com/mercurysignon.php Drag, Drop Method Drag & Drop Example SetTOProperty Method Understand GetTOProperty & GetTOProperties above and here and try SetTOProperty yourself. Exist Property Checks whether the object currently exists in the open application. a=Browser("Browser").Page("Page").WebCheckBox("name:=team").Exist

If a="True" Then msgbox "True" else msgbox "False" End If msgbox a Object Property Accesses the internal methods and properties of the object. The Object property for Web objects is supported only when running steps on Internet Explorer. It is not supported when working with Netscape Browser or Mozilla Firefox. Below example accesses the checkbox object and then performs click method on it. set a=Browser("Browser").Page("Page").WebCheckBox("name:=team").Object a.click

QTP Edit Menu Shortcut Keys


Edit Menu Commands
Tab Backspace CTRL+Z CTRL+Y CTRL+X CTRL+C CTRL+V DELETE SHIFT+F2 CTRL+ENTER; ALT+ENTER CTRL+ENTER; ALT+ENTER CTRL+ENTER; ALT+ENTER CTRL+F Indents the step according to the tab spacing defined in the Editor Options dialog box. Outdents the step (reduces the indentation) according to the tab spacing defined in the Editor Options dialog box. Reverses the last command or deletes the last entry you typed. Reverses the action of the Undo command. Removes the selection from your document. Copies the selection from your document. Pastes the selection to your document. Deletes the selection from your document. Changes the name of an action. Opens the Comment Properties dialog box for a comment step. Opens the Object Properties dialog box for a selected object. Displays the Report Properties dialog box for a report step. Searches for a specified string. Searches and replaces a specified string. CTRL+H CTRL+G CTRL+B Moves the cursor to a particular line in the test. Creates bookmarks in your script for easy navigation.

CTRL+M CTRL+SHIFT+M ALT+G CTRL+SPACE

Comments out the current row, or selected rows. Removes the comment formatting from the current or selected rows. Navigates to the definition of the selected function. Completes the word when you type the beginning of a VBScript method or object. Displays the syntax of a method.

CTRL+SHIFT+ SPACE CTRL+W CTRL+SHIFT+W Generates With statements for the action displayed in the Expert View. Converts any With statements in the action displayed in the Expert View to regular (singleline) VBScript statements.

QTP Automation Menu Shortcut Keys


Automation Menu Commands
F3 F5 F4 Starts a recording session. Starts a run session from the beginning or from the line at which the session was paused. Stops the recording or run session. Starts a run session from the selected step. CTRL+F5 SHIFT+ALT+F3 CTRL+SHIFT+F3 Starts recording in analog recording mode. Starts recording in low level recording mode.

QTP Debug Menu Shortcut Keys


Debug Menu Commands
F11 F10 SHIFT+F11 CTRL+F10 CTRL+T F9 CTRL+F9 CTRL+SHIFT+F9 Runs only the current line of the script. If the current line calls a method, the method is displayed in the view but is not performed. Runs only the current line of the script. When the current line calls a method, the method is performed in its entirety, but is not displayed in the view. Runs to the end of the method then pauses the run session. (Available only after running a method using Step Into.) Runs until the current step. Adds the selected item to the Watch tab. Sets or clears a breakpoint in the test. Enables or disables a breakpoint in the test. Deletes all breakpoints in the test.

QTP Resources Menu Shortcut Keys


Resources Menu Commands

CTRL+R

Opens the Object Repository window, which displays a tree containing all objects in the current test or component.

QTP Insert Menu Shortcut Keys


Insert Menu Commands
Alt +F12 Opens the Add Existing Checkpoint dialog box, enabling you to insert an existing checkpoint for an object or a table. Note: From the menu option, context-menu option, or toolbar button, you can also insert other types of checkpoints, if available. Opens the Add Existing Output Value dialog box, enabling you to create a standard output value for an object or a table. Note: From the menu option, context-menu option, or toolbar button, you can also insert other types of output values, if available Opens the Checkpoint Properties dialog box, enabling you to create a standard checkpoint for an object or a table. Note: From the menu option, context-menu option, or toolbar button, you can also insert other types of checkpoints, if available. Opens the Output Value Properties dialog box, enabling you to create a standard output value for an object or a table. Note: From the menu option, context-menu option, or toolbar button, you can also insert other types of output values, if available. Opens the Step Generator. Inserts a new step in the Keyword View. Inserts a new step after a conditional or loop block in the Keyword View.

Shift+Ctrl+F12

F12

CTRL+F12

F7 F8; INSERT SHIFT+F8

QTP File Menu Shortcut Keys


File Menu Commands
CTRL+N CTRL+SHIFT+N CTRL+ALT+N SHIFT+ALT+N CTRL+O CTRL+SHIFT+O CTRL+ALT+O SHIFT+ALT+O CTRL+S CTRL+ALT+S CTRL+ALT+I CTRL+ALT+C CTRL+P Creates a new test. Creates a new business component. Creates a new application area. Creates a new function library. Opens an existing test. Opens an existing business or scripted component. Opens an existing application area. Opens an existing function library. Saves the active document. Creates a zip file of the active document. Imports a document from a zip file. Converts a business component to a scripted component. Prints the active document.

QTP Tools Menu Shortcut Keys


Tools Menu Commands
CTRL+7 Checks the syntax of the active document.

QTP Data Table Menu Shortcut Keys


Data Table Menu Commands
CTRL+X CTRL+C CTRL+V CTRL+DEL CTRL+I CTRL+K CTRL+R CTRL+D CTRL+F CTRL+H Cuts the table selection and puts it on the Clipboard. Copies the table selection and puts it on the Clipboard. Pastes the contents of the Clipboard to the current table selection. Clears the contents from the current selection. Inserts empty cells at the location of the current selection. Cells adjacent to the insertion are shifted to make room for the new cells. Deletes the current selection. Cells adjacent to the deleted cells are shifted to fill the space left by the vacated cells. Copies data in the left-most cell of the selected range to all cells to the right of it, within the selected range. Copies data in the top cell of the selected range to all cells below it within the selected range. Finds a cell containing specified text. You can search the table by row or column and specify to match case or find entire cells only. Finds a cell containing specified text and replaces it with different text. You can search the table by row or column and specify to match case and/or to find entire cells only. You can also replace all. Recalculates the selected data in the Data Table. Switches through the Data Table sheets when the Data Table is in focus.

F9 CTRL+PAGE UP/PAGE DOWN

QTP Navigate and Learn Shortcut Keys


You can use the following keyboard shortcuts when learning objects using the Navigate and Learn option:
ENTER CTRL+F Learn Focused Window. Define Object Filter. Help. F1 ESC Return to Object Repository Manager.

QTP Object Repository Merge Tool Shortcut Keys


Performing Object Repository Merge Tool Commands
File Menu Commands
CTRL+N CTRL+S Enables you to specify two object repositories with which to perform a new merge operation. Saves the merged shared object repository.

Navigate Menu Commands


F4 Finds the next difference between objects in the object repositories.

SHIFT+F4 CTRL+F F3 SHIFT+F3

Finds the previous difference between objects in the merged object repositories. Opens the Find dialog box. Finds the next object in the merged object repositories according to the search specifications in the Find dialog box. Finds the previous object in the merged object repositories according to the search specifications in the Find dialog box.

Help Menu Commands


F1 Opens the Object Repository Merge Tool Help.

QTP Object Repository Comparison Tool Shortcut Keys


Performing Object Repository Comparison Tool Commands Using Shortcut Keys
File Menu Commands
CTRL+N Enables you to specify two object repositories on which to perform a new comparison operation.

Navigate Menu Commands


F4 SHIFT+F4 CTRL+F F3 SHIFT+F3 Finds the next difference between objects in the object repositories. Finds the previous difference between objects in the object repositories. Opens the Find dialog box. Finds the next object in the object repositories according to the search specifications in the Find dialog box. Finds the previous object in the object repositories according to the search specifications in the Find dialog box.

Help Menu Commands


F1 Opens the Object Repository Comparison Tool Help.

You might also like