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();
}声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。
- 上一篇:没有了
- 下一篇:没有了
