我正在尝试遵循有关Selenium的教程http://selenium-python.readthedocs.io/getting- started.html。我已下载的最新版本geckodriver并将其复制到/usr/local/bin。但是,当我尝试
geckodriver
/usr/local/bin
from selenium import webdriver driver = webdriver.Firefox()
我收到以下错误消息:
Traceback (most recent call last): File "/Users/kurtpeek/Documents/Scratch/selenium_getting_started.py", line 4, in <module> driver = webdriver.Firefox() File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 152, in __init__ keep_alive=True) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 98, in __init__ self.start_session(desired_capabilities, browser_profile) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 188, in start_session response = self.execute(Command.NEW_SESSION, parameters) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in execute self.error_handler.check_response(response) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: Unable to find a matching set of capabilities [Finished in 1.2s with exit code 1]
从https://github.com/SeleniumHQ/selenium/issues/3884看来,其他用户也遇到了类似的问题,但是Selenium团队无法复制它。如何使Selenium与Firefox兼容?(它确实可以chromedriver和一个webdriver.Chrome()实例一起使用,所以我怀疑这可能是Selenium中的错误)。
chromedriver
webdriver.Chrome()
更新Firefox和Selenium为我解决了它。但是,我不假装对根本原因进行解释。
我还Geckodriver使用HomebrewSelenium对其进行了重新安装/更新,并明确地将其用作了Selenium的可执行文件WebDriver,但事实证明,不必缓解 “无法找到匹配的功能集” 错误。
Geckodriver
Homebrew
WebDriver