GetTOproperties, SetTOproperty, GetTOproperty & GetROproperty - methods explained with sample scripts.
Before we get started, I would like to take some time explaining about the TO, RO, Get and Set part of the methods.
TO : Stands for Test Object (The object that we have recorded in our object repository)
RO : Stands for Runt-time Object (The application object we are testing against the object in the Object repository)
Get : Is used to get (return) the current property/ies of a Run-time or a test object.
Set : Is used to set (return) the property of a test object.
GetTOproperties:
This method is used to return get the properties and their corresponding values from the recorded object in our object repository.
The following example explains the usage of GetTOproperties method:
Get TO Properties Script
systemutil.Run "iexplore.exe", "http://www.google.com"
Set oWebEdit=Browser("Google").Page("Google").WebEdit("q") 'Create webedit object
Set TOProperties=oWebEdit.GetTOProperties 'Get TO Properties
For i = 0 to TOProperties.count - 1 'Looping through all the properties
sName=TOProperties(i).Name ' Name of the property
sValue=TOProperties(i).Value 'Value of the property
isRegularExpression=TOProperties(i).RegularExpression 'Is it a Regular expression
Msgbox sName & " -> " & sValue & "->" & isRegularExpression
Next
SetTOproperty :
This method is used to set the value of a particular property of an object in the object repository.
GetTOproperty:
This method is used to get the current value of a property of an object in the object repository. If we had used the SetTOproperty method to change the existing property of an object in the OR, GetTOproperty method would only retrieve the current value of the property (ie, what ever value was set using SetTOproperty).
Note : Whatever value we set during the script execution is not retained after the execution is complete. The values in the OR automatically gets back to what it was at the beginning of the execution just like the run-time data tables.
Set TO Property & Get TO property
oldName = oWebEdit.GetTOProperty("name")
msgbox "Old Name ->" & oldName
oWebEdit.SetTOProperty "name","New Value"
NewName = oWebEdit.GetTOProperty("name")
msgbox "New Name ->" & NewName
GetROProperty:
This method is used to get the runtime value of a property in an application object.
Note : SetROproperty method is not supported by QTP, hence it is unavailable.
Get RO Property
oWebEdit=Browser("Google").Page("Google").WebEdit("q").GetROProperty("value")
msgbox oWebEdit
No comments:
Post a Comment