问题
In QTP each test object supports the following methods
GetRoProperty
GetToProperty
SetToProperty
GetToProperties
What is the difference between a RO-property and a TO-property and why can I only set a TO-property and not an RO-property?
回答1:
The difference between RO-Properties and TO-Properties are that TO properties refer to the properties as they exist in the Test Object saved in the test (i.e. in the object repository or as described in descriptive programming) and the RO-Properties refer to the RunTime object (i.e. the object as it appears in the Application Under Test (AUT)).
From this distinction a few things arise
- Accessing a TO property doesn't require the AUT to be open
- Accessing an RO property requires the AUT to be open and the object to be uniquely described
- You can set the value of a TO property but not that of an RO property
In addition to the QTP specific properties some technologies also support accessing the native object's properties via the .Object
property of the test object.
回答2:
please find the below difference between GetRoProperty , GetToProperty, GetTOProperties :
GetTOProperty : (Get Test Object Property) : GetTOProperty can be used to fetch a particular test object property from object repository.
GetTOProperties
: GetTOProperties
is used to enumerate all the properties of an object used for identification.
GetROProperty
: (Get Runtime Object Property)
GetROProperty
is used to fetch the property value of an object at runtime.
Let's take an example :
Suppose there is link present on some webpage and we have to verify the text of the link at runtime,
sLinkText = Browser("title:=Google").Page("title:=Google").Link("html tag:=a","visible:=true").GetROProperty("innertext")
msgbox sLinkText
output:
Gmail
Similarly, we can fetch any property of any particular object at run time.
来源:https://stackoverflow.com/questions/8699160/what-is-the-difference-between-ro-properties-and-to-properties-in-qtp