This project is read-only.

Item in Snoop not visible to Automation?

Feb 10, 2011 at 8:29 PM

I am working on automating an app for testing and last week the developers made some changes to their UI to allow for skinning. It looks the same but the UI tree is different. UISpy can no longer see a few objects that I was using and their children are all flattened on to one level now. I ran Snoop and it can see the objects and they still have their automation ids, but I can't grab them. I did a LogStructure() on the panel that contains these objects and it doesn't see them either.

So my question is, if something is in Snoop and has an automation id, is it possible that it can't be accessed with White? Also, what would cause it to be visible in Snoop, but not in UISpy or LogStructure()?

Feb 11, 2011 at 6:32 AM



Snoop shows the complete visible Tree, but this does not mean, all elements are visible for UIAutomation.


Problem: Not all Controls (and Custom Controls) in a UI implement AutomationPeer (needed for UIAutomation).


So all elements which are does not implement AutomationPeer  are not visisble for UIAutomation.


Have you read the chapter CustomCommands (for White 2.0)?


I have direct access to the developer whcih implement the application I test. If I can't see a custom control and need it for test I ask them to implement AutomationPeer to make is testable.


Hope this information helps.



Feb 11, 2011 at 11:47 PM

Thanks for the quick reply! I did a little deeper investigation and talked withe the developer responsible for the code and it turns out they are using a ControlTemplate. I did some searching and it seems like Control Templates and UIAutomation don't work very well together. I am going to search some more and try and find a way to expose the ControlTemplate to UIAutomation.

Feb 17, 2011 at 7:19 PM
Edited Feb 17, 2011 at 7:20 PM

I ended up getting the item visible again to UIAutomation. In the class for the custom control I overrode the OnCreateAutomationPeer() method to call a custom AutomationPeer class. I had the AutomationPeer class inherit from FrameworkAutomationPeer because it was a generic Control type (not like ListControl, TextBoxControl, etc.).

In the custom class I overrode  GetClassNameCore() and GetLocalizedControlTypeCore() to return the values for the control that I wanted, and that caused it to be visible in the tree again.