python selenium模块使用出错-selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.,,Python 2.7
python selenium模块使用出错-selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.,,Python 2.7
Python 2.7+selenium+Firefox 55.0.3
代码:
from selenium import webdriverfrom selenium.common.exceptions import NoSuchElementExceptionfrom selenium.webdriver.common.keys import Keysimport timebrowser = webdriver.Firefox() # Get local session of firefoxbrowser.get("http://www.yahoo.com") # Load pageassert "Yahoo!" in browser.titleelem = browser.find_element_by_name("p") # Find the query boxelem.send_keys("seleniumhq" + Keys.RETURN)time.sleep(0.2) # Let the page load, will be added to the APItry: 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.
相关内容
- python-模块与包,python-模块,目录:1.模块 2.
- python 验证码处理,,一、灰度处理,就是把
- centos7安装python3和Django后,ModuleNotFoundError: No module nam
- python读取xml文件报错ValueError: multi-byte encodings are not s
- 【Python3练习题 019】 有一分数序列:2/1,3/2,5/3,8/5,
- python3.6 request模块和ddt模块的安装,,1.1用cmd命令进
- centos 安装python3与Python2并存,并解决"smtplib&
- Python3 tkinter基础 Canvas create_polygon 画三角形,python3tki
- python解压分析jar包,,import osi
- Python 批量生成中文姓名(百家姓),python中文, 最
评论关闭