QTP – Extract Runtime Object Property

by seetaram on December 21, 2011

A “Test Engineer” need to validate many values on the application during runtime against a set of test data. To facilitate this, the test automation tools provide functionalities such as checkpoints.

Apart from the eight different checkpoints, the QTP also provides a function called “GetROProperty”.

You might wonder why GetROProperty needs to be used while there are checkpoints functionality is already available. To get the property of an object programmatically during runtime, this function can be utilized. Once we learn how to use GetROProperty, then there is no need to use “text checkpoint”. We can directly retrieve the runtime object property and compare that with the existing test data.

We will execute a sample test scenario against flight application available with QTP.

  1. Login to flight application with appropriate credentials (username: admin / password: mercury)
  2. Fill “Date of Flight”, “Flight From”, and “Flight To” fields
  3. Click on “Flights” button and click OK button on the popup dialog
  4. Click “Insert Order” button
  5. Expected Result: “Insert Done..” should be displayed as well as the new order number

Here in the fifth step, it is possible to verify “Insert Done..” value with the help of checkpoints (i.e. text checkpoint, standard checkpoint, etc) but is it possible to get the “Order No”? The answer would be NO.

Here the GetROProperty function becomes handy. We will create a script for the above test scenario and see how we can utilize this function.

'Script  - "InsertOrder" in the Flight application 
'Username and Password are parameterized through DataTable
'Date, From, and To are also parameterized
' Purpose - Demonstrates usage of GetROProperty
'Author - Seetaram Hegde
'Copyrights - All rights reserved

Dim uname, pwd
SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog("Login").WinEdit("PasswordEdt").SetSecure Crypt.Encrypt(pwd)
'Window("FlightReservationWin").WinMenu("Menu").Select "File;Exit"
msgbox "Status: "&status&"  Order No: "&orderNo

For this script, I have created a shared object repository and associated the object repository with the test action and hence the customized logical names of the objects. One more thing is the test data is parameterized from the data table. We need to change the headers of the columns as “UserName, Password, Date, From, To, Passenger” and fill the appropriate data.

This script clearly demonstrates how we can get the object properties dynamically during execution.

{ 5 comments… read them below or add one }

Debindas August 26, 2012 at 2:47 pm

Hi, Its a great help, but i am getting some issue with the below command:

Suppose the month is January, any date and year (01/25/12). When I insert the same date on the datatable, it takes as “12512”. During Run, QTP takes the value as Month:12(December), date:51(Error), Year:2(Error). Please help me with the situation.


Shreyas December 12, 2012 at 4:38 am

When you enter the date like 01/25/12
then you must write it like ’01/25/12


Priya November 24, 2013 at 6:20 pm

Hi, I am new to uft.

Can you please explain line status=Window(“FlightReservation”).ActiveX(“OrderStatus”).GetROProperty(“text”).
I was trying to create the same script. I am not sure how you got the ActiveX(“OrderStatus”).
Please let me know. Tks


seetaram November 26, 2013 at 6:26 am

Just record the scenario, UFT will generate this code for you.


Vinni November 6, 2015 at 4:02 am

I’ve facing another problem now, where I am unable to extract the innertext/outertext from a WebElement. Though I am able to identify & highlight the WebElement using Object Spy, but when I try extracting its value programmatically, its returning empty string & highlight is also not working.
‘ — My code
Browser(“name:=Cards.*”).Page(“title:=Cards.*”).highlight ‘ —> This works
Browser(“name:=Cards.*”).Page(“title:=Cards.*”).WebElement(“class:=dsk-block”,”html id:=postStatus”).Highlight ‘ —> UFT throws General run error
Msgbox Browser(“name:=Cards.*”).Page(“title:=Cards.*”).WebElement(“class:=dsk-block”,”html id:=postStatus”).GetROProperty(“outertext”) ‘—> Returns blank
Msgbox Browser(“name:=Cards.*”).Page(“title:=Cards.*”).WebElement(“class:=dsk-block”,”html id:=postStatus”).GetROProperty(“innertext”) ‘—> Returns blank

Please let me know, if I am missing something here or you can redirect me to any link for understanding any concept. Will appreciate if you can share any function to retrieve the object values, if you have..

-Thanks in advance,


Leave a Comment

Previous post:

Next post:

Do you want to get updates on the recent articles written? Please subscribe to RSS feed or Email