繁体   English   中英

WebDriverException:消息:'geckodriver'可执行文件需要在PATH中

[英]WebDriverException: Message: 'geckodriver' executable needs to be in PATH

os:windows 7 selenium v​​ersion 3.0.1 mozilla firefox:48.0.2

Traceback (most recent call last):
  File "C:\Users\LENOVO\Desktop\kk2.py", line 4, in <module>
  driver = webdriver.Firefox()
  File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 135, in __init__
  self.service.start()
  File "C:\Python27\lib\site-packages\selenium\webdriver\common\service.py", line 71, in start
  os.path.basename(self.path), self.start_error_message)
  WebDriverException: Message: 'geckodriver' executable needs to be in PATH. 

请一步一步提供信息请实际上我是学习者

对于基于Linux的系统,请下载geckodriver 解压缩并将驱动程序复制到/ usr / local / bin,最后使其可执行(chmod + x geckodriver)。

请检查答案:

https://stackoverflow.com/a/37765661

https://stackoverflow.com/a/40208762

不久,

从selenium 3.0开始,你必须明确下载Marionette geckodriver于Firefox的Marionette geckodriver (类似于ChromeDriver for Chrome)并将其保存在系统可以识别它的位置。 (如系统路径 - Windows中的环境变量)或指定使用语言选项。

参考文献:

  1. 下载Marionette GeckoDriver
  2. https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver
  3. https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette

对于mac用户使用:

brew install geckodriver

我只需下载Gecko文件并粘贴到你的python文件所在的位置。 它解决了这个问题!

Linux(Ubuntu)用户应下载geckodriver并将其解压缩到项目文件夹中,并在运行python脚本时将参数设置为

executable_path="./geckodriver"

例:

from selenium import webdriver

class RunFFTests():

    def testMethod(self):
        # Initiate the driver instance
        driver = webdriver.Firefox(
            executable_path="./geckodriver")

        driver.get("http://www.letskodeit.com")

ff = RunFFTests()
ff.testMethod()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM