I have set autoAcceptAlerts capability to my tests, but there are some alerts that I need to check for their text. Currently I’m doing it like this:
String asdf = driver.switchTo().alert().getText();
Assertions.assertTrue(asdf.contains("Unable to login"));
But this sometime passes, and sometimes not, because I get “An attempt was made to operate on a modal dialog when one was not open”
Is there a way to make a small pause before the alert is automatically accepted?