当前位置: 首页 > 知识库问答 >
问题:

在Windows10上使用selenium/geckodriver for Firefox“找不到匹配的功能集”

苏洛城
2023-03-14

版本:

>

  • geckodriver 0.26.0(路径内环境变量)

    硒3.141.0

    火狐75.0

    python 3.8.2

    Windows 10

    当我尝试:

    from selenium import webdriver
    
    driver = webdriver.Firefox()
    driver.get('https://seleniumhq.org/')
    

    我明白了:

    Traceback (most recent call last):
      File "C:\Users\Me\Desktop\python\FFtests.py", line 3, in <module>
        driver = webdriver.Firefox()
      File "C:\Users\Me\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 170, in __init__
        RemoteWebDriver.__init__(
      File "C:\Users\Me\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
        self.start_session(capabilities, browser_profile)
      File "C:\Users\Me\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
        response = self.execute(Command.NEW_SESSION, parameters)
      File "C:\Users\Me\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
        self.error_handler.check_response(response)
      File "C:\Users\Me\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
        raise exception_class(message, screen, stacktrace)
    selenium.common.exceptions.SessionNotCreatedException: Message: Unable to find a matching set of capabilities
    

    当我尝试时:

    from selenium import webdriver
    from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
    
    cap = DesiredCapabilities().FIREFOX
    cap["marionette"] = False
    driver = webdriver.Firefox(capabilities = cap)
    driver.get('https://seleniumhq.org/')
    

    我明白了:

    Traceback (most recent call last):
      File "C:\Users\me\Desktop\python\FFtests.py", line 6, in <module>
        driver = webdriver.Firefox(capabilities = cap)
      File "C:\Users\me\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 190, in __init__
        executor = ExtensionConnection("127.0.0.1", self.profile,
      File "C:\Users\me\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\firefox\extension_connection.py", line 52, in __init__
        self.binary.launch_browser(self.profile, timeout=timeout)
      File "C:\Users\me\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 73, in launch_browser
        self._wait_until_connectable(timeout=timeout)
      File "C:\Users\me\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 103, in _wait_until_connectable
        raise WebDriverException(
    selenium.common.exceptions.WebDriverException: Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.
    

    IEDriver适用于IE

    我有Windows Visual Studio安装https://github.com/mozilla/geckodriver/releases指示我应该。

    我能做些什么来实现这一目标?

  • 共有1个答案

    东方权
    2023-03-14

    这可能是FireFox版本的一个问题。尝试更新Firefox和Selenium。

    • 更新Firefox
    • 更新硒
    • 重新安装/更新GeckoDrive

    有关更多解决方案,请参见此处。

     类似资料: