Forum Discussion

ARR's avatar
ARR
Occasional Contributor
5 years ago

Capture objekt tree structure of elements that disappear

How can I capture properties and objekt tree structure of elements that disappear when clicking in object spy or testcomplete?

 

The tested app uses custom context menus. These can be captured with object spy (Ctrl+Shift+A). But, when I want to view the object tree structure, it is not available, because the context menus disappears as far as you click into the object spy or other window (""Unable to hightlight this object in the object tree, because it does not exist."). The Context menus are only available until you click outside of them.

The context menus with submenus look like parents and children on the screen, but are not in the object structure. My goal was to access the objects via FindChild and FindAllChildren (The values of the properties should be passed dynamically to a function via parameters. Therefore, name mapping is not an option here.). To make this work faster, I wanted to study the object structure. This way I could better understand the structure and relationships of the objects. But that didn't work.

 

Other tools can take a snapshot of the object structure or at least show the object structure further (for example Inspect.exe or Appium). So you can view the structure (and properties) of the elements, even if the elements and structure are no longer exist on screen.

 

With TestComplete, however, this information are only available as long as the element is present on the screen. As a quick solution I wrote my own function (Recursive loop, FindAllChildren, etc.) that automatically captures all elements on the screen and writes the structure in an XML-like file.

So I got what I need. But it's very slow and inconvenient. I would assume that Testcomplete could do something basic like that natively and I just didn't find it. How can I do that?

 

PS: I work with script test cases and Python.

  • BenoitB's avatar
    BenoitB
    Community Hero

    You can go through the structure by _NewEnum property.

     

    The _NewEnum property contains children of the object spyied. The number of children is hold by ChildrenCount property.

     

     

    If you click on _NewEnum ... button at right, you access to the selector of the item you wish to introspect.

    Select the Items number by clicking on Params button at right of it. Value start from 0 to ItemCount-1.

     

     

    After selected the item number, you can access to his properties through  ... button at right.

     

     

    And so on ...

     

     

     

    By script you access same using obj.Items(itemNumber) property.

     

     

    • ARR's avatar
      ARR
      Occasional Contributor

      NewEnum contains the child elements, if available. And the procedure has little to do with an understandable object tree structure. I have an object and do not know where it is in the tree. Who are its parents, grandparents? I do not know. But there are hundreds of elements in my app object tree.  I need the parent of a object and I can't go the way from any parent element to child elements because my target object doesn't exist when I use the object spy or other windows.

       

      I have a context menu and wants to know who is the parent element of "Rahmen hinzufügen". Is it "Rahmen", app main windows or a completely different object? Everything is possible.

      The object spy gives different information.
      - Aliases says: Popup("frame")
      - FullName says: "Popup("frame")
      - Parent  -> [...]: is empty

       

      And when I map the object, an "Item" is inserted in the name mapping tree.

       

      This is a lot of different information and none of it leads to a working solution.

       

      I would just use 'Highlight Object in Object tree', but:

       

      The question is, who is the real parent of my object and how can I easily find out?

      • BenoitB's avatar
        BenoitB
        Community Hero

        On your screenshot of your submenu item, the Parent property seem to have an object. And the FullName give you  the correct parent (here on screenshot the MenuItem() has the parent Popup("Rahmen")).

        Normally you have just to use obj.Parent to know the parent or use the FullName path.

         

        But you say that using the parent it give you the message that the parent doesn't exist ?

        Is that the problem ?