QTP – How to get all Object Indentification Properties?
- Manually
- Programmatically
Use QTP Object Spy to get manually object properties.
I’ve captured properties of ”Advanced Search” link from Google’s page:
It’s possible to get these properties programatically:
- The GetTOProperty and GetTOProperties methods enable you to retrieve a specific property value or all the properties and values that QuickTest uses to identify an object.
- The GetROProperty returns the current value of the test object property from the object in the application.
GetTOProperty differs from the GetROProperty method:
- GetTOProperty returns the value from the test object’s description.
Test Object Properties are stored in the QTP Object Repository. - GetROProperty returns the current property value of the object in the application during the test run.
QTP reads Run-time Object Properties from actual objects during the runnins can be read and accessed during the run session.
That means that when you work with objects using QTP Descriptive Programming (DP), you will be able to access run-time object properties only (using GetROProperty function). Test object properties (using GetTOProperty function) will not be accessed, because QTP DP doesn’t work Object Repository.
There is a problem with Run-time object properties.
In contrast to GetTOProperties (which returns the collection of all properties and values used to identify the test object), GetROPropertiesfunction does NOT exist!
Once again – GetROProperties function does NOT exist!
Well, how to get all Object Indentification Properties of an object?
Answer: We can read them from Windows Registry.
The following registry key contains properties of a given test object:
For example, I’ve opened:
HKEY_LOCAL_MACHINESOFTWAREMercury InteractiveQuickTest ProfessionalMicTestTest ObjectsLinkProperties
- in the object repository description
- in programmatic descriptions
- in checkpoint and output value steps
- and as argument values for the GetTOProperty and GetROProperty methods
So we have to read all Identification Properties from the registry.
This QTP code reads Link Identification Properties:
Set oReg = GetObject(“winmgmts:{impersonationLevel=impersonate}!\.rootdefault:StdRegProv”)
sKeyPath = “SOFTWAREMercury InteractiveQuickTest ProfessionalMicTestTest ObjectsLinkProperties”
oReg.EnumValues HKEY_LOCAL_MACHINE, sKeyPath, arrNames
As a result, arrNames array contains all names of properties.
To prove my words I use this QTP script:
For i = 0 to UBound(arrNames) sNames = sNames & arrNames(i) & vbNewLine
Next
MsgBox sNames
The result is:
So, we can read names of properties.
Next step is to read their values. It can be archived using GetTOProperty or GetROProperty.
Also, I’m going to show how GetTOProperty and GetROProperty work for Test Object (located in QTP Object Repository) and Run-time Object (actual object, created during the run session).
- Properties of Test Object
QTP script is:‘ Link(“Advanced Search”) is an object from QTP Object Repository
Set TestLink = Browser(“Google”).Page(“Google”).Link(“Advanced Search”)sNamesTO = “GetTOProperty for Test Object” & vbNewLine & “Identfication Properties: Values” & vbNewLine
sNamesRO = “GetROProperty for Test Object” & vbNewLine & “Identfication Properties: Values” & vbNewLineFor i = 0 to UBound(arrNames)
sNamesTO = sNamesTO & arrNames(i) & “: “ & TestLink.GetTOProperty(arrNames(i)) & vbNewLine
sNamesRO = sNamesRO & arrNames(i) & “: ” & TestLink.GetROProperty(arrNames(i)) & vbNewLine
NextMsgBox sNamesTO
MsgBox sNamesRO - Test Object Properties of Test Object
Test Object Properties of Test Object and their values are: - Run-time Object Properties of Test ObjectRun-time Object Properties of Test Object and their values are:
Set TestLink = Browser(“Google”).Page(“Google”).Link(“text:=Advanced Search”)
sNamesTO = “GetTOProperty for Run-time Object” & vbNewLine & “Identfication Properties: Values” &vbNewLine
sNamesRO = “GetROProperty for Run-time Object” & vbNewLine & “Identfication Properties: Values” &vbNewLine
For i = 0 to UBound(arrNames)
sNamesTO = sNamesTO & arrNames(i) & “: “ & TestLink.GetTOProperty(arrNames(i)) & vbNewLine
sNamesRO = sNamesRO & arrNames(i) & “: ” & TestLink.GetROProperty(arrNames(i)) & vbNewLine
Next
MsgBox sNamesTO
MsgBox sNamesRO
- Test Object Properties of Run-time ObjectTest Object Properties of Run-time Object and their values are:
- Why almost all properties are empty?
As I said, GetTOProperty function gets values from Test Object, which is stored in QTP Object Repository. Since Run-time Object is a dynamic object, it’s not stored in QTP Object Repository. That’s why GetTOProperty function cannot read object’s properties.
Look at the above screenshot again. The only one property (‘text’) contains its value (‘Advanced Search’). We used this property to create description for our link:
Set TestLink = Browser(“Google”).Page(“Google”).Link(“text:=Advanced Search”)That’s why this Run-time Object contains the only property.
- Run-time Object Properties of Run-time ObjectRun-time Object Properties of Run-time Object and their values are:
During the run session, QTP creates a Run-time copy of Test Object. That’s why Run-time Object Properties were the same for Test Object and Run-time Object.
1 thought on “QTP – How to get all Object Indentification Properties?”
Comments are closed.
I really like reading through a post that can make people think. Also, many thanks for permitting me to comment!
AngularJS Training In Bangalore
Web Designing Training and Placement Institute
Web Development Training Institute in Bangalore Marathahalli
Best Selenium Training in Bangalore Marathahalli
iOS Training In Bangalore
Swift Training in Bangaloe
Java Training In Bangalore
Best Java Institute In Bangalore
UI Development Training In Bangalore
PHP Mysql Training In Bangalore
Best php training in bangalore marathahalli