Problems with a coded user interface and MessageBox - search criteria

I am currently porting my UI tests to CodedUI Tests. Now I am facing the following problem:

In my UnitTest, I call the method located in my UIMap twice. The method contains a fragment that checks whether the MessageBox window is open and has a logical parameter that switches whether to press the confirm or cancel button in the message window. Messagebox never changes (this means its name, 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 problems every time. During the second call, a Messagebox pops up, but cannot be detected by the test environment.

The search criteria assigned by CodedUiTestBuilder to the MessageBox is its name (information) and class name (# 32770).

- , ? MessageBox?

,

+3
1

. , , - UIMap MapName = new UIMap(); , .

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();
    }
}

, .

+4

All Articles