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

Created on 3 Nov 2017  路  11Comments  路  Source: SeleniumHQ/selenium

Meta -

OS: Windows 10
Selenium Version: 3.7.0
Browser: Firefox
Browser Version: 56.0.2 (32-bit)

Expected Behavior -

Run sample code for Python taken from Selenium Python. Expect it to work.

Actual Behavior -

>>> from selenium import webdriver
>>> from selenium.webdriver.common.keys import Keys
>>>
>>> driver = webdriver.Firefox()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\MY_USER_NAME\AppData\Local\Continuum\anaconda3\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 154, in __init__
    keep_alive=True)
  File "C:\Users\MY_USER_NAME\AppData\Local\Continuum\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 151, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "C:\Users\MY_USER_NAME\AppData\Local\Continuum\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 240, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "C:\Users\MY_USER_NAME\AppData\Local\Continuum\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 308, in execute
    self.error_handler.check_response(response)
  File "C:\Users\MY_USER_NAME\AppData\Local\Continuum\anaconda3\lib\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

Steps to reproduce -

Freshly install everything and try to run the python code.

Most helpful comment

The only reason that I can think of this happening is if your Firefox is not installed in a normal location. This message is coming from geckodriver indicating that it cannot find Firefox to start. Alternatively, you can try this to point directly to your firefox installation:

from selenium import webdriver
from selenium.webdriver.firefox.options import Options
opts = Options()
opts.binary = "C:\path\to\firefox.exe"
driver = webdriver.Firefox(firefox_options=opts)

If you're using portable, you'll need to point to the actual bin and not the FirefoxPortable.exe, which would be somewhere further down the directory like \FirefoxPortable\App\Firefox64\firefox.exe

All 11 comments

I just tried this on a fresh install of Win10, Firefox, python, and geckodriver and it works fine. Maybe try without Anaconda?

I tried it without anaconda and the error persisted.

>>> from selenium import webdriver
>>> from selenium.webdriver.common.keys import Keys
>>>
>>> driver = webdriver.Firefox()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\MY_USER_NAME\AppData\Roaming\Python\Python36\site-packages\selenium\webdriver\firefox\webdriver.py", line 154, in __init__
    keep_alive=True)
  File "C:\Users\MY_USER_NAME\AppData\Roaming\Python\Python36\site-packages\selenium\webdriver\remote\webdriver.py", line 151, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "C:\Users\MY_USER_NAME\AppData\Roaming\Python\Python36\site-packages\selenium\webdriver\remote\webdriver.py", line 240, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "C:\Users\MY_USER_NAME\AppData\Roaming\Python\Python36\site-packages\selenium\webdriver\remote\webdriver.py", line 308, in execute
    self.error_handler.check_response(response)
  File "C:\Users\MY_USER_NAME\AppData\Roaming\Python\Python36\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

Are you using Firefox Portable? Or installed Firefox in a non-standard location?

The only reason that I can think of this happening is if your Firefox is not installed in a normal location. This message is coming from geckodriver indicating that it cannot find Firefox to start. Alternatively, you can try this to point directly to your firefox installation:

from selenium import webdriver
from selenium.webdriver.firefox.options import Options
opts = Options()
opts.binary = "C:\path\to\firefox.exe"
driver = webdriver.Firefox(firefox_options=opts)

If you're using portable, you'll need to point to the actual bin and not the FirefoxPortable.exe, which would be somewhere further down the directory like \FirefoxPortable\App\Firefox64\firefox.exe

I have the same issue on my Selenium Grid.

OS: Windows 10 & 8.1
Selenium Version: 3.6.0 - 3.7.0
Browser: Firefox
Browser Version: 56.0.2 (32-bit)
Geckodriver version: 0.19
Behave version: 1.2.5

Python script that I am running

import unittest
import time
import datetime
from datetime import date
from behave import *
from selenium.webdriver.common.keys import Keys
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

