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;

    }

}

相关文章