selenium.common.exceptions.SessionNotCreatedException: Message: Unable to find a matching set of capabilities with GeckoDriver, Selenium and Firefox

允我心安 提交于 2019-11-27 09:52:36

As per your question and code block as you are using the following Test Configuration:

  • Selenium => 3.14
  • geckodriver => 0.21.0
  • Firefox => 61.0.2

You have to use the capability marionette mandatorily. To achieve that either:

  • You can leave the capability marionette untouched as by default marionette is set to True.
  • You can also specify the capability marionette as follows:

    cap = DesiredCapabilities().FIREFOX
    cap["marionette"] = True
    

This usecase

This error message...

selenium.common.exceptions.SessionNotCreatedException: Message: Unable to find a matching set of capabilities

...implies that the GeckoDriver was unable to initiate/spawn a new WebBrowser i.e. Firefox Browser session.

There are numerous possibilities behind the error you are seeing and can be solved through any of the following steps mentioned below:

  • As you are on Windows OS you need to pass the key executable_path along with the value containing:

    • Absolute path of the GeckoDriver.
    • The Absolute path of the GeckoDriver should be mentioned through single quotes and single backward slash along with the raw (r) switch.
    • Include the extension of the GeckoDriver binary.
    • Your line of code will be:

      driver = Firefox(executable_path=r'C:\path\to\geckodriver.exe', firefox_options=options, capabilities=cap)
      

References

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!