Problem with recognizing objects - Focus tracking from UIVerify

Jun 2, 2011 at 2:01 PM
Edited Jun 2, 2011 at 5:35 PM


I’m looking for alternative for existing tests written in QTP for my Win32 application written in Borland C++.
My candidate is White because it’s native solution, I can create my tests using .NET/C# and easily integrate it with nUnit and Hudson.

I use UI Verify as a spy to identify properties of objects I want to find in my tests.
More or less when I can see something in the spy, I can find it using UI Automation/White.

Generally I don't have much problems with recognizing objects but when I try to search some content inside the tab contained in Tab Panel
or try to see MenuItems of Menu bar then the problem appears. UI Automation/UI Verify works wired.
When I run UI Verify (1.0 version) I see that objects can be registered properly only then
when I set 'Focus tracking' option and click on target objects or change the keyboard cursor on them. Otherwise it's impossible to find them.
UI Verifier can show me children of my 'tab' panel then. But I can’t find them using UI Automation/White. This is example code:

Tab tab = window.Get();
ITabPage tabPage = tab.SelectedTab;
AutomationElementCollection newCol = tabPage.AutomationElement.FindAll(TreeScope.Descendants, Condition.TrueCondition);

the collection is empty even though spy see the children.

Does any of you have some experience with this library that he/she would like to share with me or know how to use the tracking mechanism implemented in UI Verifier?


Jun 6, 2011 at 6:43 AM


I know this problem too.


My Workaround:

I get all tabs, in a loop I open each tab and the last step is to select the needed Tab.

After that I find the elements inside the tab. It's not nice but works for me.



Jun 6, 2011 at 11:42 PM
Edited Jun 6, 2011 at 11:44 PM
Throndorin wrote:

My Workaround:

I get all tabs, in a loop I open each tab and the last step is to select the needed Tab.

After that I find the elements inside the tab. It's not nice but works for me.


can you please provide the example code?

You mean something like that?
Tab tab = window.Get<Tab>();
for (int t = 0; t < tab.TabCount; t++) { 

and then what?


Please share with the solution because it's not clear enough. I'm not talking about the nested tabs. I need to know how to get to the content of my TabPages.

I've noticed on another box (WindowsXP 32bit on VM) in the UIVerify 1.0 spy a wired situation. Each time I have an open (selected) TabPage I also can see a window child of my Tab Pane (container of the tabs).
I'm not sure I've seen such behavior on my first box (WindowsXP 32 bit physical).

Finally I ported the focus tracking feature from UIVerify, but it is good when we either click on element or press tabulation to change focus on it only.

Jun 7, 2011 at 7:02 AM
Edited Jun 7, 2011 at 7:03 AM

To select the correct Page:



/// <summary>
/// Switches the tab.
/// </summary>
/// <param name="tab">The tab.</param>
/// <returns></returns>
private TabPage SwitchTab(Tab parent, string auID )
  TabPage page = (TabPage)parent.Pages.Where(p => p.AutomationElement.Current.AutomationId == auID).First(); 

  foreach( ITabPage tabPage in parent.Pages )

  if( page != null )

  return page;


Next Step is Getting the Elemets from page returned by the OpenTab Operation, I handle such things in a class, which contains all Elements

Button _button;


_button = page.Get<Button>(....)


Getter and Setter for the elements

and so on


My Problem was White and also UIVerify or UISpy don't see the elements on the tab, without this trick.


window as container for tab pages are you sure we don't speek of MDI Childs?