繁体   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