Search code examples
wpfui-automationtabitemteststack

TestStack White ui automation cannot find TabItem


I am automating a wpf windows application. Trying to perform a logout function where I click on the settings icon. A new modal window opens up with several TabItems such as "General", "Security", "Appearance" etc.

I would like to click on the security tabitem which has a textbox "Security". Upon clicking that, a pane adjacent to the TabControl loads with a signout button.

I am unable to get the Security tabitem and unable to click on it. It does not have an AutomationId. So far I can get the TabControl which has all the TabItems within using this:

var tabControl = settingsWindow.Get(SearchCriteria.ByClassName("TabControl"));

But I am unable to select a TabItem and click on the buttons in the Security pane.


Solution

  • Got it!

    var tabControl = settingsWindow.Get<Tab>(SearchCriteria.ByClassName("TabControl"));
    
    tabControl.SelectTabPage(1); // since the tab i want to click on is the 2nd tabitem in the TabControl