python运行时提示WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
2017-03-09 21:52
1956 查看
本人亲自实践selenium + webdriver,结合了容易出现的两个问题,网上虽然有方法,但是找起来很费劲。在这里总结给大家,希望对各位有帮助!
1.python运行时提示WebDriverException:Message: 'geckodriver' executable needs to be in PATH.
解决办法:百度‘geckodriver’下载,下载32或是64位,本人的是64位的。下载完成后,将geckodriver.exe放在和python同一个目录下,我的是D:\Python27,之后再去运行
或者直接进入下载地址:https://github.com/mozilla/geckodriver/releases,根据需要自己选择
2.运行时可能会提示:
WebDriverException: Expected browser binarylocation, but unable to find binary in defaultlocation,no'moz:firefoxOptions.binary' capability provided, and no binary flagset on the command line
原因是我们安装火狐时并未安装在默认地址。这时我们需要指定Firefox浏览器程序路径。
binary =FirefoxBinary('D:\\Firefox\\Firefox\\firefox.exe')
browser =webdriver.Firefox(firefox_binary=binary)
注:提示找不到"firefoxBinary"可以通过下面语句导入 from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
3.运行时还会提示:
selenium.common.exceptions.WebDriverException: Message: Unable to find a matching set of capabilities
这是因为版本不匹配
解决方案:a.检查本机java版本,selenium3.x只支持java8版本以上,这里符合要求;
b. geckodriver版本是v0.18.1 ,firefox浏览器版本是45,卸载firefox,安装最新版本的firefox版本54;
运行脚本,可以正常执行。
1.python运行时提示WebDriverException:Message: 'geckodriver' executable needs to be in PATH.
解决办法:百度‘geckodriver’下载,下载32或是64位,本人的是64位的。下载完成后,将geckodriver.exe放在和python同一个目录下,我的是D:\Python27,之后再去运行
或者直接进入下载地址:https://github.com/mozilla/geckodriver/releases,根据需要自己选择
2.运行时可能会提示:
WebDriverException: Expected browser binarylocation, but unable to find binary in defaultlocation,no'moz:firefoxOptions.binary' capability provided, and no binary flagset on the command line
原因是我们安装火狐时并未安装在默认地址。这时我们需要指定Firefox浏览器程序路径。
binary =FirefoxBinary('D:\\Firefox\\Firefox\\firefox.exe')
browser =webdriver.Firefox(firefox_binary=binary)
注:提示找不到"firefoxBinary"可以通过下面语句导入 from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
3.运行时还会提示:
selenium.common.exceptions.WebDriverException: Message: Unable to find a matching set of capabilities
这是因为版本不匹配
解决方案:a.检查本机java版本,selenium3.x只支持java8版本以上,这里符合要求;
b. geckodriver版本是v0.18.1 ,firefox浏览器版本是45,卸载firefox,安装最新版本的firefox版本54;
运行脚本,可以正常执行。
相关文章推荐
- python运行时提示WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
- python运行时提示WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
- 运行提示:WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
- WebDriverException:Message:'geckodriver'executable needs to be in Path
- selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH
- selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
- win7 python3.6+selenium3.8.1运行chromedriver提示“Message: 'chromedriver' executable needs to be in PATH
- selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH
- WebDriverException:Message:'geckodriver'executable needs to be in Path
- python selenium 3.4 错误解决 Message: 'geckodriver' executable needs to be in PATH.
- python selenium模块使用出错解决,Message: 'geckodriver' executable needs to be in PATH
- WebDriverException: Message: 'phantomjs.exe' executable needs to be in PATH.
- python selenium模块使用出错解决,Message: 'geckodriver' executable needs to be in PATH
- selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH
- selenium.common.exceptions.WebDriverException: Message: 'phantomjs' executable needs to be in PATH
- WebDriverException:Message:'geckodriver'executable needs to be in Path
- selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PAT
- WebDriverException: Message: 'IEDriverServer.exe' executable needs to be in PATH. Please download fr
- MAC安装chromedriver提示“Message: 'chromedriver' executable needs to be in PATH.Please see ...”
- python运行selenium chromedriver提示WebDriverException: 'chromedriver' executable needs to be in PATH.