栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

【解决】selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted:

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

【解决】selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted:

这里写自定义目录标题
今日做了一个h5网站的下单流程的自动化脚本,到了最后一步提交订单一直报错,尝试了各种定位方式还是报错,报错内容如下:

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)

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)

原代码:

driver.find_element(By.link_TEXT, "确认提交").click()

后来找了解决办法尝试了一下成功了:

element1=driver.find_element(By.link_TEXT, "确认提交")
driver.execute_script("arguments[0].click();",element1)

也没有解释为什么会这样查看了execute_script 的用法如下:

    def 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才能做操作,不知道理解对不对,希望有大神指出原理谢谢

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/689391.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号