Ask a Question

Cannot access ToolTip property using Object Spy (WPF)

Andrii
New Contributor

Cannot access ToolTip property using Object Spy (WPF)

Hi,

 

I'm interested in two cases: when ToolTip is Text and when ToolTip is an object. Neither works for me.

In both cases Object Spy shows (Null Object) (don't remember the exact text). However, Snoop shows them (please see the screenshot 'test.png').

It seems like Object Spy is not able to dig into visual tree properly.

 

I also tried to access the tooltip manually using WPFObject but it shows the same result:

....WPFObject("Border", "", 1).WPFObject("Grid", "", 1).WPFObject("ItemsControl", "", 1).WPFObject("ContentPresenter", "", 1).WPFObject("DisplayGrid").WPFObject("LeftSideTogglePopup").WPFObject("PART_ToggleButton", "").ToolTip

 

WPFObject("Border", "", 1).WPFObject("Grid", "", 1).WPFObject("ItemsControl", "", 1).WPFObject("ContentPresenter", "", 1).WPFObject("DisplayGrid").WPFObject("LeftSideTogglePopup").WPFObject("ToggleButton", "", 1).ToolTip

 

1) How can I solve this issue?

2) Is it possible to find a control by x:Name in the visual tree?

 

This limits our team in testing dynamically set tooltips. 

 

Thanks,

Andrii

4 REPLIES 4
tristaanogre
Esteemed Contributor

It depends upon the implementation, really. 

 

In some cases, "tooltip" is a property on an object.  In these cases, you cannot spy with object spy because there is no object to spy.  You spy the parent object and then access the tooltip property.

 

For a web application I'm currently testing, there are these "hover" tool tips that open an object on the page for viewing.  These objects are part of the page but are only set to "visible" when the mouse hovers over them.  In these cases, we have to use the SHIFT-A method of capturing the item or go searching in the Object browser.

 

So... guess it comes down to how your tool tip is implemented in your application.  Can you see it in the object browser (this is not the object spy, but the object browser tab itself)? If so, start there.  If not, look for it as a property of the parent object.


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

Hi Robert, 

 

Thank you for you reply. 

 

It doesn't show the tooltip even if it is hardcoded as a string. In my example above: WPFObject("PART_ToggleButton", "").ToolTip - PART_ToggleButton is a parent object and ToolTip is a property. Object Spy shows ToolTip == "Null Object", when Snoop shows that the value is "Select Tenor". Because it is hardcoded it doesn't depend on the implementation.

 

Thanks,

Andrii

tristaanogre
Esteemed Contributor

Can you show me a screenshot of the object with the tool tip property with all the other properties on the object?

 

I'm not familiar with the Snoop tool... however, I suspect that it's accessing the property differently than TestComplete.  Is it possible that the object that is represented in the tooltip property is not actually instantiated until the parent object is hovered over?  That almost seems to be what's going on.  

 

As a test, use the "HoverMouse" action on the parent object and, with the mouse hovered, simply write a log message out to the log with the contents of the tool tip property to see if it actually records at that point.


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

Thanks for your help Robert,

 

It doesn't depend on the MouseEvents, It is hardcoded from the beginning(other tooltip with the same problem, original code base has been changed):

 

<Button x:Name="PART_UncheckedControl" Focusable="False" Background="Transparent"
ToolTip="Electronic" Height="18" ....

 

It isn't being changed during the execution either.  

Screenshot with initial object state is attached. Tooltip hadn't been shown when I took the screenshot.

 

Unfortunately, I don't have access to the Object Spy because QC only have license for that. I will try to create simple wpf form with a tooltip and check whether Object Spy could get a value.

 

Thanks

 

 

 

 

 

 

 

 

cancel
Showing results for 
Search instead for 
Did you mean: