cancel
Showing results for 
Search instead for 
Did you mean: 

Capture objekt tree structure of elements that disappear

SOLVED
Occasional Contributor

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Community Hero

Re: Capture objekt tree structure of elements that disappear

That's the thing... this isn't an "object" like others.  Menus like this are not something you're going to capture with Object Spy or such... They are properties of some other form... specifically, as the documentation says, MainMenu or PopupMenu or something like that.  So, you're not going to be able to "map" it or see the parent... that's not how TestComplete sees these objects.

https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/window-and-process/ma...

 

So, unfortunately, I'm not sure you're going to be able to do precisely what you want with Object Spy or something like that.  You should be able to examine/iterate through the "Items" property of the menu object to find out the information you want to know...  

https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/menu/items-property-m...

 

 


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

View solution in original post

9 REPLIES 9
Community Leader

Re: Capture objekt tree structure of elements that disappear

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.

 

TestComplete_JxhM3wsk5d.png

 

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.

 

firefox_N9R6cxMoT7.pngTestComplete_kTYwhyBdpn.png

 

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

firefox_ig4UVsSuP4.png

 

 

And so on ...

 

firefox_xTCOhAtWgv.png

 

 

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

 

 

Un sourire et ça repart

Occasional Contributor

Re: Capture objekt tree structure of elements that disappear

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.

001.PNG

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

002.PNG

 

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

005.PNG

 

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:

004.PNG

 

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

Community Leader

Re: Capture objekt tree structure of elements that disappear

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 ?

 

 

Un sourire et ça repart

Occasional Contributor

Re: Capture objekt tree structure of elements that disappear

This is my object on the screen:

001.PNG

 

This is Object Spy with Ctrl+Shift+A on this object:

002.PNG

 

'Aliases' and 'FullName' say that 'Popup("Rahmen") is the parent element.

 

Now I click on 'parent' -> '[...]. But there are no information.

003.PNG

 

Ok, then I map the object: Right click -> Map object...

And this is the result in the Mapped Objects. The Object is placed under a new "Item". But it was supposed to be the child of "Rahmen"?

005.PNG

 

This inconsistency of information is a problem at work. Precisely because the tree structure cannot be seen. This would not be a major problem if you could view the object tree, even if the object no longer exists on the screen. Keyword: Snapshot of object tree.

 

Edit:

The button at the top right "Highlight Object in Object tree" (window object spy) gives me the error message, that the object doesn't exist.

Community Hero

Re: Capture objekt tree structure of elements that disappear

This is a menu object?  You don't map menu objects.  You map the main menu or popup menu and then you use a Menu Action in Keyword Tests if you're operating on the menu.  

 

https://support.smartbear.com/testcomplete/docs/keyword-testing/reference/test-actions/menu-action.h...


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Community Leader

Re: Capture objekt tree structure of elements that disappear

What is your need precisely ?

Why you want to go down-to-up ? What is the objective in your test approach ?

Because opening the menu item was done by clicking on its parent. So you have checked the parent.

 

 

Un sourire et ça repart

Occasional Contributor

Re: Capture objekt tree structure of elements that disappear

I do not use keyword testing. The contents of the context menu are dynamic and the parameters are passed dynamically to a function, which then identifies and addresses the element using FindChild or FindAllChildren.

I'm looking for exactly the parent element, but the information is inconsistent.

 

I'm not looking for a workaround, because this was just an example for better understanding. The requirement is: If I have an object, I want to be able to uniquely identify its parent element and its exact position in the object tree. This is not a problem with objects that remain on the sceen, but with objects that disappear when you switch to Testcomplete or Object spy.

 

In my example I want to use 'TestObj.FindChild(PropNames, PropValues, Depth, RefreshTree)' with as little depth as possible. If 'TestObj' is the direct parent then 'Depth' can be '1'. But because of the inconsistency of the information and the inaccessibility of the object tree it is difficult to find out who the parent element is. (Object spy says one thing, mapping another thing and Object Tree says nothing.) In this example, the (sub) context menu on the right side is not a child of the context menu on the left side. Then it would be easy.

Community Hero

Re: Capture objekt tree structure of elements that disappear

That's the thing... this isn't an "object" like others.  Menus like this are not something you're going to capture with Object Spy or such... They are properties of some other form... specifically, as the documentation says, MainMenu or PopupMenu or something like that.  So, you're not going to be able to "map" it or see the parent... that's not how TestComplete sees these objects.

https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/window-and-process/ma...

 

So, unfortunately, I'm not sure you're going to be able to do precisely what you want with Object Spy or something like that.  You should be able to examine/iterate through the "Items" property of the menu object to find out the information you want to know...  

https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/menu/items-property-m...

 

 


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

View solution in original post

Community Manager

Re: Capture objekt tree structure of elements that disappear

Thanks Community!

 

@ARR , was your question answered? Please mark the best answer as a solution. Thank you.


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors