我有一个简单的button应用程序,它用showDialog()方法显示另一个窗体。我想在此打开的表单中单击“关闭”按钮,但调用session.findElementByName(“关闭”)将尝试从第一个失败的表单中单击“关闭”按钮(因为另一个表单使用showDialog()打开)。
有什么提示我如何切换到这个新表单吗?
switchto似乎不起作用。
调用showDialog()后,会话中有两个窗口句柄,但切换似乎不起作用。
[TestMethod]
public void AppDriverTest_Close_Another_Window()
{
Session.FindElementByAccessibilityId("button1").Click();
Session.FindElementByName("Close").Click();
}
// Form1 has button with following click method
private void button1_Click(object sender, EventArgs e)
{
var frm = new Form2();
frm.ShowDialog();
}