Is it possible to automatically handle unexpected alerts?

During testing there are situations when an unexpected alert appears and due to this the whole test suite is stuck while waiting for the alert to be handled. This is very unfortunate situation.

When using SeleniumLibrary, the test is simply failing after a while if the alert is unhandled. Also I think it is possible to handle it by default through e.g. chrome capabilities. How to do this with Browser library, is it possible to handle it with default or fail the test if not?

For example, with Playwright I tried and it is possible to use environment variable NODE_OPTIONS=–unhandled-rejections=strict and then the test is failing with ‘TimeoutError’.


Have you fixed this issue? Im with the same problem.

Also curious if anyone has a solution here? Running into a similar issue with one of our products having an unexpected alert some of the time but not all.