其他分享
首页 > 其他分享> > WebDriver switching to new window

WebDriver switching to new window

作者:互联网

String firstWindow = driver.getWindowHandle();

Set<String> allWindows = driver.getWindowHandles();

Iterator<String> windowsIterator = allWindows.iterator()

While(windowsIterator.hasNext()){

    String windowHandle = windowsIterator.next().toString();

    if(!windowHandle.equals(firstWindow)){

       driver.swithTo().window(windowHandle);

       break;

    }

}

标签:WebDriver,allWindows,String,windowHandle,driver,windowsIterator,window,switching
来源: https://www.cnblogs.com/amy2012/p/11624533.html