ERROR net.serenitybdd.core.Serenity - No alert is present (WARNING: The server did not provide any stacktrace information)
I get this error when I try to detect an alert with this code:
Alert alertBox = getDriver().switchTo().alert();
The alert popup does show up, but it is not exactly the same when I execute the operation via Selenium WebDriver and manualy. This might be the source of the problem but I don't know why the popup is different.
The alert when done with Selenium
This is the function that calls the alert:
function confirm_remove() {
return window.confirm("Alert message");
}
Thanks for your help
UPDATE:
Ok I found a way to bypass the problem but not really solve it.
I tried inserting waits and sleep like you suggested me to but it did not solve the problem, the alert was still undetected.
In my project I am using a Test class which calls steps from my Steps class which calls webElements from my Page class. The thing is that between the step which clicks on the "Delete" button and the step that manages the alert, Selenium loses the handling of the alert. So I regrouped those two steps and Selenium seems to handle the alert well.