Selenium and Firefox Error – Message: Unable to find a matching set of capabilities

Message: Unable to find a matching set of capabilities is an error which happens when you have compatibility issues with Firefox and selenium.

In this article I am going to explain what happens when you get this error and how you can solve it with a main solution, we will also explore other solutions which can possibly solve the issue.

Exploring the Error Message: Unable to find a matching set of capabilities

This is an error which happens when you have compatibility issues with Firefox and selenium.

Bellow you can find the solution which worked for me plus other popular possible solutions among developers who already faced this error.

Solution 1 : Geckodriver and marionette fix

One of the tricks one can try to solve this error quickly is to use a newer version of Firefox.

You can follow this link. Head to the downloads section and click on releases.

                                                                       #
https://github.com/mozilla/geckodriver/
                                                                       #

Then choose one of the latest versions of firefox.

You can keep the old version of firefox and set marionette to False. You can do that using the code bellow.

                                                                       #
caps = DesiredCapabilities.FIREFOX.copy()
caps['marionette'] = False
driver=webdriver.Firefox(capabilities=caps)
                                                                       #

Changing marionette to False should be enough to solve this problem.

If you do not know how to add that to your code, this is how you can do it.

                                                                       #
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
cap = DesiredCapabilities().FIREFOX # setting marionette to False
cap["marionette"] = False
browser = webdriver.Firefox(capabilities=cap, executable_path="C:\\path\\to\\geckodriver.exe")
browser.get('http://twitter.com/')
                                                                       #

If this solution fixed the problem, congratulations. Otherwise, You can try the solution bellow.

Solution 2 :  Install geckodriver using brew

Another solution is to Install geckodriver using brew.

You can do that by running the command bellow.

                                                                       #
brew install geckodriver #Installing geckodriver using brew
                                                                       #

The second step is to uninstall the old version of firefox.

The code bellow should work fine.

                                                                       #
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
browser = webdriver.Firefox()
browser.get('http://twitter.com/')
                                                                       #

The solutions above should be enough to solve the problem, if you like our effort make sure to consider donating to our Kofi account, there is a red button that you can use if you are feeling generous.

Summing-up

I hope you guys found my article helpful, I hope the solution provided above has solved your problem. If you like the effort I put in this post please consider donating to our Kofi account using the red button at the top of this page.

Keep learning guys, keep coding and cheers. If you want to learn more about Python, please check out the Python Documentation : https://docs.python.org/3/