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


let´s pass browser("mybrowser").page("mypage").webcheckbox("mybox") function:

myfunction (browser("mybrowser").page("mypage").webcheckbox("mybox")) 

later, function wants log logical name of received test object (which in case, of course, "mybox").

how that?

the "name" test object property returns name built if re-add test object. there no (documented) test object property logical name. runtime object properties can´t possibly contain name since not name aut gui.

so think test object not know name. repository "knows" under name test object stored there.

so have inspect repository itself, not test object.

the objectrepositoryutil api allows me (via getchildren, or other methods) find test object in repository´s test object collection, , use getlogicalname method name. fine.

but way work obtain reference repository loading it. impression api designed manipulate (or analyze) repos outside of qtp, not within test run. not want re-load repository. want test object in 1 of already-loaded repositories.

the repositoriescollection api can tell me loaded (by name , path), not provide means of obtaining reference object instance represents 1 of repositories.

so how can obtain reference already-loaded repository, can use getlogicalname?

or asking: given reference "normal" test object contained in current action´s shared repository, how can find out logical name programmatically?

if there ultra-wise qtp wizard la motti knows can not done, i´d appreciate answer him if reads "it cannot done" if true.

you want "testobjname" property:

function getreponame(obj)     getreponame = obj.gettoproperty("testobjname") end function 

usage:

logicalname = getreponame(browser("mybrowser").page("mypage").webcheckbox("mybox")) 'logicalname equals "mybox" 

should feel need reconstruct entire object chain string, can use following method "getfullqtpname" (which requires getreponame plus 2 methods below):

function getfullqtpname(obj)     dim fullqtpname : fullqtpname = makeqtpname(obj)     dim objcurrent : set objcurrent = obj      while not isempty(objcurrent.gettoproperty("parent"))         set objcurrent = objcurrent.gettoproperty("parent")         fullqtpname = makeqtpname(objcurrent) & "." & fullqtpname     loop      getfullqtpname = fullqtpname end function  function makeqtpname(obj)     makeqtpname = getclassname(obj) & "(""" & getreponame(obj) & """)" end function  function getclassname(obj)     getclassname = obj.gettoproperty("class name") end function 

usage:

fullqtpname = getfullqtpname(browser("mybrowser").page("mypage").webcheckbox("mybox")) 'fullqtpname equals "browser("mybrowser").page("mypage").webcheckbox("mybox")" 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -