zoukankan      html  css  js  c++  java
  • Message: 'geckodriver' executable needs to be in PATH. 解决方法

    问题描述:

    执行如下代码

    # coding=utf-8
    from selenium import webdriver
    
    driver = webdriver.Firefox()
    driver.maximize_window()
    driver.implicitly_wait(2)
    
    driver.get('https://www.baidu.com')
    try:
        driver.find_element_by_id('kw')
        print('test pass: ID found')
    except Exception as e:
        print('Exception found', format(e))
    
    driver.quit()

    提示报错:

    Traceback (most recent call last):
    File "E:/PythonSelenium/CSDN/004id.py", line 4, in <module>
    driver = webdriver.Firefox()
    File "E:Python35libsite-packagesseleniumwebdriverfirefoxwebdriver.py", line 142, in __init__
    self.service.start()
    File "E:Python35libsite-packagesseleniumwebdrivercommonservice.py", line 81, in start
    os.path.basename(self.path), self.start_error_message)
    selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.

    原因分析:

    摘取主要报错信息 Message: 'geckodriver' executable needs to be in PATH.

    解决方法:

    (1)测试环境:Selenium 3.4.0   Firefox 56.0   Python3.5.2

    (2)下载火狐浏览器对应驱动,传送门 https://github.com/mozilla/geckodriver/releases   结合我浏览器的版本需要下载V 0.19.0

    (3)解压文件获取geckodriver.exe文件,并放置在主目录下。重新运行后发现问题已解决。

    注:注意火狐浏览器、Python环境变量设置。

  • 相关阅读:
    Python 2 与 python 3的区别
    语法基础题
    Python运算符_ 2018-07-26
    Python 各种语句:2018-07-27
    解决在Python中使用Win32api报错的问题,No module named win32api
    在CenOS7.5里安装Redis
    下载Redis
    重置CentOS6.5的登录口令
    如何在CentOS里切换操作系统所用的语言,中英文切换
    在Ubuntu里安装Mysql5.7.23
  • 原文地址:https://www.cnblogs.com/mrgavin/p/8328196.html
Copyright © 2011-2022 走看看