[转]selenium使用报错“selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable nee

安装了python3,使用pip安装了selenium,但是在使用时,报了“selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.”

网上查了一下解决办法,此处做下记录:

原因:使用pip安装selenium,默认安装的是最新版本的selenium,使用pip list查了一下我的selenium版本,是3.4.2的,firefox版本,是43.0.1的,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,问题解决。

  
\---------------------  
作者:大懒猫在吃草  
来源:CNBLOGS  
原文:https://www.cnblogs.com/yousuosiyss/p/6882420.html  
版权声明:本文为作者原创文章,转载请附上博文链接!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值