原文:關於報錯stale element reference: element is not attached to the page document處理

現象 在執行腳本時,有時候引用一些元素對象會拋出如下異常 org.openqa.selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document 報錯原因 官方給出解釋如下: The element has been deleted enti ...

2018-02-05 10:44 0 4471 推薦指數:

查看詳情

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

抓取網頁代碼后,由於是在同一個li標簽下,所以使用一次性抓取,所有的a標簽,然后循環做不同的操作,但是拋出找不到元素異常。 屏幕日志: 最后原因是因為刷新頁面導致之前拿到的元素對象失效,無法鎖定,從而導致改報錯。 坑: 頁面點擊之后刷新了 之前抓取的元素對象失效 ...

Sat Oct 12 02:35:00 CST 2019 0 319
selenium爬蟲報錯:Message: stale element reference: element is not attached to the page document 促成1分鍾爬完斗魚主播信息。

先看代碼 執行后只爬了兩頁就報錯誤: 這樣的錯誤是說我已經點擊了翻頁,但是還沒有完成翻頁,於是又爬了一次當前頁,然后再要執行翻頁時頁面已經刷新了,前面找到的翻頁元素已經過期了,無法執行點擊。 當然最有效的方法是在點擊翻頁后強制sleep幾秒,但是這樣會浪費時間 ...

Thu Oct 25 09:09:00 CST 2018 1 12881
Selenium2學習-012-WebUI自動化實戰實例-010-解決元素失效:StaleElementReferenceException: stale element reference: element is not attached to the page document

元素失效的想象提示信息如下圖所示,此種問題通常是因為元素頁面刷新之后,為重新獲取元素導致的。 解決此類問題比較簡單,只需要在頁面刷新之后,重新獲取一下元素,就可以消除此種錯誤了。 以下以易迅網 ...

Wed Jun 17 22:53:00 CST 2015 1 18370
 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM