相关疑难解决方法(0)

没有这样的文件或目录:'geckodriver'用于Python简单的Selenium应用程序

我正在Linux上运行一个简单的selenium示例:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()
driver.get("something")
Run Code Online (Sandbox Code Playgroud)

并得到一个错误:

FileNotFoundError: [Errno 2] No such file or directory: 'geckodriver'
Run Code Online (Sandbox Code Playgroud)

怎么解决?

$ 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
>>> 
Run Code Online (Sandbox Code Playgroud)

python linux selenium

33
推荐指数
4
解决办法
2万
查看次数

'geckodriver'可执行文件必须在PATH中

Mac OS用户在此处。我正在尝试在python IDLE中运行命令:

from selenium import webdriver
browser = webdriver.Firefox()
Run Code Online (Sandbox Code Playgroud)

我收到以下错误消息:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 76, in start
    stdin=PIPE)
  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'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<pyshell#4>", line 1, in <module>
    browser = webdriver.Firefox()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/firefox/webdriver.py", line 160, in __init__ …
Run Code Online (Sandbox Code Playgroud)

python path geckodriver

4
推荐指数
2
解决办法
7184
查看次数

Python Selenium:'意外的关键字参数'executable_path'

我刚刚开始使用seleniumPython,并且不断收到以下错误代码:

TypeError: WebDriver.__init__() got an unexpected keyword argument 'executable_path'
Run Code Online (Sandbox Code Playgroud)

这是上下文的代码:

from selenium.webdriver import Firefox
from selenium.webdriver.common.keys import Keys

url = 'https://example'
driver_path = r"D:\path\to\geckodriver.exe"

browser = Firefox(executable_path=driver_path)
browser.get(url)
Run Code Online (Sandbox Code Playgroud)

提前致谢!

我检查了路径、selenium包的版本并确保我有正确的geckodriver.exe但仍然收到错误。

python firefox selenium-webdriver

4
推荐指数
1
解决办法
6114
查看次数