Ad Home

Theme images by kelvinjay. Powered by Blogger.

Travel

Header Ads

Java

Selenium

UFT

Framework

General QA Concept

BDD

» » » 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:

For quick and steady access QTP stored them in registry as well:
The Path would be:
HKEY_CURRENT_USER\Software\Mercury Interactive\QuickTest Professional\MicTest\Test Objects\<<ObjectName>>\Properties
or
HKEY_LOCAL_MACHINE\Software\Mercury Interactive\QuickTest Professional\MicTest\Test Objects\<<ObjectName>>\Properties
depending upon license and installation.
For Browser
HKEY_CURRENT_USER\Software\Mercury Interactive\QuickTest Professional\MicTest\Test Objects\Browser\Properties

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.


GetROProperty:
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.

Example:
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")


Name_of_variable[String]=<Fully Qualified DOM>.ObjectType<Object unique identifier>.getROProperty("Property Name")


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:


Here I have given more example of GetROProperties.
How to get number of links in a page.
Get URL value dynamically.
How to get StatusBar Message
How to get Browser Title
Number of Open Browser in Desktop
How to Capture Tooltips
How to close all browsers
How to Wok with Editbox
Commonly Used Functions in QTP
How too Retrieve element value in QTP

GetTOProperty:
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.

Syntax-
Variable_Name[of type String]=<Fully Qualified DOM>.ObjectType<Object unique identifier>.getTOProperty("Property Name")
Code:
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")

During the use of GetTOProperty, many of us get the error called "Invalid procedure call or argument". Most likely this error comes when we are trying to get property value which is not listed or learnt by QTP during recording time.Use Object Spy to get the correct set of value to be fetched from object property.All it fetches the basic static properties of the test object.


GetTOProperties:
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.
Syntax-
Variable_Name[of type String array]=<Fully Qualified DOM>.ObjectType<Object unique identifier>.getTOProperties

Example:
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


SetTOProperty:
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.
Example:
Say in a page there two links available for a table view.

  1. GoNext-Upon clicking this Application will produce next 10 records
  2. GoPrevious-Upon clicking Application will produce previous 10 records.
So when we recorded,QTP learn about these two objects and stored in Object Repository.Now due to requirement change or any temporary change it becomes "Next" and "Previous". The working mechanism is same. As this is a temporary change so we will not change the Object Repository ,rather we will change the way QTP identifies these object in such case SETTOProperty will be handy. For that we will change the name property of these button.


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
The only thing to remember before applying SETTOProperty is to disable the QTP's Smart Identification mechanism to identify the Object. Secondly,it is done in a encapsulated manner hence the screen (Active) or the Object Repository .So they will remain unchanged.
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.
SetROProperty:
This is not available in QTP. Rather not required at all.During Runtime QTP is going to set the value anyway.This technique is important when QTP can not identify a text filed or some operation which QTP can not perform. We will adopt javascript executor in such case. Few QTP codes say it as SetROProperty. Let us discuss how:
set page=Browser("Google").Page("Google")
'setting the object for page
set googleTextBox=page.RunScript("document.getElementByName('q')(0);")
'Setting the object after finding in DOM
googleTextBox.value="AskQTP"

We can use getElementByID,getElementByXpath etc remember this is for fun and QTP does not have this method.

«
Next
Newer Post
»
Previous
Older Post

No comments:

Leave a Reply