Possible Duplicate:
Selenium 2 Alert handling with Java
If I use driver.switchTo.alert();
for checking whether the alert is present or not it, it takes more than 2 seconds.
But, if I use below logic for checking, it takes less than 1 second.
Selenium sel=new WebDriverBackedSelenium(driver, "");
b = sel.isAlertPresent();
But the problem is that if an alert is not present, it is returning false, and if the alert is present instead it throws an UnhandledAlertException
instead of just returning true.
Why is it throwing this exception instead of returning true?