Possible Duplicate:
selenium 2.4.0, how to check for presence of an alert
I am using the following code to close the alert window :
Alert alert3 = driver.switchTo().alert();
alert3.dismiss();
The alert appears a few seconds after the opening of the main window.
How can I wait and check if alert appears ?
No default method for waiting for alert.
but, you can write your own method something like this.
waitForAlert(WebDriver driver)
{
int i=0;
while(i++<5)
{
try
{
Alert alert = driver.switchTo().alert();
break;
}
catch(NoAlertPresentException e)
{
Thread.sleep(1000);
continue;
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With