WPFWindow.Get(...) returns null. But Click manually on window and reexecute line it (seemingly) only then returns a reference.

Jan 20, 2009 at 3:35 PM

hi;

Via nunit test with white doing UIA of a wpf app, i dynamically activate a main tabitem - before its activation, dynmically, a usercontrol with,  a  listview is loaded into it.

In the load handler for the usercontrol i create an automation id for the listview.
I check with uispy .... the listview is listed with the automation id (which is lv0).

But the automation code returns null on the second code line when i try to get the control.
   //verify 1367 items in the lv0 start tabitem.
   Core.UIItems.Finders.SearchCriteria scListView0 = Core.UIItems.Finders.SearchCriteria.ByAutomationId("lv0");
   Core.UIItems.
IUIItem iuiItemLV0 = wpfWindow.Get(scListView0);

 

 

If i break before the Get(...) and then go manually and click on the opened wpf window
... and then go back to automation code step over the line... then it works!  The Get returns a non null reference to the control.

What to do?

I tried by doing stuff like here:
//Prepare logview view
Core.UIItems.Finders.SearchCriteria sc = Core.UIItems.Finders.SearchCriteria.ByControlType(System.Windows.Automation.ControlType.Tab);
Core.UIItems.
IUIItem tabControl= wpfWindow.Get(sc );
Core.UIItems.TabItems.
Tab mainTabControl = (Core.UIItems.TabItems.Tab)tabControl;
mainTabControl.SelectTabPage(1);
mainTabControl.Click();
Core.UIItems.TabItems.
ITabPage fileViewTabItem = mainTabControl.SelectedTab;
fileViewTabItem.RightClick();
mainTabControl.KeyIn(Core.WindowsAPI.
KeyboardInput.SpecialKeys.RETURN);
Mouse.Click(System.Windows.Input.MouseButton.Left);

 ... without avail.

Thanks,
Paul

Jan 20, 2009 at 5:17 PM
solved:
this trick did it:
wpfWindow.DisplayState = Core.UIItems.WindowItems.DisplayState.Minimized;
wpfWindow.DisplayState = Core.UIItems.WindowItems.
DisplayState.Maximized;
wpfWindow.DisplayState = Core.UIItems.WindowItems.
DisplayState.Restored;

thanks,
paul