我正在玩一个小挑战,该挑战被设置为自动对调查猴子进行表单响应,为此示例,我设置了一个虚拟调查。
本质上,selenium 无法单击该框,因为按钮显示模糊了它。
ElementClickInterceptedException: Message: Element input id="234136539_1601280849" class="checkbox-button-input " name="234136539[]" type="checkbox"> is not clickable at point (237.5,345.5) because another element span class="checkbox-button-display "> obscures it
我看过this question这是 Java 特有的,我不太清楚如何克服这个问题,我尝试过隐式等待,单击它周围的框,但在不学习 Java 的情况下有点迷失从哪里开始。
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get('https://www.surveymonkey.com/r/L9DJGXR')
vote_check = driver.find_element_by_id('234136539_1601280849')
vote_check.click()
此代码应该可以复制虚拟调查的问题。
最佳答案
右键单击“我”旁边的复选框并选择检查...选择了哪个元素? SPAN
。这是因为 SPAN
与您要单击的 INPUT
重叠。这就是该错误告诉您的内容。您正在尝试单击被另一个元素覆盖的元素。 Selenium 无法“查看”页面以查看下面的元素是否真正被遮挡。
解决方案是单击错误中的 SPAN
或 LABEL
。你做什么并不重要,两者都会起作用。下面有两个 CSS 选择器
[id='234136539_1601280849'] + label // clicks the LABEL
^ has this ID
^ '+' means sibling
^ LABEL tag
[id='234136539_1601280849'] + label > span // clicks the SPAN
everything is the same as above until...
^ '>' means child
^ SPAN tag
关于python - 尝试通过 Selenium 和 Python 单击 Surveymonkey.com 中的复选框时出现 ElementClickInterceptedException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55022107/