Add fix for capybara/chromedriver issue causing brittle tests #290#159
Merged
Add fix for capybara/chromedriver issue causing brittle tests #290#159
Conversation
Our feature tests using Capybara and Chromedriver are intermittently
failing with the following error:
unknown error: unhandled inspector error: {"code":-32000,"message":"Node with given id does not
belong to the document"}
This can usually be fixed by rerunning the tests.
In our CI environments and end-to-end tests we pin chrome to 128 where
the issue doesn't occur.
It's harder to pin chrome in local development environments.
This commit takes a different approach found in a comment on the
capabara issue: It adds a monkey patch to the Selenium driver to
intercept the initialization of `UnknownError` and raise a
`StaleElementReferenceError` instead.
This makes the test retry.
This commit can be reverted once the issue is resolved.
teamcapybara/capybara#2800
d43bdb1 to
6bf051b
Compare
miles-smith
approved these changes
Oct 13, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes intermittent errors "Node with given id does not belong to the document" by duplicating the monkey patch from alphagov/forms-admin@5ea9876#diff-c36c07a0c7f499b1b95634f9dce1a10ebf4d10a9dee872f39f746a9efa555ddbR1-R34
This is needed until teamcapybara/capybara#2800 is fixed.
The
bundle auditwarning is fixed separately on PR #158.The test failures are all integration tests, and can be ignored: recent chrome driver changes have made the integration tests very brittle, but the front-end is no longer in use (and the code for it is probably still working fine anyway).