使用pip安装selenium,默认安装...

你在这里

使用pip安装selenium,默认安装...

使用pip安装selenium,默认安装的是最新版本的selenium,使用pip list查了一下我的selenium版本,是3.5.0的,firefox版本,是47.0.2的,selenium 3.x开始,webdriver/firefox/webdriver.py的__init__中,executable_path="geckodriver";而2.x是executable_path="wires"

方法一:可以卸载现有的selenium,安装指定的2.X版本的selenium,这个办法没有试,因为就是本着selenium3来的,不打算降版本;

方法二:下载geckodriver.exe

1.下载地址:https://github.com/mozilla/geckodriver/releases,根据自己的电脑,下载的win64位的;

2.在firefox的安装目录下,解压geckodriver,然后将该路径添加到path环境变量下,不报这个错了;

3.但是,报了一个新的错“selenium.common.exceptions.WebDriverException: Message: Unable to find a matching set of capabilities”;

4.继续网上查,原因是,我下载的geckodriver是V0.16.1版本的,这个版本和selenium3.4.2不兼容,需要使用deckdriverV0.15的版本;

5.重新下载了deckodriverV0.15的版本,ok了,不报这个错了,但是,又报了一个新的错“selenium.common.exceptions.WebDriverException: Message: Unsupported Marionette protocol version 2, required 3;

6.继续往上查原因,说是firefox版本太低了,需要升级到最新版,ok,更新firefox,问题解决。

7.火狐浏览器的安装文件.exe也添加到path环境变量中,避免出现一些不不要的错误