selenium踩过的坑

1、使用环境 ubuntu16.04,python3.5

2、官方文档

https://selenium-python-zh.readthedocs.io/en/latest/installation.html

3、安装

pip install selenium

4、ERROR1  chromedriver:

WebDriverException: Message: 'chromedriver' executable needs to be in PATH.

1)    解决:下载chromedriver,并将之复制到usr/bin目录下

chromedriver下载地址:https://sites.google.com/a/chromium.org/chromedriver/downloads

2)    从其他文件夹复制到root目录:$sudo copy chromedriver /usr/bin

然后输入密码,完成复制

5、ERROR2  权限:

Message: 'chromedriver' executable may have wrong permissions.

在usr/bin目录下修改chromedriver权限:$sodu chmod 777 chromedriver

6、ERROR3  session :

selenium.common.exceptions.SessionNotCreatedException: Message: session not created exception

要么更新chrome,要么重新降低chromedriver的版本

浏览器中帮助-关于google Chrome可以看到谷歌的版本

上面chromedriver下载地址里面有chromedriver与chrom的版本匹配情况

然后你会发现,下载地址里面除了最新版本以外其他的都是文本状态并不能点击链接

打开可以链接的最新版本下载地址,然后再网址栏中直接修改上图红框部位的内容为你需要的版本,

回车,就可以打开你需要的版本地址了。

猜你喜欢

转载自blog.csdn.net/Diana_Z/article/details/82774033