I have just started working with Cucumber + Serenity.
I would like to ignore UnhandledAlertException.
This is how chrome capabilities could be set in Selenium
capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.IGNORE);
But I am not sure what should be used in serenity.properties file to ignore the unhandled alerts.
chrome.capabilities.unexpectedAlertBehaviour = ignore
Is this correct? The problem is that I cannot test this behavior since the unexpected alert exception doesn't occur in all the runs.
So, I will get the feedback whether the above property is working only if a test fails (that I am unable to replay)
At least the below code doesn't work for me right now, so I decided to use the global setting along with the below method:
private void dismissAlertIfPresentAtStartOfScenario()
{
try
{
Alert alert = REAL_DRIVER.switchTo().alert();
String text = alert.getText();
alert.dismiss();
LOGGER.warn("Dismissed alert [{}] at start of this scenario!", text);
}
catch (NoAlertPresentException e)
{
// ignore the exception and do nothing, no alert is expected at the start of the scenario
}
}
for Chrome the answer is :
This sis equivalent to code :
Source : https://johnfergusonsmart.com/configuring-chromedriver-easily-with-serenity-bdd/
I am looking for the equivalent for Firefox but I have found nothing up to now.