使用selenium时出现element click intercepted报错的解决办法

win10,python3.8.10。

selenium版本如下(用pip38 show selenium查看):

在定位中,定位了一个按钮(特点:button下还有span然后才是文本),代码如下:

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options

confirm_button=WebDriverWait(xxx_driver, 5).until(
    EC.element_to_be_clickable((By.XPATH,'//button/span[contains(text(), "确定")]'))
)

定位是没有问题的。然后执行如下点击代码:

confirm_button.click()

就会报错了:element click intercepted: Element <span>...</span> is not clickable。 

解决办法:

将点击代码改为如下即可:

webdriver.ActionChains(xxx_driver).move_to_element(confirm_button).click(confirm_button).perform()

可以参考我的文章: selenium中出现 Other element would receive the click的解决方式-CSDN博客

也可以参考文章:

element click intercepted: Element <span>...</span> is not clickable报错解决办法_element click intercepted: element <span>...</span-CSDN博客

或者:

https://www.cnblogs.com/soundcode/p/15910729.html

对于这篇文章,我测试第一种方法并不好用,第二种好用。

最近更新

  1. TCP协议是安全的吗?

    2024-04-26 10:54:02       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-04-26 10:54:02       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-04-26 10:54:02       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-04-26 10:54:02       20 阅读

热门阅读

  1. 企业网络安全的全方位解决方案

    2024-04-26 10:54:02       12 阅读
  2. 大数据任务运维方案

    2024-04-26 10:54:02       12 阅读
  3. 【13】编写shell-备份mysql数据

    2024-04-26 10:54:02       12 阅读
  4. Vue中嵌套路由(子路由)的使用

    2024-04-26 10:54:02       13 阅读
  5. 前端如何优化工程

    2024-04-26 10:54:02       15 阅读
  6. 基于python的NBA球员数据可视化分析的设计与实现

    2024-04-26 10:54:02       13 阅读
  7. 理解彩虹攻击:颜色缤纷的威胁

    2024-04-26 10:54:02       11 阅读
  8. hanoi塔

    hanoi塔

    2024-04-26 10:54:02      15 阅读