Coded UI Test and MessageBox search Criteria problem

  • 1 Replies
  • 1263 Views
Coded UI Test and MessageBox search Criteria problem
« on: April 28, 2016, 20:15:55 pm »
I am moving all my tests to CodedUI.

In one of my tests I call a method from my UIMap twice. The method contains code that checks if a MessageBox Window is open and has a boolean parameter that switches whether to click accept/cancel button in the MessageBox. The Messagebox never changes (Title, Text, Buttons).

Code
public void CheckMessageBox(bool t)
{
    ApplicationUnderTest app = ApplicationUnderTest.Launch("app.exe");
    try
    {
        Assert.AreEqual(true, uImessageBoxWindow.Exists);
        if (t == true)
            Mouse.Click(uIAcceptButton, new Point(17, 40));
        else
            Mouse.Click(uICancelButton, new Point(27, 48));
    }
    finally
    {
        app.Close();
    }
}

The first call works without problems. When calling the method a second time- the MessageBox pops up, but it cannot be located by the testing framework's CodedUITestBuilder.

What could the problem be possibly ?

*

Oren

  • **
  • 59
Re: Coded UI Test and MessageBox search Criteria problem
« Reply #1 on: May 01, 2016, 17:17:58 pm »
Try refreshing the map from your test method. This way, when you call the method in the partial class for a second time just add in:

Code
UIMap MapName = new UIMap();

This will refresh the map and you can call your window again without the refresh problem.

Code
ApplicationUnderTest app = ApplicationUnderTest.Launch("app.exe");
try
{
    Assert.AreEqual(true, uImessageBoxWindow.Exists);

    UIMap MapName = new UIMap();
    if (t == true)
        Mouse.Click(uIAcceptButton, new Point(17, 40));
    else
        Mouse.Click(uICancelButton, new Point(27, 48));
}
finally
{
    app.Close();
}

 

Sitemap 1 2 3 4 5 6 7 8