Getting controls inside a tab

Jul 30, 2009 at 12:08 AM

I'm not sure what I'm doing wrong.  I'm just trying to be able to click on controls inside a tab, but I can't find them.

I've tried all the different ways to select the tab that I've found.  When I run the test it has no problem selecting whatever tab I want, but then I can't click on the checkboxes inside the tab. 


TabPage tPage = _window.Get<TabPage>("_standardTab");

IUIItem[] items = _window.GetMultiple(SearchCriteria.All);


items only has the elements outside of the tab area.  None of my attempts to search the window for items in the tab area have worked.


What obvious thing am I missing?  Thanks


Jul 30, 2009 at 6:58 AM


I use also _window.Get<Control>....

to get visible elements after selecting and opening a tab.


In my case to get a ListBox with is part of the opened tab.



Jul 30, 2009 at 7:03 AM

Yea, I've tried using the normal method of _window.Get<Control> to find the elements in the tab, but without success.

It is my understanding that

IUIItem[] items = _window.GetMultiple(SearchCriteria.All);

will find all of the visible items on the screen, then while debugging it's easy to see what items are available, that's why I was using it. 


If you can use the normal Get call then maybe there is something strange about my tab setup.  I'll try it with a more basic example.

Jul 30, 2009 at 7:10 AM

Did you use UISpy or UIAutomationVerify to see available elements???

(I use the second one)

if there are elements try first to get the using



TabPage tPage = _window.Get<TabPage>("_standardTab");
AutomationElementCollection coll = tPage.AutomationElement.FindAll( TreeScope.Children, Condition.TrueCondition );


Jul 30, 2009 at 8:18 PM

I made a simple test project with a tab panel and some buttons and I was easily able to find the controls in the tab.  There must be something about the main applications tabs that is causing the problem.  I'll post when I figure it out.

Jul 30, 2009 at 8:51 PM

I tried applying a TabControl style to the TabControl in my simple test project (as there is in the real project), and that's where I ran into problems.  As soon as I apply even the simplest style I can think to make to the TabControl the contents of the tab become invisible to White.  Without using the style the TabControl works fine and I can get the buttons inside the tab with White, no problem, but as soon as it's applied I can no longer see the buttons with White.

Has anyone else seen this issue?

The style I used for the test:


<Style TargetType="TabControl">
        <Setter Property="Template">
                <ControlTemplate TargetType="TabControl">
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                        <TabPanel Grid.Row="0" IsItemsHost="True" />
                        <ContentPresenter Grid.Row="1" ContentSource="SelectedContent" />






Jul 31, 2009 at 8:46 AM

I'm not really sure, but maybe the style don't implement the needed provider for automation


does UIAutomationVerify found the elements if the style is used???



Jul 31, 2009 at 6:17 PM

UIAutomationVerify also doesn't see the elements in the tab when a style is applied.  I see them in the tree when there's no style, but when there is they don't show up.

Jul 31, 2009 at 6:47 PM

It looks like AutomationElement is unable to find the controls inside the tab.  This call in the White source:

return automationElement.FindAll(TreeScope.Descendants, condition);

does not return the controls in the tab when the tab is styled.


Aug 2, 2009 at 10:47 AM

TabPage is not a primary UIItem so please try getting the Tab from the window and find TabPage from it instead

Mar 3, 2010 at 4:21 PM

I think the TabPage is not the problem. The problem is: How to get the elements from the TabPage when the TabControl contain styles (using Template property)?

Mar 4, 2010 at 5:20 AM


have a look at this =>

TextBlocks contained in a DataGridTemplateColumn are not available in UI Automation

this discribes the Problem if Textblocks are part of the Template. => And there is a solution, but this needs access to the developer and a change in the Application to test.

An other interesting thing is custom-controls-and-ui-automation

but this needs also changes by the developer



Mar 4, 2010 at 8:18 AM


great links, thank you. We ran into the same problem and fixed it similarly.


do you consider establishing a FAQ for White? The hints and solutions like this should be captured, I think.


Mar 8, 2010 at 3:50 PM

There is other questions page where I capture repeated questions. I wonder how can I open it for the community to add such things themselves


Mar 18, 2010 at 6:35 PM

Try adding a Name in:

<ContentPresenter Grid.Row="1" ContentSource="SelectedContent" /> as follow
<ContentPresenter Name="ContentPresenter" Grid.Row="1" ContentSource="SelectedContent" />

Some UiObjects need to have Name to be accessible.