First time I've seen this particular random failure https://www.drupal.org/pift-ci-job/2629301

1) Drupal\FunctionalJavascriptTests\Tests\JSWebAssertTest::testJsWebAssert
WebDriver\Exception\CurlExec: Curl error thrown for http POST to http://chromedriver-jenkins-drupal-patches-175432:9515/session/3d49e65f913131440b1a261ae7b7ebd0/execute with params: {"script":"return arguments[0].getAttribute(\"id\")","args":[{"ELEMENT":"0.49279528092055735-44"}]}

Retries: 10 and last result:
{"sessionId":"3d49e65f913131440b1a261ae7b7ebd0","status":10,"value":{"message":"stale element reference: element is not attached to the page document\n  (Session info: headless chrome=106.0.5249.103)\n  (Driver info: chromedriver=106.0.5249.61 (511755355844955cd3e264779baf0dd38212a4d0-refs/branch-heads/5249@{#569}),platform=Linux 4.9.0-0.bpo.6-amd64 x86_64)"}}

Steps to reproduce

In another galaxy issue, far, far away, I reproduced the first error and took screenshots when the assertion fails. That looks like this:
CLUNK
Or in fact any number in that text except for the wanted 1100.

So the assertion is done whilst the DOM-manipulation through JavaScript isn't finished.
Which is number 2 on the list of why the "stale element"-stuff happens:

The failure can only happen for two reasons:
1. The element under test is removed from the DOM.
2. The page changed whilst after getting the element under test.

Proposed resolution

Many moons ago, when we were on some faster testbot servers, the assertion would be called when the DOM-manipulation was long done.

However, nowadays stuff goes slower, so we need to assert the elements _after_ the JS-magic is done.

Comments

acbramley created an issue. See original summary.

penyaskito’s picture

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

spokje’s picture

Assigned: Unassigned » spokje
StatusFileSize
new2 KB

Let's first proof that there still is a random test failure.

Here's a patch that runs _only_ \Drupal\FunctionalJavascriptTests\Tests\JSWebAssertTest 500 times.

spokje’s picture

Issue summary: View changes
StatusFileSize
new12.94 KB
spokje’s picture

The normal routine to prove a random failure is fixed is to run the failing patch and the patch with the fix at the same time, whilst the latter has to have ~8000 - 10.000 failure free runs to prove it's credibility.

So let's do that here.

spokje’s picture

StatusFileSize
new976 bytes

25.000 runs is fine with me, here's the actual patch

spokje’s picture

Assigned: spokje » Unassigned
Status: Active » Needs review
spokje’s picture

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Improvement looks good. Thanks @Spokje for explaining too!

  • catch committed 160c5097 on 10.0.x
    Issue #3350973 by Spokje, acbramley: [random failure] Curl error thrown...

  • catch committed e4149f9a on 10.1.x
    Issue #3350973 by Spokje, acbramley: [random failure] Curl error thrown...

  • catch committed 3eb1472b on 11.x
    Issue #3350973 by Spokje, acbramley: [random failure] Curl error thrown...

  • catch committed 341aa5b1 on 9.5.x
    Issue #3350973 by Spokje, acbramley: [random failure] Curl error thrown...
catch’s picture

Version: 11.x-dev » 9.5.x-dev
Status: Reviewed & tested by the community » Fixed

Really nice find!

Committed/pushed to 11.x and cherry-picked back through to 9.5.x, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.