我设置了具有以下功能的 webDriver:
DesiredCapabilities ffCapabilities = DesiredCapabilities.firefox();
ffCapabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);
driver = new FirefoxBrowser(ffCapabilities);
有一个页面应该解除警报。是否有可能通过这样的捕获来捕获 UNEXPECTED_ALERT_BEHAVIOUR:
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();
}