QTP tutorials & interview questions


Search more on QTP here

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


Also See:
QTP SetTOProperty