class browsepython(unittest.TestCase):


    @given('we have behave installed using {browser} with version {version} on {platform}')
    def step_impl(context, platform, browser, version):
        context.browser = browser
        context.platform = platform
        context.version = version
        context.driver = webdriver.Remote(command_executor='http://172.16.31.133:4444/wd/hub',
         desired_capabilities={'platform': platform, 'browserName': browser, 'javascriptEnabled': True}
         )
        pass

    @when('we browse to a site at url {url}')
    def step_impl(context, url):
        context.url=url
        try:
           context.driver.get(url)
        except:
           assert "can not reach the url: "+context.url
    @then('the page is captured')
    def step_impl(context):
        today = datetime.datetime.now().strftime("%Y%b%d_%H%M_")
        try:          
           context.driver.save_screenshot('C:\\testBehave\\features\\browsepython\\reportstestBehave\\features\\browsepython\\reports\\screenscapture\\'+str(today)+'.png')
        except:
           assert "can not capture the page"
        finally:
           context.driver.quit()


Feature file

`Feature: Browse Python with behave

Scenario Outline: Run a simple search on Python site using with version on
Given we have behave installed using with version on
when we browse to a site at url
then the page is captured

Examples:
| platform | browser | version | url |
| WIN8_1 | firefox | ANY | http://www.python.org |
| WINDOWS | chrome | ANY | http://www.python.org |
| WINDOWS | internet explorer | 9 | http://www.python.org |
| WINDOWS | firefox | 47.0 | http://www.python.org |
| WINDOWS | internet explorer | 11 | http://www.python.org |
| MAC | safari | 7.1.5 | http://www.python.org |
| WIN10 | internet explorer | Edge | http://www.python.org |
| WIN10 | firefox | 56.0 | http://www.python.org |
| WIN10 | chrome | 56.0 | http://www.python.org |
`

