Reputation: 129
I'm using CodedUI in WPF, Visual Studio 2013, using a combination of the built in tools, and hand written tests.
I'm trying to click a basic button on a popup window. I have similar windows that work fine, from external libraries, however this is from my own.
Mouse.Click(UIMap.StubWindow.OK);
This creates an error, as it cannot find the OK button. Additionally calling:
UIMap.StubWindow.DrawHighlight();
Fails also, not being able to find the window. However sometimes it draws an outline around the Start Button in Windows. Strangely, both of the below lines work correctly, after calling FindMatchingControls().
UIMap.StubWindow.FindMatchingControls();
UIMap.StubWindow.DrawHighlight();
Mouse.Click(UIMap.StubWindow.OK);
The problem is, it takes around 5-10s for FindMatchingControls to execute, as it has to search all top level windows on the system. Even after matching one window. Calling Find(); does not work. However oddly,
var x = UIMap.StubWindow.FindMatchingControls().Count;
x is 1.
Is there a reason for this, or a way for me to not need to call FindMatchingControls? I have tried changing the search configurations to always search for both the window and the OK button, but that does not work.
SearchProperties is relying on an AutomationId, and a Framework ID, both using the EqualsTo operator.
This does not work even when used directly from the test builder. I only found that FindMatchingControls makes it work whilst debugging, checking for ambiguity.
Upvotes: 0
Views: 634
Reputation: 129
Just fixed this. Seems fairly obvious now, but the popup windows were written quickly and didn't have titles.
Didn't notice/think this was important, but had a fairly large impact. Added titles and setup the UIMap again, and works fine.
Upvotes: 1
Reputation: 66
Have you tried defining the control w/o using the UIMap? Something like this?:
var app = new ApplicationUnderTest();
var x = new UITestControl(app);
x.SearchProperties.Add("Key","Value");
x.SearchProperties.Add("Key","Value");
x.SearchProperties.Add("Key","Value");
Mouse.Click(x,x.GetClickablePoint());
Upvotes: 0