Python selenium 报错 element is not attached to the page document

最近在使用 selenium 实现自动化下载,期间遇到了这个错误:

selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document

查找下发现原因是页面已经发生改变,而 selenium 还在用操作旧的 webElement。解决方式是确保在页面更新后及时重新获取 webElement。

参考:html - StaleElementReferenceException on Python Selenium - Stack Overflow
其他:[Python]selenium 爬虫报错:Message: stale element reference: element is not attached to the page document_su_2018的博客-CSDN博客

posted @ 2021-09-03 20:40  Higurashi-kagome  阅读(587)  评论(0编辑  收藏  举报