Errorlog
`Feature: Browse Python with behave # browsepython.feature:1

Scenario Outline: Run a simple search on Python site using firefox with version ANY on WIN8_1 -- @1.1 # browsepython.feature:10
Given we have behave installed using firefox with version ANY on WIN8_1 # stepsbrowsepython.py:13
Traceback (most recent call last):
File "c:python36-32libsite-packagesbehavemodel.py", line 1456, in run
match.run(runner.context)
File "c:python36-32libsite-packagesbehavemodel.py", line 1903, in run
self.func(context, args, *kwargs)
File "stepsbrowsepython.py", line 19, in step_impl
desired_capabilities={'platform': platform, 'browserName': browser, 'javascriptEnabled': True}
File "c:python36-32libsite-packagesseleniumwebdriverremotewebdriver.py", line 151, in __init__
self.start_session(desired_capabilities, browser_profile)
File "c:python36-32libsite-packagesseleniumwebdriverremotewebdriver.py", line 240, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "c:python36-32libsite-packagesseleniumwebdriverremotewebdriver.py", line 308, in execute
self.error_handler.check_response(response)
File "c:python36-32libsite-packagesseleniumwebdriverremoteerrorhandler.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
Build info: version: '3.7.0', revision: '2321c73', time: '2017-11-02T22:12:12.411Z'
System info: host: 'QA5', ip: '172.16.31.136', os.name: 'Windows 8.1', os.arch: 'x86', os.version: '6.3', java.version: '1.8.0_121'
Driver info: driver.version: unknown
remote stacktrace: stack backtrace:
0: 0x47e934 -
1: 0x47f0a3 -
2: 0x442511 -
3: 0x4436da -
4: 0x42a890 -
5: 0x406f5e -
6: 0x40cfc9 -
7: 0x6bef19 -
8: 0x420756 -
9: 0x6b96e0 -
10: 0x7fffa42e15dd - BaseThreadInitThunk
Stacktrace:
at sun.reflect.NativeConstructorAccessorImpl.newInstance0 (None:-2)
at sun.reflect.NativeConstructorAccessorImpl.newInstance (None:-1)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance (None:-1)
at java.lang.reflect.Constructor.newInstance (None:-1)
at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$new$0 (W3CHandshakeResponse.java:57)
at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$getResponseFunction$2 (W3CHandshakeResponse.java:104)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0 (ProtocolHandshake.java:123)
at java.util.stream.ReferencePipeline$3$1.accept (None:-1)
at java.util.Spliterators$ArraySpliterator.tryAdvance (None:-1)
at java.util.stream.ReferencePipeline.forEachWithCancel (None:-1)
at java.util.stream.AbstractPipeline.copyIntoWithCancel (None:-1)
at java.util.stream.AbstractPipeline.copyInto (None:-1)
at java.util.stream.AbstractPipeline.wrapAndCopyInto (None:-1)
at java.util.stream.FindOps$FindOp.evaluateSequential (None:-1)
at java.util.stream.AbstractPipeline.evaluate (None:-1)
at java.util.stream.ReferencePipeline.findFirst (None:-1)
at org.openqa.selenium.remote.ProtocolHandshake.createSession (ProtocolHandshake.java:126)
at org.openqa.selenium.remote.ProtocolHandshake.createSession (ProtocolHandshake.java:73)
at org.openqa.selenium.remote.server.ServicedSession$Factory.apply (ServicedSession.java:218)
at org.openqa.selenium.remote.server.ActiveSessionFactory.lambda$apply$11 (ActiveSessionFactory.java:167)
at java.util.stream.ReferencePipeline$3$1.accept (None:-1)
at java.util.stream.ReferencePipeline$3$1.accept (None:-1)
at java.util.stream.ReferencePipeline$11$1.accept (None:-1)
at java.util.stream.ReferencePipeline$2$1.accept (None:-1)
at java.util.Spliterators$ArraySpliterator.tryAdvance (None:-1)
at java.util.stream.ReferencePipeline.forEachWithCancel (None:-1)
at java.util.stream.AbstractPipeline.copyIntoWithCancel (None:-1)
at java.util.stream.AbstractPipeline.copyInto (None:-1)
at java.util.stream.AbstractPipeline.wrapAndCopyInto (None:-1)
at java.util.stream.FindOps$FindOp.evaluateSequential (None:-1)
at java.util.stream.AbstractPipeline.evaluate (None:-1)
at java.util.stream.ReferencePipeline.findFirst (None:-1)
at org.openqa.selenium.remote.server.ActiveSessionFactory.apply (ActiveSessionFactory.java:170)
at org.openqa.selenium.remote.server.NewSessionPipeline.lambda$null$1 (NewSessionPipeline.java:44)
at java.util.stream.ReferencePipeline$3$1.accept (None:-1)
at java.util.Collections$2.tryAdvance (None:-1)
at java.util.stream.ReferencePipeline.forEachWithCancel (None:-1)
at java.util.stream.AbstractPipeline.copyIntoWithCancel (None:-1)
at java.util.stream.AbstractPipeline.copyInto (None:-1)
at java.util.stream.AbstractPipeline.wrapAndCopyInto (None:-1)
at java.util.stream.FindOps$FindOp.evaluateSequential (None:-1)
at java.util.stream.AbstractPipeline.evaluate (None:-1)
at java.util.stream.ReferencePipeline.findFirst (None:-1)
at org.openqa.selenium.remote.server.NewSessionPipeline.lambda$createNewSession$2 (NewSessionPipeline.java:47)
at java.util.stream.ReferencePipeline$3$1.accept (None:-1)
at java.util.stream.ReferencePipeline$3$1.accept (None:-1)
at java.util.stream.ReferencePipeline$3$1.accept (None:-1)
at java.util.stream.DistinctOps$1$2.accept (None:-1)
at java.util.stream.ReferencePipeline$2$1.accept (None:-1)
at java.util.stream.ReferencePipeline$3$1.accept (None:-1)
at java.util.stream.ReferencePipeline$2$1.accept (None:-1)
at java.util.stream.Streams$StreamBuilderImpl.tryAdvance (None:-1)
at java.util.stream.Streams$ConcatSpliterator.tryAdvance (None:-1)
at java.util.stream.ReferencePipeline.forEachWithCancel (None:-1)
at java.util.stream.AbstractPipeline.copyIntoWithCancel (None:-1)
at java.util.stream.AbstractPipeline.copyInto (None:-1)
at java.util.stream.AbstractPipeline.wrapAndCopyInto (None:-1)
at java.util.stream.FindOps$FindOp.evaluateSequential (None:-1)
at java.util.stream.AbstractPipeline.evaluate (None:-1)
at java.util.stream.ReferencePipeline.findFirst (None:-1)
at org.openqa.selenium.remote.server.NewSessionPipeline.createNewSession (NewSessionPipeline.java:50)
at org.openqa.selenium.remote.server.commandhandler.BeginSession.execute (BeginSession.java:77)
at org.openqa.selenium.remote.server.WebDriverServlet.lambda$handle$0 (WebDriverServlet.java:240)
at java.util.concurrent.Executors$RunnableAdapter.call (None:-1)
at java.util.concurrent.FutureTask.run (None:-1)
at java.util.concurrent.ThreadPoolExecutor.runWorker (None:-1)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (None:-1)
at java.lang.Thread.run (None:-1)

When we browse to a site at url http://www.python.org                                                 # None
Then the page is captured                                                                             # None

Failing scenarios:
browsepython.feature:10 Run a simple search on Python site using firefox with version ANY on WIN8_1 -- @1.1

0 features passed, 1 failed, 0 skipped
0 scenarios passed, 1 failed, 0 skipped
0 steps passed, 1 failed, 2 skipped, 0 undefined
Took 0m0.655s`

