我是靠谱客的博主 专注外套,这篇文章主要介绍【解决】selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted:,现在分享给大家,希望可以做个参考。
这里写自定义目录标题
今日做了一个h5网站的下单流程的自动化脚本,到了最后一步提交订单一直报错,尝试了各种定位方式还是报错,报错内容如下:
复制代码
1
2
3selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <a data-v-15c2be92="" href="javascript:void(0)" class="checkout__foot-btn all-disable">...</a> is not clickable at point (304, 637). Other element would receive the click: <div class="vc-switch">...</div> (Session info: chrome=84.0.4147.105)
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element … is not clickable at point (304, 637). Other element would receive the click:
…
(Session info: chrome=84.0.4147.105)
原代码:
复制代码
1
2
3driver.find_element(By.LINK_TEXT, "确认提交").click()
后来找了解决办法尝试了一下成功了:
复制代码
1
2
3element1=driver.find_element(By.LINK_TEXT, "确认提交") driver.execute_script("arguments[0].click();",element1)
也没有解释为什么会这样查看了execute_script 的用法如下:
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22def execute_script(self, script, *args): """ Synchronously Executes JavaScript in the current window/frame. :Args: - script: The JavaScript to execute. - *args: Any applicable arguments for your JavaScript. :Usage: driver.execute_script('return document.title;') """ converted_args = list(args) command = None if self.w3c: command = Command.W3C_EXECUTE_SCRIPT else: command = Command.EXECUTE_SCRIPT return self.execute(command, { 'script': script, 'args': converted_args})['value']
我理解就是应为我定位的元素需要先执行JavaScript才能做操作,不知道理解对不对,希望有大神指出原理谢谢
最后
以上就是专注外套最近收集整理的关于【解决】selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted:的全部内容,更多相关【解决】selenium.common.exceptions.ElementClickInterceptedException:内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复