StaleElementReferenceException
- 问题报错
- 解决方法
问题报错
# 点击下一页
web.find_element_by_xpath('//*[@id="nexthehe"]').click()
The element is no longer attached to the DOM
:元素不再附加到DOM上
解决方法
元素不再附加到DOM上
分析原因
有可能是引导了不再附加到DOM树的元素(比如,document.documentElement)
也可是是页面内容没有加载出来,找不到
解决方法:
仍然是再次查找该元素
try:
# 点击下一页
web.find_element_by_xpath('//*[@id="nexthehe"]').click()
# time.sleep(1)
except Exception:
print('点击下一页出错!')
web.find_element_by_xpath('//*[@id="nexthehe"]').click()
参考:
link
link
加油!
感谢!
努力!
最后
以上就是体贴翅膀最近收集整理的关于Selenium报错:StaleElementReferenceException异常问题报错解决方法的全部内容,更多相关Selenium报错内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复