单击按钮后如何打开新的浏览器窗口?
我遇到的情况是,单击按钮打开带有搜索结果的新浏览器窗口。
并使用它,然后返回到原始(第一个)窗口。
回答:
您可以在以下窗口之间切换:
// Store the current window handleString 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)
以上是 单击按钮后如何打开新的浏览器窗口? 的全部内容, 来源链接: utcz.com/qa/400998.html