为什么硒中的命令可以单独起作用,但是如果在脚本中放置硒,则可以找到元素
我面临的问题是,当我运行整个脚本时,它会抛出元素的错误,无法单击或找不到。当我运行命令时,命令起作用。
如果有人能解释原因和为什么它以这种方式表现出来,我将非常感激。
CodeeXample:
driver.find_element(By.XPATH, "//div[@id=\'Content_C164_Col00\']/div/div/div[2]/div/div/div/div/div/button/span/span/span[3]").click()
driver.find_elements(By.CLASS_NAME, "fxs_c_datepicker_button")[1].click()
driver.find_element(By.CLASS_NAME, "fxs_btn.fxs_btn_cta.fxs_fRight").click()
错误:
ElementClickInterpectedException:消息:元素单击截距:元素...在点(238,772)处不可单击。其他元素会单击:... (会话信息:chrome = 101.0.4951.64) StackTrace: backtrace:
我正在担任我的编辑。
The problem i am facing is when i run the whole script it throws error of element not clickable or not found. While when i run it command per command it works.
If anyone can explain the reason and why it behaves this way i ll be very grateful.
codeExample:
driver.find_element(By.XPATH, "//div[@id=\'Content_C164_Col00\']/div/div/div[2]/div/div/div/div/div/button/span/span/span[3]").click()
driver.find_elements(By.CLASS_NAME, "fxs_c_datepicker_button")[1].click()
driver.find_element(By.CLASS_NAME, "fxs_btn.fxs_btn_cta.fxs_fRight").click()
ERROR:
ElementClickInterceptedException: Message: element click intercepted: Element ... is not clickable at point (238, 772). Other element would receive the click: ...
(Session info: chrome=101.0.4951.64)
Stacktrace:
Backtrace:
I am working in VS code as my editor.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我重现了您的问题,并出现了同样的错误。我为修复它所做的只是在单击元素之前滚动到元素。
尝试一下
,我还注意到几秒钟后,网站上出现了弹出窗口。确保单击一个,因为它可能会拦截单击“应用”按钮。
更新:
这是从打开网站到选择日期并单击“应用”按钮的完整代码。
I reproduced your problem and had the same error. What i did to fix it is just scroll to the element before clicking it.
Try this out
I also noticed that after a few seconds a popup appears on the website. Make sure you click that one away as it may intercept the click on the apply button.
Update:
Here's the full code from opening the website to selecting date and clicking the apply button.
我测试了一个有效的新版本:
I tested a new version that works: