I wanna close the pop up window (known window name), and back to the original window. What shall I do? If I can't get a constant of the close button in window. so is there any general behavior to reach the goal?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Have you tried:
selenium.Close();
selenium.SelectWindow("null");
回答2:
Using WebDriver (shown with Java) you could do something like this:
// 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);
回答3:
I dont know if you are still looking for an answer, but i had some troubles with this. After spending more than one hour on searching for a way to do it, dont want to use webdriver. I tried using the garbage collector:
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
This worked for me.