|What are GetROProperty,GetTOProperty,GetTOProperties and SetTOProperty in QTP?|
Developers develop application with different elements in any technology.They provide or maintain some basic information about the element.
Now While automating such application using QTP, we rely on QTP.It has its own mechanism to identify and learn about such properties of the application.These are standard object properties.
To begin with, let us understand few basic things..
- TO–Test Object[standard]
- RO–Runtime Object[standard]
- Get–To fetch some value [kind of getter]
- Set–To set some value [kind of setter]
|Standard Object identified by QTP|
Mercury now HP has created or defined Test objects according to the supported environment (web,ERP,Java etc).When QTP records an application,it tries to match the same list of properties for an Object and store them in Object Repository.
Navigate to Tools–>Object Identification
you can see the HP given/created Test Object properties:
The Path would be:
HKEY_CURRENT_USERSoftwareMercury InteractiveQuickTest ProfessionalMicTestTest Objects<<ObjectName>>Properties
HKEY_LOCAL_MACHINESoftwareMercury InteractiveQuickTest ProfessionalMicTestTest Objects<<ObjectName>>Properties
depending upon license and installation.
HKEY_CURRENT_USERSoftwareMercury InteractiveQuickTest ProfessionalMicTestTest ObjectsBrowserProperties
However all these properties can be found under Help section of QTP.
In this post I trying to clarify different operation can be made through QTP on these objects.
When we do little advance programming in QTP, We need to fetch the value from the UAT. That becomes a standard requirement in QTP. Fetching value from application during run time was not so easy.QTP’s advance programmer made it easy for all of us.
The technique is named as GetROPropery [Get Run time Object Property]
This command deals with the current value of the element.This can fetch values associated with runtime object.[During execution]. It can only be used on the properties that an element support during execution. Use Object Spy tool to identify compatible properties who’s value can be fetched.We can use Regular expression too.
Browser("Google").Page("Google").WebEdit("q").set "AskQTP" msgbox Browser("Google").Page("Google").WebEdit("q").getROProperty("Value")
It supports descriptive programming as well.
dim class_Name as String class_Name=Browser("name:=Google").Page("title:=Google").WebEdit("name:=q").GetROProperty("nativeclass")
Where we can use it?
Mostly finding combo items,getting title,getting table size,We will be using this methos.
It is bit advanced than standard or text check point.
General syntax is written below:
GetTOProperty can fetch values associated with test object residing in Object Repository.In simple words,this command or function returns the properties and values which QTP has learnt during recording of the flow. It stores all values in Object Repository. During run time, QTP tries to match the same values with application’s object to identify and perform operations..It reads all the value from object description.This can be used instead of standard check point to compare static values.
dim class_Name as String class_Name=Browser("Google").Page("Google").WebEdit("q").GetTOProperty("nativeclass")
It supports descriptive programming as well.
dim class_Name as String class_Name=Browser("name:=Google").Page("title:=Google").WebEdit("name:=q").GetTOProperty("nativeclass")
This is one advanced command or method over GetTOProperty. GetTOProperty deals with a single value. GetTOProperties can fetch multiple properties from a test object.Again the basic is same. These values need to be stored in Object Repository.
dim object_properties as String array dim name as String dim alt as String systemUtil.Run "iexplore.exe","http:/Google.com" 'Open google Set ObjectEditBox=Browser("Google").Page("google").webEdit("q") Set object_properties=ObjectEditBox.GetTOProperties /This will fetch all TOProperties associated with editbox in the form of string array for i=0 to object_properties-1 Name=object_properties(i).Name alt=object_properties(i).alt ... ... Next
This method or command is used to modify a property value that QTP has learnt during record session and stored in Object Library.During recording QTP stores application properties and values in Object repository and during run session it creates a replica of the same.Then,tries to match all the properties and its corresponding values.By SetTOProperty we change the replica version of those object’s property.So it is temporary and valid for each run session. After the run QTP restores the original values.
In this case the yellow box the original properties and values do not get affected.Mostly when there is no way to identify the object and no information available in Object Repository about the object we follow this approach to make QTP understand about the new Object.
Say in a page there two links available for a table view.
- GoNext-Upon clicking this Application will produce next 10 records
- GoPrevious-Upon clicking Application will produce previous 10 records.
Browser("ABC").Page("XYZ").webButton("GONext").SETTOProperty "name","Next" Browser("ABC").Page("XYZ").webButton("GONext").Click Browser("ABC").Page("XYZ").webButton("GOPrevious").SETTOProperty "name","Previous" Browser("ABC").Page("XYZ").webButton("GOPrevious").Click
One more scenario could be , when we need to work with multiple instances of the same page,all objects will be same for this case. So while testing such instance we will be using SETTOProperty to identify them uniquely by providing separate names.
'setting the object for page
'Setting the object after finding in DOM