sunshine
管理员
管理员
  • 最后登录2023-10-30
  • 发帖数170
  • 社区居民
阅读:11158回复:0

webdriver error: 'geckodriver' executable needs to be in PATH.

楼主#
更多 发布于:2018-01-23 13:06
在使用python + selenium 搭建环境时:

运行如下代码:

from selenium import webdriver

from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
# webdriver.Firefox() 找firefox 默认安装 路径
driver = webdriver.Firefox()
driver.get('http://baidu.com')


在运行过程中报错,提示信息如下:

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

原因: 在selenium 3中使用webdriver.Firefox() , 如果下载geckodriver.exe

解决方案:

1.  下载geckodriver.exe , 下载地址:https://github.com/mozilla/geckodriver/releases

2. 下载后,将geckodriver.exe复制到Firefox 浏览器的安装目录. 一般默认路径在:C:\Program Files (x86)\mozilla firefox目录下;
3. 将FireFox 的路径添加到环境变量Path中添加路径:如,C:\Program Files (x86)\mozilla firefox;
4. 将geckodriver.exe ,放到python 的目录下,如下:
   

图片:geck.jpg




注:如何还要报错,如下以下提示:

selenium.common.exceptions.SessionNotCreatedException: Message: Unable to find a matching set of capabilities


关于,上面的错误,请参考下一篇贴子:关于webdreiver error: Unable to find a matching set of capabilities  


参考 :
https://www.cnblogs.com/alexzp/p/5892895.html
http://www.cnblogs.com/leolovexx/p/7116607.html
游客


返回顶部

公众号

公众号