![](/img/trans.png)
[英]Selenium element not interactable button (Python, Windows, Chromedriver)
[英]python selenium element not interactable when bot tries to click agreement button
<input id="agreement-input-mobile" class="agreement-input" type="checkbox" name="agreement" aria-describedby="agreement-content">
我试图自动化某个任务,但它需要单击一个协议按钮,但每次我尝试选择它时,我都会收到此错误
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
(Session info: chrome=87.0.4280.67)
这是我的代码行的样子
driver.find_element_by_name('agreement').click()
我不建议按名称查找元素。 使用 ID 或 xpath。 所以将driver.find_element_by_name('agreement').click()
改为driver.find_element_by_id('agreement-input-mobile').click()
代替.click()
方法,您可以尝试另一种方法,如下所示:
使用动作ActionChains
:
#following import from selenium.webdriver import ActionChains element = driver.find_element_by_id('agreement-input-mobile') action = ActionChains(driver) action.move_to_element(element).click(element).perform()
使用.execute_script
:
element = driver.find_element_by_id('agreement-input-mobile') driver.execute_script("arguments[0].click();", element)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.