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 ...
随机推荐
- mysql replace into 实现存在则更新,不存在则插入
测试用的mysql数据库: 新建测试表: CREATE TABLE `test` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `text` varchar(2 ...
- Trunk 实现跨交换机 VLAN 通信
当网络中有多台交换机时,位于不同交换机上的相同VLAN的主机之间时如何通信的呢?我们使用Trunk实现跨交换机VLAN通信.还有以太网通道的操作哦. 实验拓扑 两台交换机直连,每台下面再连接两台VPC ...
- OpenStack核心组件-cinder存储服务
1. cinder 介绍 Block Storage 操作系统获得存储空间的方式一般有两种: 1) 通过某种协议(SAS,SCSI,SAN,iSCSI 等)挂接裸硬盘,然后分区.格式化.创建文 ...
- spring cloud (六) 将一个普通的springcloud项目 非feign或ribbon项目,改造成turbine可聚合监听的项目
改造之前一个项目 service-a 1 pom.xml添加如下 <dependency> <groupId>org.springframework.cloud</gro ...
- Kotlin调用Java程序解析
Kotlin跟Java是百分百兼容的,换言之,也就是它们俩是可以互操作的,也就是Java可以调Kotlin,Koltin可以调Java,所以下面来看一下在Kotlin中如何来调用Java代码: 咱们来 ...
- Java并发包--ConcurrentSkipListSet
https://www.cnblogs.com/kexianting/p/8550459.html import java.util.concurrent.ConcurrentLinkedQueue; ...
- Python通过xpath查找元素通过selenium读取元素信息
#coding:utf-8 from selenium import webdriver import time url ='http://www.baidu.com' driver = webdri ...
- PCA: PCA的具体实现过程
数据预处理:mean normalization & feature scaling 先进行均值归一化(mean normalization),计算出每个特征的均值(uj),然后用xj-uj ...
- docker-compose更新image命令
docker-compose stop docker-compose up -d --build
- Java 14 周作业
题目:编写一个应用程序,输入一个目录和一个文件类型,显示该目录下符合该类型的所有文件.之后,将这些文件中的某一个文件剪切到另外一个目录中. 代码: package ccut.cn; import ja ...