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

StaleElementReferenceException from is_text_not_present #541

Closed
bri256 opened this issue Apr 11, 2017 · 3 comments
Closed

StaleElementReferenceException from is_text_not_present #541

bri256 opened this issue Apr 11, 2017 · 3 comments
Milestone

Comments

@bri256
Copy link

bri256 commented Apr 11, 2017

I just encountered this stack trace (version 0.7.5):

  File "/.../lib/python3.6/site-packages/splinter/driver/webdriver/__init__.py", line 319, in is_text_not_present
    self.driver.find_element_by_tag_name('body').text.index(text)
  File "/.../lib/python3.6/site-packages/selenium/webdriver/remote/webelement.py", line 73, in text
    return self._execute(Command.GET_ELEMENT_TEXT)['value']
  File "/.../lib/python3.6/site-packages/selenium/webdriver/remote/webelement.py", line 491, in _execute
    return self._parent.execute(command, params)
  File "/.../lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 238, in execute
    self.error_handler.check_response(response)
  File "/.../lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 193, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
  (Session info: chrome=57.0.2987.133)
  (Driver info: chromedriver=2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9),platform=Mac OS X 10.11.6 x86_64)

It seems that the body went away after the call to find_element_by_tag_name('body') but before text could be accessed from the result. The possibility of this makes sense to me based on the application that I'm testing.

I think the solution is to handle StaleElementReferenceException the same way as NoSuchElementException.

@andrewsmedina
Copy link
Member

I agree. The StaleElementReferenceException should be handled

@jaraco
Copy link
Contributor

jaraco commented Apr 21, 2018

In the meantime, is a workaround available?

@andrewsmedina andrewsmedina added this to the 0.9 milestone Apr 22, 2018
@jaraco
Copy link
Contributor

jaraco commented Apr 28, 2018

Patches are proposed in #341, #396, and #450. #396 is the best.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants