selenium 常见问题

 

启动selenium时报错如下异常:

selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.

解决方式:需要下载geckodriver,并放在path的环境变量下,下载地址:https://github.com/mozilla/geckodriver/releases

 

启动selenium时报异常:selenium.common.exceptions.WebDriverException: Message: Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line

解决方法1:

找到Python27\Lib\site-packages\selenium\webdriver\firefox\webdriver.py文件将构造方法中firefox_binary=None的值改为当前firefox的安装路径。如下

解决方法2:

在创建webdriver时,将firefox.exe可执行文件路径当做参数传递给webdriver。如下

 

 

启动selenium时报异常:selenium.common.exceptions.WebDriverException: Message: Unsupported Marionette protocol version 2, required 3

解决方法:firefox 版本太低,需要升级firefox浏览器版本

 

启动selenium时,报异常:selenium.common.exceptions.SessionNotCreatedException: Message: Unable to find a matching set of capabilities

原因:geckodriver 版本与firefox浏览器版本不匹配

下载匹配的版本即可,当前试过的版本:geckodriver-v0.11.1-win64 能与firefox v47.2 可以正常启动firefox。

 

转载于:https://www.cnblogs.com/JcHome/p/10747328.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值