Running Selenium WebDriver 2.37.1
I\'m receiving an intermittent problem when running a test and receive the following error:
org.openqa.selenium.No
did you open a new window? If yes, you need make driver to switch to the new window, following code is tested by me:
String currentWindow = driver.getWindowHandle();// get handle of current window
Set handles = driver.getWindowHandles();// get handle of all windows
Iterator it = handles.iterator();
while (it.hasNext()) {
if (currentWindow == it.next()) {
continue;
}
driver = driver.switchTo().window(it.next());// switch to new window
//business action
//xxxxxxx
}
driver.switchTo().window(currentWindow);//switch back to original window