How to wait for an alert in Selenium webdriver ? [duplicate]

0
0

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 ?

  • You must to post comments
0
0

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;
}
}
}
  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Website