Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐛 Bug]: Python - staleness_of is crashing with Node with given id does not belong to the document #15401

Open
nijel opened this issue Mar 12, 2025 · 10 comments
Labels
A-needs-triaging A Selenium member will evaluate this soon! I-defect Something is not working as intended

Comments

@nijel
Copy link
Contributor

nijel commented Mar 12, 2025

What happened?

The staleness_of predicate occasionally crashes with:

selenium.common.exceptions.WebDriverException: Message: unknown error: unhandled inspector error: {"code":-32000,"message":"Node with given id does not belong to the document"}

This happens like in a few percent of test runs. Maybe this error should consider the element to be stale as well?

How can we reproduce the issue?

old_page = driver.find_element(By.TAG_NAME, "html")
button = driver.find_element(By.ID, "login-button")
button.click()
WebDriverWait(driver, timeout).until(staleness_of(old_page))

Relevant log output

 DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:403 POST http://localhost:34823/session/cb29bcff3d26a9a5bf8a9d3ee542865b/url {'url': 'http://localhost:44713/'}
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:436 Remote response: status=200 | data={"value":null} | headers=HTTPHeaderDict({'Content-Length': '14', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'})
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:465 Finished Request
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:403 POST http://localhost:34823/session/cb29bcff3d26a9a5bf8a9d3ee542865b/window/rect {'x': None, 'y': None, 'width': 1200, 'height': 1024}
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:436 Remote response: status=200 | data={"value":{"height":1024,"width":1200,"x":10,"y":10}} | headers=HTTPHeaderDict({'Content-Length': '52', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'})
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:465 Finished Request
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:403 POST http://localhost:34823/session/cb29bcff3d26a9a5bf8a9d3ee542865b/element {'using': 'tag name', 'value': 'html'}
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:436 Remote response: status=200 | data={"value":{"element-6066-11e4-a52e-4f735466cecf":"f.96315BEE3240B233DDF88038EB78D53F.d.B4463F82CF9BAD5A90FF59C60049C91A.e.1462"}} | headers=HTTPHeaderDict({'Content-Length': '128', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'})
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:465 Finished Request
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:403 POST http://localhost:34823/session/cb29bcff3d26a9a5bf8a9d3ee542865b/element {'using': 'css selector', 'value': '[id="login-button"]'}
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:436 Remote response: status=200 | data={"value":{"element-6066-11e4-a52e-4f735466cecf":"f.96315BEE3240B233DDF88038EB78D53F.d.B4463F82CF9BAD5A90FF59C60049C91A.e.1463"}} | headers=HTTPHeaderDict({'Content-Length': '128', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'})
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:465 Finished Request
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:403 POST http://localhost:34823/session/cb29bcff3d26a9a5bf8a9d3ee542865b/element/f.96315BEE3240B233DDF88038EB78D53F.d.B4463F82CF9BAD5A90FF59C60049C91A.e.1463/click {}
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:436 Remote response: status=200 | data={"value":null} | headers=HTTPHeaderDict({'Content-Length': '14', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'})
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:465 Finished Request
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:403 GET http://localhost:34823/session/cb29bcff3d26a9a5bf8a9d3ee542865b/element/f.96315BEE3240B233DDF88038EB78D53F.d.B4463F82CF9BAD5A90FF59C60049C91A.e.1462/enabled {}
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:436 Remote response: status=404 | data={"value":{"error":"stale element reference","message":"stale element reference: stale element not found\n  (Session info: chrome=134.0.6998.35)","stacktrace":"#0 0x55eaf3e9946a \u003Cunknown>\n#1 0x55eaf3952ed0 \u003Cunknown>\n#2 0x55eaf396642b \u003Cunknown>\n#3 0x55eaf39651e2 \u003Cunknown>\n#4 0x55eaf395a479 \u003Cunknown>\n#5 0x55eaf39585df \u003Cunknown>\n#6 0x55eaf395c268 \u003Cunknown>\n#7 0x55eaf395c2f3 \u003Cunknown>\n#8 0x55eaf399f4ca \u003Cunknown>\n#9 0x55eaf39ca862 \u003Cunknown>\n#10 0x55eaf399833a \u003Cunknown>\n#11 0x55eaf39caa2e \u003Cunknown>\n#12 0x55eaf39f0ceb \u003Cunknown>\n#13 0x55eaf39ca633 \u003Cunknown>\n#14 0x55eaf39961be \u003Cunknown>\n#15 0x55eaf3997981 \u003Cunknown>\n#16 0x55eaf3e5f86b \u003Cunknown>\n#17 0x55eaf3e6373c \u003Cunknown>\n#18 0x55eaf3e46f12 \u003Cunknown>\n#19 0x55eaf3e642b4 \u003Cunknown>\n#20 0x55eaf3e2b0af \u003Cunknown>\n#21 0x55eaf3e87ad8 \u003Cunknown>\n#22 0x55eaf3e87cb6 \u003Cunknown>\n#23 0x55eaf3e982e6 \u003Cunknown>\n#24 0x7fa51929caa4 \u003Cunknown>\n#25 0x7fa519329c3c \u003Cunknown>\n"}} | headers=HTTPHeaderDict({'Content-Length': '1062', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'})
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:465 Finished Request
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:403 POST http://localhost:34823/session/cb29bcff3d26a9a5bf8a9d3ee542865b/element {'using': 'css selector', 'value': '[id="id_username"]'}
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:436 Remote response: status=200 | data={"value":{"element-6066-11e4-a52e-4f735466cecf":"f.96315BEE3240B233DDF88038EB78D53F.d.8D2E11A2AABD120F510736E8D4507135.e.1469"}} | headers=HTTPHeaderDict({'Content-Length': '128', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'})
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:465 Finished Request
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:403 POST http://localhost:34823/session/cb29bcff3d26a9a5bf8a9d3ee542865b/element/f.96315BEE3240B233DDF88038EB78D53F.d.8D2E11A2AABD120F510736E8D4507135.e.1469/value {'text': '[email protected]', 'value': ['w', 'e', 'b', 'l', 'a', 't', 'e', '@', 'e', 'x', 'a', 'm', 'p', 'l', 'e', '.', 'o', 'r', 'g']}
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:436 Remote response: status=200 | data={"value":null} | headers=HTTPHeaderDict({'Content-Length': '14', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'})
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:465 Finished Request
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:403 POST http://localhost:34823/session/cb29bcff3d26a9a5bf8a9d3ee542865b/element {'using': 'css selector', 'value': '[id="id_password"]'}
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:436 Remote response: status=200 | data={"value":{"element-6066-11e4-a52e-4f735466cecf":"f.96315BEE3240B233DDF88038EB78D53F.d.8D2E11A2AABD120F510736E8D4507135.e.1470"}} | headers=HTTPHeaderDict({'Content-Length': '128', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'})
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:465 Finished Request
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:403 POST http://localhost:34823/session/cb29bcff3d26a9a5bf8a9d3ee542865b/element/f.96315BEE3240B233DDF88038EB78D53F.d.8D2E11A2AABD120F510736E8D4507135.e.1470/value {'text': 'testpassword', 'value': ['t', 'e', 's', 't', 'p', 'a', 's', 's', 'w', 'o', 'r', 'd']}
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:436 Remote response: status=200 | data={"value":null} | headers=HTTPHeaderDict({'Content-Length': '14', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'})
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:465 Finished Request
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:403 POST http://localhost:34823/session/cb29bcff3d26a9a5bf8a9d3ee542865b/element {'using': 'tag name', 'value': 'html'}
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:436 Remote response: status=200 | data={"value":{"element-6066-11e4-a52e-4f735466cecf":"f.96315BEE3240B233DDF88038EB78D53F.d.8D2E11A2AABD120F510736E8D4507135.e.1477"}} | headers=HTTPHeaderDict({'Content-Length': '128', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'})
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:465 Finished Request
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:403 POST http://localhost:34823/session/cb29bcff3d26a9a5bf8a9d3ee542865b/element {'using': 'xpath', 'value': '//input[@value="Sign in"]'}
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:436 Remote response: status=200 | data={"value":{"element-6066-11e4-a52e-4f735466cecf":"f.96315BEE3240B233DDF88038EB78D53F.d.8D2E11A2AABD120F510736E8D4507135.e.1475"}} | headers=HTTPHeaderDict({'Content-Length': '128', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'})
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:465 Finished Request
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:403 POST http://localhost:34823/session/cb29bcff3d26a9a5bf8a9d3ee542865b/element/f.96315BEE3240B233DDF88038EB78D53F.d.8D2E11A2AABD120F510736E8D4507135.e.1475/click {}
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:436 Remote response: status=200 | data={"value":null} | headers=HTTPHeaderDict({'Content-Length': '14', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'})
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:465 Finished Request
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:403 GET http://localhost:34823/session/cb29bcff3d26a9a5bf8a9d3ee542865b/element/f.96315BEE3240B233DDF88038EB78D53F.d.8D2E11A2AABD120F510736E8D4507135.e.1477/enabled {}
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:436 Remote response: status=500 | data={"value":{"error":"unknown error","message":"unknown error: unhandled inspector error: {\"code\":-32000,\"message\":\"Node with given id does not belong to the document\"}\n  (Session info: chrome=134.0.6998.35)","stacktrace":"#0 0x55eaf3e9946a \u003Cunknown>\n#1 0x55eaf3952ed0 \u003Cunknown>\n#2 0x55eaf3939690 \u003Cunknown>\n#3 0x55eaf3937f2d \u003Cunknown>\n#4 0x55eaf39386ef \u003Cunknown>\n#5 0x55eaf39640b5 \u003Cunknown>\n#6 0x55eaf39667a6 \u003Cunknown>\n#7 0x55eaf39651e2 \u003Cunknown>\n#8 0x55eaf395a479 \u003Cunknown>\n#9 0x55eaf39585df \u003Cunknown>\n#10 0x55eaf395c268 \u003Cunknown>\n#11 0x55eaf395c2f3 \u003Cunknown>\n#12 0x55eaf399f4ca \u003Cunknown>\n#13 0x55eaf39ca862 \u003Cunknown>\n#14 0x55eaf399833a \u003Cunknown>\n#15 0x55eaf39caa2e \u003Cunknown>\n#16 0x55eaf39f0ceb \u003Cunknown>\n#17 0x55eaf39ca633 \u003Cunknown>\n#18 0x55eaf39961be \u003Cunknown>\n#19 0x55eaf3997981 \u003Cunknown>\n#20 0x55eaf3e5f86b \u003Cunknown>\n#21 0x55eaf3e6373c \u003Cunknown>\n#22 0x55eaf3e46f12 \u003Cunknown>\n#23 0x55eaf3e642b4 \u003Cunknown>\n#24 0x55eaf3e2b0af \u003Cunknown>\n#25 0x55eaf3e87ad8 \u003Cunknown>\n#26 0x55eaf3e87cb6 \u003Cunknown>\n#27 0x55eaf3e982e6 \u003Cunknown>\n#28 0x7fa51929caa4 \u003Cunknown>\n#29 0x7fa519329c3c \u003Cunknown>\n"}} | headers=HTTPHeaderDict({'Content-Length': '1270', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'})
DEBUG    selenium.webdriver.remote.remote_connection:remote_connection.py:465 Finished Request

Operating System

Ubuntu

Selenium version

Python 4.29.0

What are the browser(s) and version(s) where you see this issue?

Chromium 134.0.6998.0

What are the browser driver(s) and version(s) where you see this issue?

ChromeDriver 134.0.6998.35

Are you using Selenium Grid?

No response

@nijel nijel added I-defect Something is not working as intended A-needs-triaging A Selenium member will evaluate this soon! labels Mar 12, 2025
Copy link

@nijel, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@navin772
Copy link
Member

@nijel can you provide a full reproducible code along with the url to reproduce this issue independently? It will help in triaging

@navin772 navin772 added the J-awaiting answer Question asked of user; a reply moves it to triage again label Mar 12, 2025
@nijel
Copy link
Contributor Author

nijel commented Mar 12, 2025

As mentioned before, it isn't reliably reproducible, it happens occasionally. To me, it looks like it needs to hit a certain time when the browser is in the middle of loading the next page and the selected element is still available (“Node with given id does not belong to the document”), but is not yet stale to trigger StaleElementReferenceException.

The snippet is from our test suite, in this particular case it is testing the login page which does nothing complex (a form where submit button is clicked). It can be seen online, for example, at https://hosted.weblate.org/accounts/login/.

I've now got the failure with selenium logging enabled, posted the logs above, the full job is here: https://github.com/WeblateOrg/weblate/actions/runs/13806523670/job/38618335307

If you have any idea how to debug this deeper, I'm happy to include that in our CI.

I don't think I've seen this issue before upgrading Selenium to 4.29.0 (from 4.28.1), but it might be just a coincidence (it might also be that the Chrome and/or ChromeDriver were updated inside the GitHub Actions meanwhile).

@nijel
Copy link
Contributor Author

nijel commented Mar 12, 2025

https://issues.chromium.org/issues/375343406 might be related (but doesn't give much info).

@github-actions github-actions bot removed the J-awaiting answer Question asked of user; a reply moves it to triage again label Mar 12, 2025
@javierm
Copy link

javierm commented Mar 12, 2025

We're getting the same error in GitHub Actions quite often since two days ago. Happens with both Selenium 4.25.0 and 4.29.1. We're using Ruby with Capybara, though. My best guess is that it's related to a change in GitHub Actions and they're now using a different version of Chromium 🤔. Or maybe they changed something that made the tests slower and that somehow affects the results.

Here's an example of a test run that failed a few times with Selenium 4.25.0 and another example with Selenium 4.29.1.

We haven't been able to reproduce any of the failures, though, with each test run failing on different tests.

@nijel
Copy link
Contributor Author

nijel commented Mar 12, 2025

Looking back at the workflow logs, I can't locate such an issue with Chromium 133.0.6943.0 / ChromeDriver 133.0.6943.141 which were used before. With Chromium 134.0.6998.0 / ChromeDriver 134.0.6998.35 there is quite likely that the test will fail.

nijel added a commit to nijel/weblate that referenced this issue Mar 12, 2025
Chromium 134 seem to broke Selenium and it throws WebDriverException
when element is about to get stale. This catches the error and retries
the operation after a short delay.

See SeleniumHQ/selenium#15401
nijel added a commit to nijel/weblate that referenced this issue Mar 12, 2025
Chromium 134 seem to broke Selenium and it throws WebDriverException
when element is about to get stale. This catches the error and retries
the operation after a short delay.

See SeleniumHQ/selenium#15401
@nijel
Copy link
Contributor Author

nijel commented Mar 12, 2025

WeblateOrg/weblate#14187 seems to be a workaround for us.

nijel added a commit to WeblateOrg/weblate that referenced this issue Mar 12, 2025
Chromium 134 seem to broke Selenium and it throws WebDriverException
when element is about to get stale. This catches the error and retries
the operation after a short delay.

See SeleniumHQ/selenium#15401
@javierm
Copy link

javierm commented Mar 13, 2025

We've used the setup-chrome action to run the tests with several versions of Chrome 132 and Chrome 133, each in combination with Selenium 4.25.0 first and then Selenium 4.29.1. We get the same behavior in all cases: apparently random "-32000 Node with given id does not belong to the document" errors with no apparent cause, even on simple tests that only go to a page, click on a button and check the result. The screenshots of the failures just show a regular browser window showing that everything apparently behaves as it should.

With Chrome 132.0.6834.83 we also get another apparently random error (we still get the "-32000" error as well with this version):

     Selenium::WebDriver::Error::WebDriverError:
       aborted by navigation: loader has changed while resolving nodes
         (Session info: chrome=132.0.6834.83)

@pixeltrix
Copy link

We're getting this a lot in our RSpec system specs - the pattern that fails is this:

click_link "Add post"
expect(page).to have_content("New post")

fill_in "Title", with: "Chrome/chromedriver 134 errors"

click_button "Submit"
expect(page).to have_content("Post updated successfully")

Which gives an "Node with given id does not belong to the document" error because the redirect hasn't finished. When we set an expectation on the path the problem goes away:

click_link "Add post"
expect(page).to have_content("New post")

fill_in "Title", with: "Chrome/chromedriver 134 errors"

click_button "Submit"
expect(page).to have_current_path("/posts") # wait for redirect
expect(page).to have_content("Post updated successfully")

@javierm
Copy link

javierm commented Mar 16, 2025

Possibly related: teamcapybara/capybara#2800.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-needs-triaging A Selenium member will evaluate this soon! I-defect Something is not working as intended
Projects
None yet
Development

No branches or pull requests

4 participants