我想关闭弹出窗口(已知窗口名称),然后回到原来的窗口。我该怎么办?如果我无法在窗口中获得关闭按钮的常量。那么有没有达到目标的一般行为?
问问题
28499 次
3 回答
8
使用 WebDriver(用 Java 显示)你可以做这样的事情:
// instantiate your driver
...
// get window handle
String baseWindowHdl = driver.getWindowHandle();
// navigate to pop-up
...
// close pop-up
driver.close();
// switch back to base window
driver.switchTo().window(baseWindowHdl);
于 2011-09-12T08:21:47.403 回答
6
你有没有尝试过:
selenium.Close();
selenium.SelectWindow("null");
于 2011-01-18T04:40:14.120 回答
0
我不知道你是否还在寻找答案,但我对此有一些麻烦。在花了一个多小时寻找一种方法之后,不想使用 webdriver。我尝试使用垃圾收集器:
Selenium selenium = new DefaultSelenium(......);
selenium.start();
................
selenium.close(); //to terminate testing window
selenium = null; //make sure there are no references to the file
System.gc(); //now the garbage collector can kick in
这对我有用。
于 2012-11-12T21:13:24.170 回答