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.
- Login to flight application with appropriate credentials (username: admin / password: mercury)
- Fill “Date of Flight”, “Flight From”, and “Flight To” fields
- Click on “Flights” button and click OK button on the popup dialog
- Click “Insert Order” button
- 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 uname=DataTable.Value("UserName","Global") pwd=DataTable.Value("Password","Global") SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe" Dialog("Login").WinEdit("AgentNameEdt").Set(uname) Dialog("Login").WinEdit("PasswordEdt").SetSecure Crypt.Encrypt(pwd) Dialog("Login").WinButton("OKBtn").Click 'Window("FlightReservationWin").WinMenu("Menu").Select "File;Exit" Window("FlightReservation").ActiveX("DateOfFlightEdt").Type(DataTable.Value("Date","Global")) Window("FlightReservation").WinComboBox("FlyFromCbx").Select(DataTable.Value("From","Global")) Window("FlightReservation").WinComboBox("FlyToCbx").Select(DataTable.Value("To","Global")) Window("FlightReservation").WinButton("FlightsBtn").Click Window("FlightReservation").Dialog("FlightsTable").WinButton("OKBtn").Click Window("FlightReservation").WinEdit("NameEdt").Type(DataTable.Value("Passenger","Global")) Window("FlightReservation").WinButton("InsertOrderBtn").Click wait(10) status=Window("FlightReservation").ActiveX("OrderStatus").GetROProperty("text") orderNo=Window("FlightReservation").WinEdit("OrderNoEdt").GetROProperty("text") 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.
Hi, Its a great help, but i am getting some issue with the below command:
Window(“FlightReservation”).ActiveX(“DateOfFlightEdt”).Type(DataTable.Value(“Date”,”Global”))
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.
When you enter the date like 01/25/12
then you must write it like ’01/25/12
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
Just record the scenario, UFT will generate this code for you.
Hi,
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,
Vinni!