Reputation: 692
I am pressing a cancel button than according to my code it is checking some text. In Chrome and Firefox it is working fine but in IE it is taking time to perform operation on alert box but code moves to next line.
So i want some code that stop till the operation is preformed on alert box and than it goes to next Step. I am doing automation testing using selenium.
Please find piece of code:
Alert al = driver.switchTo().alert();
al.accept();
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(".//*[@id='content-body-full']/p[1]")));
assertEquals("Your cancellation request has been successfully executed.",driver.findElement(By.xpath(".//*[@id='content-body-full']/p[1]")).getText().toString());
Upvotes: 7
Views: 11490
Reputation: 5072
You want to wait until the alert is present before switching to it, similar to your 3rd row. Reference.
EDIT: try:
new WebDriverWait(driver, 60)
.ignoring(NoAlertPresentException.class)
.until(ExpectedConditions.alertIsPresent());
Alert al = driver.switchTo().alert();
al.accept();
Upvotes: 16