Wednesday, 28 August 2013

How can I get the logical name of a test object (that exists in the associated shared OR)?

How can I get the logical name of a test object (that exists in the
associated shared OR)?

Let´s say I pass a
Browser("MyBrowser").Page("MyPage").WebCheckBox("MyBox") to a function:
MyFunction (Browser("MyBrowser").Page("MyPage").WebCheckBox("MyBox"))
Later, the function wants to log the logical name of the received test
object (which in this case, of course, is "MyBox").
How could it do that?
The "name" test object property returns the name that is built if you
re-add the test object. There is no (documented) test object property for
the logical name. The runtime object properties can´t possibly contain the
name since it is not a name from the AUT GUI.
So I think the test object does not know its name. Only the repository
"knows" under which name the test object is stored there.
So I will have to inspect the repository itself, not the test object.
The ObjectRepositoryUtil API allows me (via GetChildren, or other methods)
to find the test object in the repository´s test object collection, and
use the GetLogicalName method to get its name. Fine.
But the only way to get that to work is to obtain a reference to a
repository by loading it. I get the impression this API is designed to
manipulate (or analyze) repos from outside of QTP, not from within a test
run. I do not want to re-load the repository. I want to look up the test
object in one of the already-loaded repositories.
The RepositoriesCollection API can tell me which are loaded (by their name
and path), but it does not provide a means of obtaining a reference to the
object instance that represents one of those repositories.
So how can I obtain a reference to an already-loaded repository, so I can
use GetLogicalName?
Or generally asking: Given a reference to a "normal" test object contained
in the current action´s shared repository, how can I find out its logical
name programmatically?

No comments:

Post a Comment