I'm currently moving my UI-tests to CodedUI Tests. Right now, I confront the following trouble :
In my UnitTest, I call a method located in my UIMap twice. The method contains a fragment that checks whether a MessageBox Window is open and has a boolean param that switches whether to click the confirm or cancel button in the messagebox. The Messagebox never changes (meaning its Title, Text, Buttons).
public void MyUiMethod(bool p)
{
//...variable initialization...
ApplicationUnderTest app = ApplicationUnderTest.Launch(@"some.exe");
try
{
//... get to the point that triggers the MB to show...
Assert.AreEqual(true, uImessageBoxWindow.Exists);
if (p)
Mouse.Click(uIConfirmButton, new Point(39, 16));
else
Mouse.Click(uICancelButton, new Point(49, 8));
}
finally
{
app.Close();
}
}
The first call works without any problems every time. During the second call, the Messagebox pops up, but cannot be located by the testing framework.
The Search Criteria the CodedUiTestBuilder assigns to the MessageBox are its Name (Info) and classname (#32770).
Does anybody have any hints on what could possibly go wrong here? Is this some accessibility lack in the MessageBox control?
Regards,
Seb
You can refresh the map from your test method. So when you are calling the method in the partial class for a second time just put something like UIMap MapName = new UIMap(); Then this will refresh the map and you can call your window again without the refresh problem.
public void MyUiMethod(bool p)
{
UIMap MapName = new UIMap();
//...variable initialization...
ApplicationUnderTest app = ApplicationUnderTest.Launch(@"some.exe");
try
{
//... get to the point that triggers the MB to show...
Assert.AreEqual(true, MapName.uImessageBoxWindow.Exists);
UIMap MapName = new UIMap();
if (p)
Mouse.Click(MapName.uIConfirmButton, new Point(39, 16));
else
Mouse.Click(MapName.uICancelButton, new Point(49, 8));
}
finally
{
app.Close();
}
}
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With