StaleElementReferenceException
Problem reporting and solution
Problem reporting error
# clcik to the next page
web.find_element_by_xpath('//*[@id="nexthehe"]').click()
the element is no longer attached to the DOM
: the element is no longer attached to the dom
Solution:
The element is no longer attached to the dom
Analyze the cause
It is possible that elements that are no longer attached to the DOM tree are guided (for example, document. Documentelement)
But the page content is not loaded and cannot be found
resolvent:
Still, looking for the element again
try:
# clcik to the next page
web.find_element_by_xpath('//*[@id="nexthehe"]').click()
# time.sleep(1)
except Exception:
print('failed to next page')
web.find_element_by_xpath('//*[@id="nexthehe"]').click()
Read More:
- Python Selenium: element is not attached to the page document error
- [Solved] Python Selenium Error: AttributeError: ‘WebDriver‘ object has no attribute ‘find_element_by_xpath‘
- [Solved] Python-selenium locates an element cannot be clicked error: ElementClickInterceptedException
- [Solved] Selenium Error: ERROR: Message: element not interactable
- [Solved] Selenium python send_key error: list object has no attribute
- [Python] Right-click Selenium to Save the picture error: attributeerror: solution to module ‘pyscreen’ has no attribute ‘locationonwindow’
- Python Selenium Common Keyboard Controls
- [Solved] selenium.common.exceptions.JavascriptException: Message: javascript error: windows is not defined
- [Solved] Selenium.common.exceptions.WebDriverException: Message: newSession
- Python3.7 Capture exception error: Too broad exception clause
- Python+Selenium Error: AttributeError: ‘WebDriver‘ NameError: name ‘By‘ is not defined
- [Solved] AttributeError: module ‘selenium.webdriver‘ has no attribute ‘Chrome‘
- [Solved] selenium.common.exceptions.WebDriverException: Message: unknown error: DevToolsActivePort file doesn
- Mac Selenium Use Error: Can not connect to the Service chromedriver
- Chromdriver Install error: File “C:\python37\lib\site-packages\selenium\webdriver\common\service.py”, line 76, in start stdin=PIPE) File…
- [Solved] selenium Error: ERROR:ssl_client_socket_impl.cc(962)] handshake failed; returned -1, SSL
- python3 Execute except Exception, e Error [How to Solve]
- Python: How to Use try exception to Display Abnormal Error Information
- [Solved] RuntimeError (note: full exception trace is shown but execution is paused at: <module>)
- python2.7 ExcelWriter error Exception caught in workbook destructor. Explicit close() may be require