Unexpected Alerts will hang tests indefinitely
See original GitHub issueHello,
I am currently investigating whether moving my project from Selenium to Browser library brings benefits, and first impression after few weeks of testing is that it is worth it. I have many test cases written for some web applications (Vaadin stateful framework) that could runs unattended for few hours. With selenium I had to use lower selenium speed (between 0.5 and 2 seconds), otherwise I would get invalid element state or stale element exceptions and so on. When using Browser library such issues don’t exist so the run is a lot faster and more stable.
But…, currently I am facing a kind of a showstopper that would prevent me to move forward. Sometimes the applications could show an unexpected alert and this will hang the tests execution indefinitely. This means, if I start the testing and come back after few hours to check the result, or try to run the suite overnight, I could have an unhandled alert on the screen instead of having the tests run finished and reports generated, and this is unacceptable.
This does not happen with Selenium, and if the alert is unhandled there is an immediate error UnexpectedAlertPresentException, the test is failing and robot framework is moving naturally to the next test case from the suite.
I tried also to use Robot Framework’s Test Timeout
, but although the timeout is exceeded, the test is never finished.
To Reproduce If needed, generate index.html with an alert and upload somewhere, e.g. with the following buttons:
<!doctype html>
<html>
<head>
<title>Title</title>
</head>
<body>
<p>Content</p>
<button type="button" onclick="javascript:alert('your msg')";>First click</button>
<button type="button">Second click</button>
</body>
</html>
Execute the following RF code:
New Browser chromium headless=false
New Context
New Page http://site/index.html
Click text=First click
Click text=Second click
Expected behavior In the case of unhandled alert, I would expect the test is simply failing with an exception rather than being stuck indefinitely.
Alternatively, Test Timeout
settings from Robot Framework should end the test case also in this situation.
Note:
When running such test directly with node and playwright, an unhandled alert can end the test with timeout exception if on the command line the flag --unhandled-rejections=strict
is used.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:8 (8 by maintainers)
Fixed in #690
Title does not timeout after the failed/timeouted click. Reproduced with pure playwright.