Other ways to select a tab

May 12, 2008 at 11:26 PM
I'm trying to automate testing of a product that I don't have the source code for.  All I know is it is built using Visual C++ and appears to use only standard/simple UI controls.  When I select a tab the product switches to the tab but then it reports and error and crashes.  I'm make the tab switch as shown below (I've changed the names of the tabs to ABC and DEF in case my client cares): 

Core.

Application application = Core.Application.Attach("ABC");
Core.UIItems.WindowItems.
Window window = application.Find(delegate(string obj) { return obj.StartsWith("PATH"); }, Core.Factory.InitializeOption.NoCache);
Console
.WriteLine("Found window:" + window.Name);
Tab tab = window.Get<Tab>();
Console.WriteLine("Tab count:" + tab.TabCount);
Console.WriteLine("Selected tab:" + tab.SelectedTab.Name);
foreach (UIItem item in tab.Pages) { Console.WriteLine("item:" + item.Name); }
tab.SelectTabPage(
"DEF");

All the output to the console for the tab count, selected tab, and tab names is correct.  My code doesn't throw an exception on the line where it calls 'SelectTabPage'.   If I call 'SelectTabPage' with the name of the tab initially selected I don't get the error from the Product.  I get the same error when I try to select a different tab by index.

When I look at the structure of the UI using UISpy the initial tab's content is under the tab but the contents of the other tabs do not show up as children of the tab.  Instead they are added at the same level as the tab and it looks like they are made invisible when you move to different tabs.  I suspect this is being done for performance reasons since there is a lot of data on the first tab but I don't know enough about programming with tabs to really understand what is going on. 

Is there any other way to select a tab that might not cause the product to crash, e.g., is there a way to simply click on the tab page control directly rather than through the SelectTabPage call?  Does the implementation or the underlying UIAutomation layer depend on the tab contents being displayed as children of the tab page?

 

Coordinator
May 13, 2008 at 3:50 AM
Yes there is another way to, which would just click the Tab. (May be I should change my implementation do the same instead of using UIAutomation's "recommended" way)
Find your TabPage by using tab.Pages. and the call tabPage.Click(); on it.
May 15, 2008 at 7:12 PM
Your suggestion worked.  Thanks