selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH. 错误处理方法

首次使用selenium webdriver,webdriver.Firefox()

报错selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.  原因是没有将浏览器驱动加入系统环境变量path。

 

Windows处理方法:

1、下载geckodriver.exe:

下载地址:https://github.com/mozilla/geckodriver/releases
根据系统版本选择下载;(如Windows 64位系统)

2、下载解压后将getckodriver.exe放到python安装目录下。 如果python安装的时候已经勾选了add to path不用做任何处理就可以啦。否则需将python安装目录加入系统变量-环境变量-path里面。

3.再次运行代码

 

其他浏览器处理方式类似;各浏览器driver下载地址

https://www.seleniumhq.org/about/platforms.jsp#browsers

firefox: https://github.com/mozilla/geckodriver/releases/

chrome:https://code.google.com/p/chromedriver/downloads/list

ie:http://selenium-release.storage.googleapis.com/index.html

posted @ 2018-05-31 14:58  dinghanhua  阅读(1890)  评论(0编辑  收藏  举报