原文: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 按字面表達的意思大概是,所引用的元素已過時,不再依附於當前頁面。通常情況下,這是因為頁面進行了刷新或跳轉 ...

2017-08-25 09:37 0 4283 推薦指數:

查看詳情

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
 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM