There are two ways how to get all properties of an object in QuickTest Professional:
I've captured properties of ''Advanced Search" link from Google's page:
GetTOProperty differs from the GetROProperty method:
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_MACHINE\SOFTWARE\Mercury Interactive\QuickTest Professional\MicTest\Test Objects\Link\Properties
- Manually
- Programmatically
I've captured properties of ''Advanced Search" link from Google's page:
So, QTP Object Spy shows these values:
Using QTP Object Spy you can get Run-time Object Properties and Test Object Properties.
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:
HKEY_LOCAL_MACHINE\SOFTWARE\Mercury Interactive\QuickTest Professional\MicTest\Test Objects\_ Test_Object_\Properties
HKEY_LOCAL_MACHINE\SOFTWARE\Mercury Interactive\QuickTest Professional\MicTest\Test Objects\Link\Properties
and I've got properties of Link object:
So we have to read all Identification Properties from the registry.
This QTP code reads Link Identification Properties:
As a result, arrNames array contains all names of properties.
To prove my words I use this QTP script:
Please note that you can find the same Link Identification Properties in QuickTest Professional Help:
QTP Object Identification Properties can be used:
- 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:
Const HKEY_LOCAL_MACHINE = &H80000002
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
sKeyPath = "SOFTWARE\Mercury Interactive\QuickTest Professional\MicTest\Test Objects\Link\Properties"
oReg.EnumValues HKEY_LOCAL_MACHINE, sKeyPath, arrNames
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
sKeyPath = "SOFTWARE\Mercury Interactive\QuickTest Professional\MicTest\Test Objects\Link\Properties"
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:
sNames = "Identfication Properties:" & vbNewLine
For i = 0 to UBound(arrNames) sNames = sNames & arrNames(i) & vbNewLine
Next
MsgBox sNames
The result is:For i = 0 to UBound(arrNames) sNames = sNames & arrNames(i) & vbNewLine
Next
MsgBox sNames
Compare these Link Identification Properties with properties from the registry. They are the same!
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).
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" & 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 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:
2. Properties of Run-time Object QTP script is:
' Link("text:=Advanced Search") is a dynamic run-time object
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
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:
As you can see, we got the same Run-time Object Properties both for Test Object and for Run-time Object. I can explain it.
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.
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.
Note: You can download final QTP script here.
1 comment:
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
Post a Comment