【发布时间】:2018-05-29 01:59:54
【问题描述】:
使用 Python 3.6 绑定运行 OS 10.12.6 Selenium
尽管我尽了最大的努力,但我似乎无法与 Selenium 一起工作。这是我得到的错误:
Geckodriver 错误:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 74, in start
stdout=self.log_file, stderr=self.log_file)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 1344, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'geckodriver': 'geckodriver'
在处理上述异常的过程中,又发生了一个异常:
Traceback (most recent call last):
File "/Users/christopher.gaboury/Desktop/Scripts/safariExecutive.py", line 11, in <module>
browser = webdriver.Firefox()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/firefox/webdriver.py", line 148, in __init__
self.service.start()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/common/service.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.
chromedriver 和 geckodriver 的错误基本相同。
我已经手动设置了这些路径所在的位置。同样的错误。我已将驱动程序移至路径中已存在的位置。同样的错误。我已经删除了我通过 Homebrew 下载并安装了两个驱动程序的两个版本。同样的错误。我不确定下一步该怎么做。
【问题讨论】:
-
echo $PATH,看看你的网络驱动程序是否在这些文件夹中。 -
使用代码块
-
我已经手动将驱动程序移动到路径中的位置,并允许 Homebrew 为我安装它们。两个实例都不起作用。
-
这似乎更适合作为问题/错误提交给Selenium
-
which selenium的结果是什么?
标签: python selenium selenium-chromedriver geckodriver