我正在使用selenium进行应用程序的自动化。
我正在尝试切换到新的浏览器窗口。但我的代码卡在driver.switchTo().window(winhandles)
行。
它没有任何例外。
答案 0 :(得分:0)
您可以在窗口之间切换,如下所示:
// 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)