Monday, December 21, 2009

GetRO,GetTO and SetTO propeties in QTP


GET RO Property:-It is used for getting the runtime objects property's value.
GET TO Property:-It is used for getting the test objects properties value.
SET TO Property:-It is user for setting the test objects properties value temporarly during the execution.
GetROProperty method is used to retrieve the properties of the object in an application.It is very useful method and can be used to retrieve
almost any of the property that can be seen while spying the object with object spy. For Example: To get whether Login button is visible or not.
Val = Browser("browsername").Page("pagename"). WebElement("Login").GetROProperty("visible")
If (val = true) Then
msgbox val
End If
GET TO Property:-It is used for getting the test object property values.
When you are using getTOProperty, you are trying to retrive the test object properties, you are not performing any action on it.
You cannot see it in the results window. you can store this property value in a variable and then display it in the result screen if you want to.
GetTo Property returns the properties and the values that QTP recorded and is used to identify the object at the run time.
Example:
Browser("browsername").Page("pagename").WebEdit("username").Set "username"
val = Browser("browsername").Page("pagename").WebEdit("username").GetTOProperty("name")
msgbox val
//you can use reporter Event for result text
reporter.ReportEvent micPass, "name is : ",val

SET TO Property:- You can use SetTOProperty method of test object.Object(description).SetTOProperty Property, Value - The values of test object properties are used to identify the objects. Sometimes the properties of the object in the application change dynamically.
This Method is used to set the Test object Property's value at run session without affecting value on the Active Screen or in the Object Repository.
Object(Description).SetTOProperty Property,Value
This is for flight application:
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Type "dukeka"
Dialog("Login").WinEdit("Agent Name:").SetTOProperty "attached text","Password:"
Dialog("Login").WinEdit("Agent Name:").SetSecure "mercury"
Dialog("Login").WinButton("OK").Click
Now here my ObjectRepository(OR) does contain only one WinEdit box and that is "Agent Name" only. So what i have done here is reduced the
load on OR by defining the only one editbox and adding the second edit box at run time.
This is for web:
Browser("browsername").Page("pagename").WebEdit("username").Set "username"
Browser("browsername").Page("pagename").WebEdit("username").SetTOProperty "name","password"
Browser("browsername").Page("pagename").WebEdit("username").Set "password"
Browser("browsername").Page("pagename").WebElement("login").Click "submit"