Highlighted
Frequent Visitor.
660 views

Returning repository Logical object name from the ChildObjects collection

Jump to solution

I have some code that collects the objects from a web page, but when I try to set the Name selection criteria value to the same (Logical) name I gave the object in the repository it cannot match it and returns an empty collection.

How do I return the object repository logical name I have given it from the complete web page object collection or set it as the criteria for populating the web page object collection.

So far all I can return is the Physical object name using the GetROproperty and the toString, can someone please help?

This is the code to obtain the web page object collection...

Set oPageObjects = Description.Create()
oPageObjects("micClass").Value = "WebRadioGroup"
' oPageObjects("Name").Value = datatable.getsheet("PropFile").GetParameter(2).Name ' Set Logical Name Criteria From DataTable
Set oPageCollection = Browser("Browser Name").Page("Page Name").ChildObjects(oPageObjects)
iNumberOfObjects = oPageCollection.Count

Neither of these lines of code return the Logical Object Name, just the Physical Object Name....


sLogicalName = oPagecollection(0).getroproperty("Name")

sLogicalName = oPageCollection(0).gettoproperty("Logical Name")

sObjectSourceName = split(right(opagecollection(0).tostring(),len(opagecollection(0).tostring())-2),"]")

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Returning repository Logical object name from the ChildObjects collection

Jump to solution

I don't think this is possible, both GetTOProperty and GetROProperty returns description properties that UFT uses to identify the object, logical name is not part of them.

Even if you can retrieve the logical names, UFT won't be able to return you the child collection that you expected for the same reason above.

View solution in original post

0 Likes
3 Replies
Highlighted
Micro Focus Frequent Contributor
Micro Focus Frequent Contributor

Re: Returning repository Logical object name from the ChildObjects collection

Jump to solution

Hello,

You may 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")"

 

Regards,

0 Likes
Highlighted
Frequent Visitor.

Re: Returning repository Logical object name from the ChildObjects collection

Jump to solution

Hi,

I tried using the obj.GetTOProperty("TestObjName") parameter but it returned an empty string, the same as the obj.GetTOProperty("Name") command.

The ToString and GetROProperty both return the object physical name but I need the Logical name that I gave the object in the UFT repository, where and how do I get this?

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Returning repository Logical object name from the ChildObjects collection

Jump to solution

I don't think this is possible, both GetTOProperty and GetROProperty returns description properties that UFT uses to identify the object, logical name is not part of them.

Even if you can retrieve the logical names, UFT won't be able to return you the child collection that you expected for the same reason above.

View solution in original post

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.