我目前正在将我的 UI 测试移动到 CodedUI 测试。现在,我面临以下麻烦:
在我的 UnitTest 中,我两次调用位于 UIMap 中的方法。该方法包含一个检查消息框窗口是否打开的片段,并具有一个布尔参数,用于切换是否单击消息框中的确认或取消按钮。消息框永远不会改变(意味着它的标题、文本、按钮)。
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();
}
}
第一次通话每次都没有任何问题。在第二次调用期间,会弹出消息框,但无法被测试框架定位。
CodedUiTestBuilder 分配给 MessageBox 的搜索条件是它的名称 (Info) 和类名 (#32770)。
有人对这里可能出现的问题有任何提示吗?这是 MessageBox 控件中缺少一些可访问性吗?
问候,
塞布