Absent Member.
Absent Member.
233 views

Retrieve OR path in QTP for an object

Hey i want to write a function where we will pass the object as a parameter and it should return me the full OR path..for example:-

Obj passed:- OK

Return value:- Browser("XYZ").Page("ABC").Frame("LMN").WebButton("OK")
0 Likes
3 Replies
Absent Member.
Absent Member.

You could probably use the ObjectRepositoryUtil Object to do this. There are examples in the help. I dont know how fast this would be as you will probably have to search an object tree for the target object and then you will have its parents.

Another way is exporting to xml using the ExportToXML() method and then parsing that to find the path.
0 Likes
Absent Member.
Absent Member.

hi cody can you help me more on this tree view concept...It's very urgent for me as i have to submit a report on this tmr...please give me a detail report on this,i have tried searching in help file but couldn't find anything on this..

Thanks in advance!!!!!!!!!!!
0 Likes
Absent Member.
Absent Member.

I would like to, but this isnt a trivial solution. It will require a bit of time to work it out. The basic approach I would use would be a a depth first search(DFS) to find the Object.

http://en.wikipedia.org/wiki/Depth-first_search

Paste "ObjectRepositoryUtil" into a script and press F1 on it. There is a link there for examples on how to use the object. There is also a list of methods to help you. You can use the GetChildren() method to return a collection of children under a parent. This will allow you to traverse the tree if you iterate over each member of the collection.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.