selenium 提示 stale element reference: element is not attached to the page document
BasePage:
# 視窗切換
def switch_handles(self):
handles = self.driver.window_handles
try:
self.driver.switch_to.window(handles[-1])
logger.info("Switch to window :%s" % self.driver.current_window_handle)
except NameError as e:
logger.error("Failed to switch other window")
Test:
homepage = HomePage(self.driver)
homepage.click_news_link()
newspage = NewsHomePage(self.driver)
newspage.switch_handles()
newspage.click_sports()
報錯:selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
求大神解惑,網上有說重新定位元素,但重新定位不就失去了 po 封裝的意義啦
相關文章
- selenium3 踩坑--move_to_element()報錯
- Element-Ui元件(三十九)Tooltip 文字提示UI元件
- element
- Element 利用Tooltip提示框實現動態顯示文字提示
- presence_of_element_located對比visibility_of_element_located
- Element學習
- element-uiUI
- Unknown custom element: <> -
- Remove Element 解答REM
- Selenium系列教程-06 圖片上傳以及Web Element常用操作方法Web
- 初識Element(1)
- Widget、RenderObject 與 ElementObject
- [leetcode]remove-elementLeetCodeREM
- QianKun 解決element ui 和 element-plus 樣式衝突UI
- Vue3+Vite+Ts+Element Element的元件型別丟失VueVite元件型別
- vue-element-admin 入坑記(一)vue-element-admin 中文Vue
- SAP MRKO Error - For document type RE, an entry is required in field Reference -ErrorUI
- element-plus隨筆
- 處理 Element Plus 告警
- element 手寫季度元件元件
- Element plus 圖示使用
- vue引入element-uiVueUI
- element-ui坑點UI
- LeetCode Kth Largest Element in an ArrayLeetCode
- Flutter -- Element生命週期Flutter
- ? Element UI 新春快報UI
- element-ui基本使用UI
- LeetCode 169. Majority ElementLeetCode
- leetcode-27. Remove ElementLeetCodeREM
- Leetcode 27 Remove-ElementLeetCodeREM
- Vue Element校驗validateVue
- 162. Find Peak Element
- 深入前端之replaced element前端
- Element theme-chalk 分析
- Input報錯“Form elements must have labels: Element has no title attribute Element has no placeholde”ORM
- 【小程式自動化Minium】二、元素定位-Page介面中的 get_element() 與 get_elements()
- element-ui裡Form 表單內給label內容新增圖示提示UIORM
- element-ui匯出excel表格,程式碼基於vue-element-admin-masterUIExcelVueAST