Reputation: 149
Is there any command to wait for the popup to close.nActually my project is like on home page popup will appear and after choosing city pop gets close. Then I am able to click on sign in button. But when i run the script, before closing the pop up my next command which is click on sign in button are executing. So test script getting fail. When I used sleep (10000),then my script is working fine. But every time i don't want to use sleep,
Please help me with your answers
Thanks
Upvotes: 0
Views: 10582
Reputation: 42518
I would wait for the popup to be hidden :
WebDriverWait wait = new WebDriverWait(driver, 5000); // 5 seconds timeout
wait.until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector("popup locator")));
Upvotes: 2
Reputation: 1494
One way to loop over and over rather than a fixed wait:
WebDriver driver = new FirefoxDriver();
//Accept the expected alert
driver.switchTo().alert().accept();
//Wait dynamically to disappear
int i=0;
while(i<15)
{
try{
driver.switchTo().alert();
Thread.sleep(2000);
}catch(NoAlertPresentException a){
break;
}
catch (Exception e) {
}
i++;
}
Upvotes: 1