簡體   English   中英

Selenium 元素不可交互按鈕(Python、Windows、Chromedriver)

[英]Selenium element not interactable button (Python, Windows, Chromedriver)

錯誤:引發異常類(消息,屏幕,堆棧跟蹤)selenium.common.exceptions.ElementNotInteractableException:消息:元素不可交互(會話信息:chrome = 86.0.4240.75)

我的代碼:driver.find_element_by_xpath('//button[contains(text(),"Buy Now")]').click()

html: https://i.stack.imgur.com/h0wGd.png

由於我們沒有完整的HTML頁面來查找准確的xpath而且我們有代碼的小屏幕截圖,因此您可以嘗試使用不同的xpath技術查找元素。

//button[@class='button bits' and contains(., 'Buy Now')]

然后,您可以使用以下選項之一獲取元素並單擊它。

選項1

driver.find_element(By.XPATH, "//button[@class='button bits' and contains(., 'Buy Now')]").click()

選項 2

driver.find_element(By.XPATH, "//button[@class='button bits' and contains(text(), 'Buy Now')]").click()

根據硒文檔,該錯誤發生在:

"Thrown when an element is present in the DOM but interactions
with that element will hit another element do to paint order"

確保您的元素是唯一標識的並使用等待。 如果還不夠,請通過 JavaScript 執行點擊操作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM