selenium弹出框、页面跳转处理
<span style="white-space:pre"> </span>//得到当前窗口的句柄
String currentWindow = wd.getWindowHandle();
System.out.print(currentWindow);
//得到所有窗口的句柄
Set<String> handles = wd.getWindowHandles();
Iterator<String> it = handles.iterator();
System.out.print("it:"+it);
while(it.hasNext()){
if(currentWindow == it.next())
continue;
WebDriver window = wd.switchTo().window(it.next());
//获得新窗口,新的webDriver实例。
System.out.println("title,url = "+window.getTitle()+","+window.getCurrentUrl());
window.findElement(By.xpath("//span[text()="确定"]")).click();
}声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。
- 上一篇: Selenium 处理跳转窗口
- 下一篇: selenium-web篇一,页面跳转页面
