Java Selenium - 处理页面弹出窗
2017-07-29 23:31 鸣仁 阅读(477) 评论(0) 编辑 收藏 举报1. 得到当前窗口句柄
2. 得到所有窗口句柄
3. 循环找到目标窗口
String currentWindow = driver.getWindowHandle(); Set<String> handles = driver.getWindowHandles(); Iterator<String> it = handles.iterator(); while (it.hasNext())
{ String handle = it.next(); if (currentWindow.equals(handle)) continue; WebDriver window = driver.switchTo().window(handle); }