python selenium模块使用出错-selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.

Python 2.7+selenium+Firefox 55.0.3

代码:

from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
import time

browser = webdriver.Firefox() # Get local session of firefox
browser.get("http://www.yahoo.com") # Load page
assert "Yahoo!" in browser.title
elem = browser.find_element_by_name("p") # Find the query box
elem.send_keys("seleniumhq" + Keys.RETURN)
time.sleep(0.2) # Let the page load, will be added to the API
try:
    browser.find_element_by_xpath("//a[contains(@href,‘http://seleniumhq.org‘)]")
except NoSuchElementException:
    assert 0, "can‘t find seleniumhq"
browser.close()

错误信息如下:

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

回答摘自知乎:https://www.zhihu.com/question/49568096

1. selenium 3.x开始,webdriver/firefox/webdriver.py的__init__中,executable_path="geckodriver";而2.x是executable_path="wires"
2. firefox 47以上版本,需要下载第三方driver,即geckodriver;在http://docs.seleniumhq.org/download/的Third Party Drivers, Bindings, and Plugins下面找到Mozilla GeckoDriver,下载到任意电脑任意目录(Mac 下放到了/usr/bin/ 和/sbin/, /bin/,/usr/local/bin/),解压后将该路径加入到PC的path(针对windows)即可。

作者:iceblue iceblue
链接:https://www.zhihu.com/question/49568096/answer/119324584
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

python selenium模块使用出错-selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.

时间: 2024-10-29 04:47:31

python selenium模块使用出错-selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.的相关文章

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

报这个错查了一下解决方法: 1.使用pip安装selenium,默认安装最新版本,需要到官网上下载与系统相应的最新版本geckodriver:https://github.com/mozilla/geckodriver/releases 2.解压之后把EXE程序放到Python的安装目录下,如果是放在其它目录下需要自己再配一下环境变量,重启IDE 3.如果还没有解决,就把Firefox升级到最新版本 selenium.common.exceptions.WebDriverException: M

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

环境信息:Windows7 64位 + python 3.6.5 + selenium 3.11.0 +pyCharm 1 #coding=utf-8 2 from selenium import webdriver 3 driver=webdriver.Firefox() 解决方法: 1.下载geckodriver,路径:https://github.com/mozilla/geckodriver/releases 2.解压后无需安装,将其解压路径配置到环境变量PATH [bugRecord2

解决selenium.WebDriverException: Message: ‘chromedriver‘ executable needs to be in Path

在进行爬虫爬取淘宝商品信息时候,利用selenium来模拟浏览器进行爬取时遇到了这个问题: selenium.common.exception.WebDriverException:Message:'chromedriver' executable needs to be in Path 详细如下图所示: 这一错误是因为没有配置好chromedriver,怎么配置呢?(我用的是chrome) 1.打开chrome 输入 "chrome://version/"来查看chrome版本 如图

【Python + Selenium】初次用IE浏览器之报错:selenium.common.exceptions.WebDriverException: Message: Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones.

初次用IE浏览器运行自动化程序时,报错:selenium.common.exceptions.WebDriverException: Message: Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones. Enable Protected Mode must be set to the same value (enabled or disabled

Selenium错误:selenium.common.exceptions.WebDriverException: Message: "Can't load the profile.

错误描述:在python代码中通过selenium来初始化一个firefox浏览器失败,看了下selenium的版本是2.35,然后用firefox --version看了下是28.0,firefox好像不听话自动升级了导致了旧版selenium不支持. Traceback (most recent call last): File "C:\Python27\erSiteCompare.py", line 528, in sys.exit(main()) File "C:\P

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

环境:Python3+selenium3+Firefox47 在打开火狐浏览器时报错:'geckodriver' executable needs to be in PATH from selenium import webdriver web = webdriver.Firefox() 于是,各种度娘,最终做了如下尝试: 下载了geckodriver-v0.18.0-win64,解压将geckodriver.exe放到火狐浏览器目录下,然后把火狐浏览器目录添加到path环境变量. 结果又出现报

关于Selenium.common.exceptions.WebDriverException: Message: Invalid locator strategy: css selector 的问题

在执行脚本时报Selenium.common.exceptions.WebDriverException: Message: Invalid locator strategy: css selector 的错 出现这个问题时请先检查你的selenium版本是否和Appium-Python-Client 的版本互相兼容 如果你的selenium是3.4的版本,需要下载 Appium-Python-Client 2.8的版本 如果selenium是2.53.6的请一定要下载 Appium-Pytho

初学selenium-grid执行脚本报错:selenium.common.exceptions.WebDriverException: Message: Error forwarding the new session Empty pool of VM for setup Capabilities {browserName: firefox, javascriptEnabled: true, v

初衷是想实现一个Remote实例,也是刚学selenum-grid,就迫不及待写个脚本运行看看效果: 显示报错:selenium.common.exceptions.WebDriverException: Message: Error forwarding the new session Empty pool of VM for setup Capabilities {browserName: firefox, javascriptEnabled: true, version: } 原因是启动S

selenium.common.exceptions.WebDriverException: Message: unknown Error: cannot find Chrome binary

jenkins集成web_UI自动化脚本,发送的html报告中显示: selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary 如下图: 使用Chrome浏览器时,经常会遇到以下报错:浏览器没有调用起来 通常由两种问题引起的: 1.ChromeDriver.exe驱动有问题(包括版本,路径等等) 2.Chrome.exe本身有问题. 网上搜索的解决方案:三个 1