使用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

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

相关推荐
_Jimmy_1 分钟前
Python 多线程使用和场景
python
梦想的初衷~3 分钟前
【完整教程】基于Python的无人机多光谱-点云融合生态三维建模:从Metashape重建到碳储量/生物量/LULC预测
python·无人机·三维重建·多光谱·无人机遥感·碳储量·生态建模
红糖奶茶28 分钟前
Python 中 while 循环计数异常的常见原因分析与正确搓搓
开发语言·python
lzqrzpt40 分钟前
LED驱动电源行业知名厂家技术特点与市场格局梳理
python·物联网
AI科技星1 小时前
乖乖数学·全域超复数统一场论:五大核心门槛与全套标准定量数据
人工智能·python·算法·金融·全域数学
ganbingfenxiang1 小时前
太原干冰定制
大数据·python
REDcker1 小时前
Android 15 16KB 内存页适配详解
android·开发语言·python
爱吃苹果的梨叔1 小时前
KVM和分布式坐席参数怎么看?端口、通道、节点都是什么意思
python
量化吞吐机2 小时前
近期AI量化开发,先跑最小流程再谈复杂功能
人工智能·python
杰佛史彦明12 小时前
PDF 表格转 CSV:Python 实现方法与代码解析
开发语言·python·pdf