Micro Focus QTP (UFT) Forums
Need help in creating dynamic object string using Childobjects - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Need help in creating dynamic object string using Childobjects (/Thread-Need-help-in-creating-dynamic-object-string-using-Childobjects)



Need help in creating dynamic object string using Childobjects - Keshub Mathur - 09-11-2017

Hello,

I am working on a keyword driven uft framework where I am writing the test case flow in the excel sheet which is being processed by functions in the function library. The format of the excel has the following columns. 

1. Parent(Example Value - "Browser, Page") - All parent objects are to be put in a single cell separated by comma
2. Parent Properties(Example Value - micclass:=Browser, title:=login,micclass:=Page) - All parent properties are to be put in a single cell separated by comma
3. Control (Example Value - WebEdit) - Contrl  object is the object on which the operation/action is to be performed.
4. Control Properties - Contains all the control object properties used to identify control object.
5. Action - Contains the action to be performed (ex SetValue, Click) on the control object.
6. Argument - Contains the Argument to be passed to the action (eg String argument passed to set value of a textbox etc)

I have created a ParenthierarchyIdentifier which creates a parenthierarchy object in the below format:

Browser(“B”).Page(“P”).Frame(“F”).WebEdit(“W”).Set “some value”

I am trying to do this using ChildObjects but I am getting the "Object doesn't support this property or method: 'obj_hierarchy(...).ChildObjects'" error.

Function Logic -  
1. Loop through each object until end of loop.
2. Create a description object for parent.
3. If Description_Object is the first object : Set obj_hierarchy = Description Object
       else
            Set obj_hierarchy = obj_hierarchy(0). Description Object
Next Iteration.
4. Call the ControlIdentifier() function.

The error I am getting is on step 3 else part when I am trying to fetch the child objects present under the parent hierarchy that i am at.

Below is the function code that i am executing. I have tried debugging using msgboxes and the logic is working fine but the code fails on the ChildObjects() statement.

'parentCount= for looping through each parent, arrparent = array containin parent names, sParentProp = parent property array, 

For i = 0 to parentCount
  msgbox arrParent(i)
        'Split Parent Property so that multiple objects can be resolved
        arrParentProp = Split(sParentProp, ",")
        parentPropCount = uBound(arrParentProp)
        msgbox parentPropCount
       
        Set current_parent = Description.Create()

For j = restart to parentPropCount
       
        arrParentpropKeyValue = Split(arrParentProp(j), ":=")
        msgbox arrParentpropKeyValue(0)
        msgbox arrParentpropKeyValue(1)
        If j<>restart and arrParentpropKeyValue(0) = "micclass" then
        restart=j
        msgbox "Exiting Loop"
        Exit For
Else
msgbox "In else loop"
        current_parent(arrParentpropKeyValue(0)).value = arrParentpropKeyValue(1)
        End If
        Next


If i=0 Then
Set obj_hierarchy = current_parent
msgbox "Done"
Else
msgbox "Concatenating"
*Set obj_hierarchy = obj_hierarchy(0).ChildObjects(current_parent)  
End If

Next

*Error on this statement = Object doesn't support this property or method: 'obj_hierarchy(...).ChildObjects'



Your help would be highly appreciated,

Thanks and Regards,
Keshub