QTP: how to get all properties of an object, especially with descriptive programming (4666 Views)
Reply
Occasional Advisor
Terry Pescosolido
Posts: 14
Registered: ‎05-12-2008
Message 1 of 7 (4,666 Views)

QTP: how to get all properties of an object, especially with descriptive programming

[ Edited ]

How does one programmically get all the test object (and run-time) properties of an object, like the way the Object Spy gets them? This appears to be especially frustrating when trying to get the properties of an object when descriptive programming. In that case, using GetTOProperties usually only returns 1 or 2 object properties. With the object repository, using GetTOProperties still doesn't get all the object's properties. Is there some other way to get the properties of an object?

 

P.S. This thread has been moved from Quality Center Support and News Forum to Unified Functional Testing (formerly QTP) News and Support Forum. -HP Forum Moderator

Please use plain text.
Honored Contributor
Cody Marcel
Posts: 1,039
Registered: ‎02-27-2008
Message 2 of 7 (4,666 Views)

Re: QTP: how to get all properties of an object, especially with descriptive programming

GetTOProperties() on retrieves the properties that were used to identify the object.

There is not an easy way getting all the properties of an object that are available. One way might be to keep a list of all possible properties and iterate over them to find which are available to that object.

Out of curiosity, why do you need to know all properties for a given object?
Please use plain text.
Honored Contributor
Krishna Kolachalama
Posts: 648
Registered: ‎01-29-2008
Message 3 of 7 (4,666 Views)

Re: QTP: how to get all properties of an object, especially with descriptive programming

Terry, yes it is possible.
GetTOProperties only returns what properties were "actually" used to identify the object "as stored" in your OR. If I understand you correctly, you want to programmatically get
a) all possible test object properties for a given test object.
b) all "runtime" / "native" properties and methods for an object.

Let me address (b) first. While this is possible, the answer depends on the application platform, for eg: java, .NET etc. You can't do that for standard windows objects as they don't support RO properties.

Now, for (a):
Take for eg: Browser object.
Goto Registry, say HKLM -> Software -> Mercury Interactive -> QuickTest Professional -> micTest -> Test Objects -> Browser -> Properties. This will give you the same list Object Spy shows. All you have to do is to get this list from the registry programmatically.
Please use plain text.
Occasional Advisor
Terry Pescosolido
Posts: 14
Registered: ‎05-12-2008
Message 4 of 7 (4,666 Views)

Re: QTP: how to get all properties of an object, especially with descriptive programming

Cody, Krishna,

Thanks for your responses. There are a few things I wanted this for. One of them being able to determine if an object is enabled in a very generic script using descriptive programming. Fortunately, Mark Smith on TDForums.com provided a great solution to getting the properties and their values, of which I'm copying his example below:

Set Obj = Browser("micClass:=Browser").Page("micClass:=Page").Image("alt:=Fast Reply").Object
For i = 0 to Obj.Attributes.Length-1
Reporter.ReportEvent micGeneral, Obj.Attributes(i).Name,Obj.Attributes(i).Value
Next

Using this technique worked perfectly in the script I'm creating.

Terry
Please use plain text.
Honored Contributor
Cody Marcel
Posts: 1,039
Registered: ‎02-27-2008
Message 5 of 7 (4,666 Views)

Re: QTP: how to get all properties of an object, especially with descriptive programming

Keep in mind those are not the QTP properties, but the DHTML properties. When using the .object method, you break out of the QTP shell test object.
Please use plain text.
Occasional Visitor
SrinathKN
Posts: 2
Registered: ‎10-04-2011
Message 6 of 7 (4,662 Views)

Re: QTP: how to get all properties of an object, especially with descriptive programming

Thanks. that worked for me too.....

Please use plain text.
Occasional Visitor
AnandTambey
Posts: 1
Registered: ‎08-11-2014
Message 7 of 7 (423 Views)

Re: QTP: how to get all properties of an object, especially with descriptive programming

How can we get methods available for test objects from Registry? Can you please provide any details?

 

Thanks!!!

Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation