<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弹出框、页面跳转处理
最新推荐文章于 2024-05-25 15:11:10 发布