question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unexpected Alerts will hang tests indefinitely

See original GitHub issue

Hello,

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:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
mkorpelacommented, Jan 31, 2021

Fixed in #690

1reaction
mkorpelacommented, Jan 25, 2021

Title does not timeout after the failed/timeouted click. Reproduced with pure playwright.

const {chromium} = require('playwright');

(async () => {
    const browser = await chromium.launch({ headless: false });
    const context = await browser.newContext();
    const page = await context.newPage();
    await page.goto('http://localhost:8000/');
    console.log("CLICK");
    try {
        await page.click('text=First click');
    } catch (e) {
        console.log("timeout! CLICK - done -> getting title");
        try {
            console.log(await page.title());
        } catch (e) {
            console.log("exception");
        }
        console.log("Title done")
    }
    await browser.close();
  }
)();
Read more comments on GitHub >

github_iconTop Results From Across the Web

A hang occurs when an alert dialog is displayed on Chrome 52+
4) The wait for invisibility hangs indefinitely, never catching the UnhandledAlertException.
Read more >
Common Error Messages - Sauce Labs Documentation
The most common cause is that your script crashed, was forcefully interrupted, or you lost internet connectivity. If your tests don't include a ......
Read more >
VsTest Task hangs and runs forever - Visual Studio Feedback
I had a similar issue to this in past which VsTest task would hang and just run forever. Previously it was because i...
Read more >
How to handle the "unexpected alert open"? - Stack Overflow
If something is not consistently failing in WebDriver, it is 95% chance that it is a timing issue. You can use new WebDriverWait(driver).until( ......
Read more >
Calibrating a Taurus Test - BlazeMeter Docs
This is often a sign that your test is in need of calibration, which must be ... the test may fail to start,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found