I was able to make the test pass with this code:
boolean result = false;
try {
WebDriver driver = SeleniumSession.get().getWrappedDriver();
ArrayList<String> handles = new ArrayList<String>(driver.getWindowHandles());
int i = 0;
for (String handle : handles) {
if(i == 1 ) {
driver.switchTo().window(handle);
Alert alert = driver.switchTo().alert();
alert.accept();
result = true;
}
i++;
}
} catch(TimeoutException | UnhandledAlertException e) {
result = true;
}
I don't like it, because I have to wait 160 seconds for the timeout to be thrown, but so far that's the only way to handle it.