min2

Absent Member.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2008-11-26
14:23
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")
Obj passed:- OK
Return value:- Browser("XYZ").Page("ABC").Frame("LMN").WebButton("OK")
3 Replies
Cody Marcel

Absent Member.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2008-11-26
15:14
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.
Another way is exporting to xml using the ExportToXML() method and then parsing that to find the path.
min2

Absent Member.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2008-11-26
16:59
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!!!!!!!!!!!
Thanks in advance!!!!!!!!!!!
Cody Marcel

Absent Member.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2008-11-26
18:04
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.
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.