使用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 小时前
某招聘平台爬虫:爬取招聘岗位数据,分析各城市薪资水平
开发语言·爬虫·python
2501_933670791 小时前
2026秋招量化分析岗技能栈:Python、SQL、统计建模、回测项目怎么准备
开发语言·python·sql
2601_962077602 小时前
python Dejavu库快速识别音频指纹实例探究
python·音乐识别·dejavu库·音频指纹识别·实例探究
科技苑2 小时前
如何用Python编程实现一个简单的Web爬虫?
人工智能·python
dayDayupbetter2 小时前
Visual C++ 2010安装与使用高手秘籍
python
隐擎fox2 小时前
深入理解网络传输层安全:TLS 指纹识别(JA3/JA4)原理与 Python 协议层检测实战
爬虫·python·网络协议·安全·网络安全·https
医疗信息化王工3 小时前
DataForge:基于 Python 的数据库批量导出 Excel 工具——从架构到部署的全流程实战
数据库·python·excel
小玮看世界4 小时前
[Python]从合并区间到传感器融合区:合并区间在传感器区域融合的实际落地
开发语言·python
Java陈序员4 小时前
轻量运维面板!一款现代化的服务器控制面板工具!
运维·服务器·python·react.js·github
2601_962097364 小时前
1. 使用 C 或 C++ 扩展 Python
python·api·c·引用计数·扩展模块