0

I set up my webDriver with capabilities:

DesiredCapabilities ffCapabilities = DesiredCapabilities.firefox();
ffCapabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);
driver = new FirefoxBrowser(ffCapabilities);

There is a page where alert should be dismissed. Is it possible to catch UNEXPECTED_ALERT_BEHAVIOUR with such catch:

 private void waitNoContainer(int timeout) {
    try {(new WebDriverWait(getDriver(), timeout)).
                        until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector(CssSelectors.WAIT_CONTAINER)));
            } catch (UnhandledAlertException exc) {
                driver.switchTo().alert().dismiss();
            }
Artem Yakovlev
  • 493
  • 7
  • 22

1 Answers1

1

You can set the UNEXPECTED_ALERT_BEHAVIOUR to "ignore" and do whatever you want with the alert after it is caught.

Yuvaraj HK
  • 416
  • 5
  • 13