InvalidSelectorError: Compound class names not permitted报错处理
InvalidSelectorError: Compound class names not permitted报错处理
环境:python3.6 + selenium 3.11 + chromedriver.exe
我们在解析网页的时候,总是会遇到大量的tag,如何精确定位到这些tag,也是有很多的方法。
今天在用 find_element_by_class_name获取一个节点对象时,报了个错 Compound class names not permitted.
原始代码:
selected_div = driver.find_element_by_class_name('next-pagination next-pagination-normal next-pagination-medium medium pagination')

修改后的代码:
selected_div = driver.find_element_by_css_selector("[class='next-pagination next-pagination-normal next-pagination-medium medium pagination']")
或者:
selected_div = driver.find_element_by_css_selector(".next-pagination.next-pagination-normal.next-pagination-medium.medium.pagination")
这两段代码都可以正常获取到所需对象。
总结:
在获取包含多个class名称的tag对象时
建议使用:
find_element_by_css_selector(".xx.xxx.xxxxx")
或者
find_element_by_css_selector("[class='xx xxx xxxxx']")
InvalidSelectorError: Compound class names not permitted报错处理的更多相关文章
- selenium的报错信息:selenium.common.exceptions.InvalidSelectorException: Message: invalid selector: Compound class names not permitted
报错信息:selenium.common.exceptions.InvalidSelectorException: Message: invalid selector: Compound class ...
- ffmpeg Operation not permitted 报错的解决过程记录
问题重现 由于视频的录制过程出现了一些小问题,需要重新将视频文件切割和合并,找了几个视频编辑软件来做这个事情,最终的结果都不是特别满意,当时已经挺晚的了,本来打算上床睡觉第二天再去想辙,从椅子上起身的 ...
- selenium实战-Compound class names not permitted
这个复合类其实就是嵌套类,使用最后一个作为类名即可
- Nginx报错: "Too many open files accept" 和 "could not build the server_names_hash"
一.访问Nginx时,报错:"accept() failed (24: Too many open files)"原因时:nginx的连接数超过了系统设定的最大值造成的. 处理办法 ...
- docker—tomcat 报错:Failed to get D-Bus connection: Operation not permitted
docker search centos 查系统镜像 docker pull docker.io/centos 进入容器 [root@git opt]# docker images REPOSIT ...
- 使用npm install报错-4048 operation not permitted解决
刚刚使用npm install时一直报错-4048 operation not permitted,也尝试了多种方法,终于使问题得到解决,这里总结几种方法,先贴图: 一:权限问题 首先看到operat ...
- 巨坑npm run dev 报错 终于找到正确答案 Error: EPERM: operation not permitted, open '/data/public/build/css/add.p
Windows10环境 npm run dev 报错 终于找到正确答案 Error: EPERM: operation not permitted, open '/data/public/build ...
- Android版本28使用http请求报错not permitted by network security policy
Android版本28使用http请求报错not permitted by network security policy android模拟器调试登录的时候报错 CLEARTEXT communic ...
- 启动servlet报错:The servlets named [DemoServlet] and [main.java.com.wlf.demo.servlet.DemoServlet] are both mapped to the url-pattern [/hello] which is not permitted
先看具体错误日志: [2019-04-26 09:29:25,484] Artifact demo-servlet:war: Artifact is being deployed, please wa ...
随机推荐
- 1.live555源码分析----RSTPServer创建过程分析
最近五一回家,终于有机会能安静的看一下流媒体这方面相关的知识,准备分析live555的源码,接下来会把我读源码的过程记录成博客,以供其他的同路人参考. 因为再读源码的过程中,并不是一路顺着读下来,往往 ...
- 搭建docker本地仓库
如果没有创建docker环境的话,需要先安装docker环境. 1. 使用命令创建容器 docker run -d -p 8081:8080 atcol/docker-registry-ui 8081 ...
- windows 任务计划
我的需求是每天定时访问网站的某一个控制器去刷新库存 流程如下(我自己的理解) 进入任务计划页面 上图指定的bat文件内容就是访问指定的网站路径 dingshi.bat文件内容如下(这个是网上找的,可能 ...
- nginx-location语法匹配优先级
- django项目基于钩子验证的注册功能
前端html <div class="agile-row"> <h3>注册</h3> {# 注册的开始#} <div class=&quo ...
- c# 3.0语言主要增强
1隐含类型的局部变量 var i=5; var h=23.56; var s="Cshap" var intarr=new[]{1,2,3}; var 为关键字,可以根据后边的初始 ...
- C#锐利体验2读书笔记
匿名方法,迭代,匿名方法允许我们以一种“内联”的方法来编写方法代码;匿名方法是直接与委托实例化相关联的,使委托实例化更加直观方便.匿名方法的几个相关问题--参数列表,--返回值,--外部变量. add ...
- python获取参数列表
def f(a=1, b=2, c=3): print(locals())#在函数内获取 #使用inspect模块,简单方便 python2.7: import inspectinspect.geta ...
- Centos7 虚拟机里查看IP并启动网卡
输入ip查询命名 ip addr 也可以输入 ifconfig(centOs7没有ifconfig命令)查看ip,但此命令会出现3个条目,centos的ip地址是ens33条目中的inet值. 发现 ...
- LeetCode 685. Redundant Connection II
原题链接在这里:https://leetcode.com/problems/redundant-connection-ii/ 题目: In this problem, a rooted tree is ...