简体   繁体   English

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

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

error: raise exception_class(message, screen, stacktrace) selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable (Session info: chrome=86.0.4240.75)错误:引发异常类(消息,屏幕,堆栈跟踪)selenium.common.exceptions.ElementNotInteractableException:消息:元素不可交互(会话信息:chrome = 86.0.4240.75)

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

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

Since we do not have the full HTML page to find an accurate xpath and we have a small screenshot of the code, you could try to find the element using a different xpath technique.由于我们没有完整的HTML页面来查找准确的xpath而且我们有代码的小屏幕截图,因此您可以尝试使用不同的xpath技术查找元素。

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

Then, you could get the element and click on it by using one of the following options.然后,您可以使用以下选项之一获取元素并单击它。

Option 1选项1

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

Option 2选项 2

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

According to selenium documentation, that error occurs when:根据硒文档,该错误发生在:

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

Make sure that your element is unique identified and use a wait.确保您的元素是唯一标识的并使用等待。 If is not enough, perform the click action via JavaScript.如果还不够,请通过 JavaScript 执行点击操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM