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;
}
}