Config for Selenium Node

{
"capabilities":
[
{
"browserName": "firefox",
"seleniumProtocol": "WebDriver",
"platform": "WIN8_1",
"version": "56.0",
"maxInstances": 5
},
{
"browserName": "chrome",
"maxInstances": 5,
"platform": "WIN8_1",
"version": "62.0.W8.QA5",
"seleniumProtocol": "WebDriver"
}
],
"maxSession": 5,
"port": 6666,
"register": true,
"registerCycle": 5000,
"hub": "http://172.16.31.133:4444",
"nodeStatusCheckTimeout": 5000,
"nodePolling": 5000,
"role": "node",
"unregisterIfStillDownAfter": 60000,
"downPollingLimit": 2,
"debug": false,
"servlets" : [],
"withoutServlets": [],
"custom": {}
}

I tried this on Firefox versions 44, 55 and 56
Used Geckodriver 0.16 - 0.19.
Chromedriver works perfect

@sergiybuch please open another issue

@lmtierney well, I have installed firefox at C:\Users\MY_USER_NAME\AppData\Local\Mozilla Firefox\firefox.exe which was the default for my Windows 10 setup.

Now the issue changed to

>>> driver = webdriver.Firefox(firefox_options=opts)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\MY_USER_NAME\AppData\Roaming\Python\Python36\site-packages\selenium\webdriver\firefox\webdriver.py", line 143, in __init__
    self.service = Service(executable_path, log_path=log_path)
  File "C:\Users\MY_USER_NAME\AppData\Roaming\Python\Python36\site-packages\selenium\webdriver\firefox\service.py", line 44, in __init__
    log_file = open(log_path, "a+") if log_path is not None and log_path != "" else None
PermissionError: [Errno 13] Permission denied: 'geckodriver.log'

My default user does not have admin rights and I elevate to admin each time it is needed. It seems not to be default on Windows though...

After I have dealt with the permissions issue, now it is working fine! So I would just hope that soon the driver will have a look at %APPDATA%\..\Local\Mozilla Firefox\firefox.exe when firefox is not found under C:\Progra...

For the completeness, here my working solution after adjusting permission issues:

from selenium import webdriver
from selenium.webdriver.firefox.options import Options

opts = Options()
opts.binary = r"C:\Users\MY_USER_NAME\AppData\Local\Mozilla Firefox\firefox.exe"
driver = webdriver.Firefox(firefox_options=opts)

@lmtierney It would be kind if I can close the issue myself when I see that it is solved :)

After I have dealt with the permissions issue, now it is working fine! So I would just hope that soon the driver will have a look at %APPDATA%..LocalMozilla Firefoxfirefox.exe when firefox is not found under C:Progra...

This would be an issue for geckodriver, https://github.com/mozilla/geckodriver

@lmtierney It would be kind if I can close the issue myself when I see that it is solved :)

I'm not sure what you mean by this. There was no issue for selenium here.

Was this page helpful?
0 / 5 - 0 ratings