I have a Selenium WebDriver
based test, which fill a form and send it for processing. During time period of processing a window is opened. Sometimes processing fails, but this window is not closed, so we can't get result. Purpose of this test is to get the result. I try to set a timeout for this window, so it should be closed after a predefined time (I set it to 10 seconds now.) by WebDriver
and form should be resent. I use following code.
WebElement webElement;
try {
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.findElement(sendButton).click();
webElement = wait.until(ExpectedConditions.presenceOfElementLocated(By.className("button-resultdown")));
} catch (TimeoutException ex) {
webElement = null;
} finally {
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
}
if (webElement == null) {
driver.findElement(popUpClose).click();
TimeUnit.SECONDS.sleep(4);
driver.findElement(sendButton).click();
}
Popup window is not closed automatically after 10 seconds. I checked element locators, those are valid.
driver.findElement(popUpClose).click()
?