You want the "TestObjName" property:
function GetRepoName(obj)
GetRepoName = obj.GetTOProperty("TestObjName")
end function
Usage:
logicalName = GetRepoName(Browser("MyBrowser").Page("MyPage").WebCheckBox("MyBox"))
'logicalName now equals "MyBox"
Should you feel the need to reconstruct the entire object chain as a string, you can use the following method "GetFullQtpName" (which also requires GetRepoName plus the 2 extra methods below):
function GetFullQtpName(obj)
dim fullQtpName : fullQtpName = MakeQtpName(obj)
dim objCurrent : set objCurrent = obj
do 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 now equals "Browser("MyBrowser").Page("MyPage").WebCheckBox("MyBox")"