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

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

Leave a Comment