While developing automation test scripts GetRoProperty method is widely used in UFT to perform various kinds of verifications. In this article, we will see uses of the three inbuilt methods GetRoProperty, SetToProperty, and GetToProperty in UFT.
GetRoProperty in UFT
This is a built-in method in UFT that is used to retrieve the run-time value of an object property from the object in the application.
Syntax
object.GetROProperty (Property Name)
Example: You are supposed to check the default selected value of a WebList object. For this example, I will use the Mercury Tour Demo Application.
Using Object Spy you can look for the required object property that you want to retrieve at run-time from the application.
We can use the “selection” property as it showing the current value of the WebList object. Write the following code to retrieve the value of the selected item from the fromPort WebList box.
1 2 3 |
strListBoxUtem =Browser("Welcome: Mercury Tours").Page("Find a Flight: Mercury").WebList("fromPort").GetROProperty("selection") msgbox strListBoxUtem |
Output
In the message box, the output would be “Acapulco“
SetToProperty in UFT
SetToProperty can be used to set the value of the specified description properties in the test object description that is there in the Object Repository.
Syntax
object.SetTOProperty (Property, Value)
Example: We will Set the HTML ID for fromPort WebList object.
1 |
Browser("Welcome: Mercury Tours").Page("Find a Flight: Mercury").WebList("fromPort").SetTOProperty "html id","123" |
GetToProperty in UFT
GetToProperty is used to retrieve the value of the specified description properties from the test object description.
Syntax
object.GetTOProperty(Property)
1 |
strToProp=Browser("Welcome: Mercury Tours").Page("Find a Flight: Mercury").WebList("fromPort").GetToProperty("html id") |
Difference Between GetRoProperty & GetToProperty
GetRoProperty retrieves the run-time value of an object property from the object in the application. However, GetToProperty retrieves the value of the specified description properties from the test object description that means it retrieves the object property that is stored in the object repository. It can’t return the runtime property of a Test Object from the application.
Let’s understand this with an example. If we spy the object property of fromPort WebList box, its HTML ID property value will be shown as empty.
We will set an “html id” value for it and try to retrieve its value using both GetRoProperty and GetToProperty.
1 2 3 4 5 6 7 8 9 |
Browser("Welcome: Mercury Tours").Page("Find a Flight: Mercury").WebList("fromPort").SetTOProperty "html id","123" strRoProp=Browser("Welcome: Mercury Tours").Page("Find a Flight: Mercury").WebList("fromPort").GetRoProperty("html id") Print "Runtime value of html id: " & strRoProp strToProp=Browser("Welcome: Mercury Tours").Page("Find a Flight: Mercury").WebList("fromPort").GetToProperty("html id") Print "Test Object value of html id: " & strToProp |
If we execute the above code the output will be different for both. The GetRoProperty will return an empty value. However, the GetToProperty will return to value 123.
Recommended Posts
- How to Use Function Definition Generator in UFT
- All You Need to Know about Checkpoints In UFT
- How to Use Visual Relation Identifier in UFT with Example
- DataTable in UFT One | Example of Datatable Methods
- Micro Focus UFT Tutorial – An Overview of UFT
- Web Table Methods in UFT With Example
- Settings.WebPackage Replaytype in UFT
- How to Use XPath in UFT One To Identify Web-Based Objects
- Action Input And Output Parameters In UFT