简体   繁体   English

使用Python在Firefox中打开Webdriver时Selenium服务对象错误

[英]Selenium Service Object Error when opening Webdriver with Firefox in Python

I'm trying to utilize python selenium with firefox in accordance with the documentation , but I get the below error 我正在尝试根据文档使用python selenium和firefox,但我得到以下错误

See below for my script 请参阅下面的我的脚本

from selenium import webdriver

driver = webdriver.Firefox()
driver.get("https://www.google.com/")

See below for my error 请参阅下面的错误

Traceback (most recent call last):
  File "/Users/Chris/Desktop/firefox_try.py", line 3, in <module>
    driver = webdriver.Firefox()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium-3.0.1-py2.7.egg/selenium/webdriver/firefox/webdriver.py", line 135, in __init__
    self.service.start()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium-3.0.1-py2.7.egg/selenium/webdriver/common/service.py", line 71, in start
    os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH. 

Exception AttributeError: "'Service' object has no attribute 'process'" in <bound method Service.__del__ of <selenium.webdriver.firefox.service.Service object at 0x1006890d0>> ignored

I've tried re-installing selenium's python bindings, which I did by just installing from this link with little luck: https://pypi.python.org/pypi/selenium#downloads 我已经尝试重新安装selenium的python绑定,我只是通过这个链接安装,但运气不大: https//pypi.python.org/pypi/selenium#downloads

Looks like the 'geckodriver' executable needs to be in your PATH. 看起来'geckodriver'可执行文件需要在你的PATH中。

Here's a site explaining how to set up the webdriver: https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver 这是一个解释如何设置webdriver的网站: https//developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver

The command that they specify to add geckodriver to path is: 他们指定将geckodriver添加到路径的命令是:

export PATH=$PATH:/path/to/geckodriver

I'd suggest you put it in ~/.local/bin 我建议你把它放在〜/ .local / bin中

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

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