【发布时间】:2025-12-15 20:05:02
【问题描述】:
我正在 Linux 上运行一个简单的 selenium 示例:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get("something")
并得到一个错误:
FileNotFoundError: [Errno 2] No such file or directory: 'geckodriver'
如何解决?
$ python
Python 3.5.2 (default, Jun 28 2016, 08:46:01)
[GCC 6.1.1 20160602] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import selenium
>>> from selenium.webdriver.common.keys import Keys
>>>
【问题讨论】:
-
在 Java 中,我需要设置 gecko 驱动程序的系统属性,这可能也是您需要做的,但我不太了解 Python。我在 Java 中使用的:
System.setProperty("webdriver.gecko.driver", "path/to/driver");