![](/img/trans.png)
[英]How to switch to the new browser window, which opens after click on the button?
[英]How to switch to new Browser Window?
我正在使用硒自动化应用程序。
我正在尝试切换到新的浏览器窗口。 但是我的代码卡在了行driver.switchTo().window(winhandles)
。
它没有任何例外。
您可以在以下窗口之间切换:
// Store the current window handle
String winHandleBefore = driver.getWindowHandle();
// Perform the click operation that opens new window
// Switch to new window opened
for(String winHandle : driver.getWindowHandles()){
driver.switchTo().window(winHandle);
}
// Perform the actions on new window
// Close the new window, if that window no more required
driver.close();
// Switch back to original browser (first window)
driver.switchTo().window(winHandleBefore);
// Continue with original browser (first window)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.