This project is read-only.

UI Automation ControlType from type of control

Oct 7, 2008 at 5:35 PM
Hi all!
I need to find an UIItem from a control that I have a reference from. I have a reference to the Window of the application and I can get the control with:

SearchCriteria searchCriteria = SearchCriteria.ByAutomationId(tmpControl.Name);
UIItem item = mainWindow.Get(searchCriteria) as UIItem;

However I would like to refine the search and add a Condition bt ControlType. UIAutomation ControlTypes are different from the types of controls. How can I get a
the ControlType of a control so I can do something like this:

SearchCriteria searchCriteria = SearchCriteria.ByAutomationId(tmpControl.Name).AndControlType(tmpControl.getControlType);
UIItem item = mainWindow.Get(searchCriteria) as UIItem;

Am I missing something? (As you have probably noticed I'm new to white so I may be messing things up)

Thanks for helping
José Tavares
Oct 13, 2008 at 1:53 PM

You can use UI Spy to check the accessibility of your control and get the required ControlType.

Once you get that type, you can get your object in White test the following way:

            SearchCriteria criteria = SearchCriteria.ByAutomationId(<myAutomationID>);
            myType myControl = this.WhiteWindow.Get<myType>(criteria);

Hope this helps!