Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Unable to find a matching set of capabilities" -- Selenium with Python 2.7

Using Selenium 3.8.1 with Python 2.7 with Firefox Portable 54, 64 bit, I get the following error message when running this script:

from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

binary_argument = FirefoxBinary(r'C:\Users\[removed]\FirefoxPortable.exe')
driver = webdriver.Firefox(firefox_binary=binary_argument)

driver.get("http://icanhazip.com")

.

Traceback (most recent call last):
  File "F:/cp/python-selenium3/ToyScripts/launch_portable_browser.py", line 5, in <module>
    driver = webdriver.Firefox(firefox_binary=binary_argument)
  File "C:\ProgramData\Anaconda2\envs\automation2\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 162, in __init__
    keep_alive=True)
  File "C:\ProgramData\Anaconda2\envs\automation2\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 154, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "C:\ProgramData\Anaconda2\envs\automation2\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 243, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "C:\ProgramData\Anaconda2\envs\automation2\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 312, in execute
    self.error_handler.check_response(response)
  File "C:\ProgramData\Anaconda2\envs\automation2\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

I do see the splash screen for a moment before it disappears. Also worth noting is that the browser works fine when used manually.

I suspect that the portable browser needs some settings switched to allow Selenium to take over, but that is the extent of what i know/suspect.

Thank you for any help with this.

like image 575
Sean D Avatar asked Jan 28 '23 11:01

Sean D


2 Answers

Solved by modifying DesiredCapabilities:

from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

binary_argument = FirefoxBinary(r'C:\Users\[removed]\FirefoxPortable.exe')

capabilities_argument = DesiredCapabilities().FIREFOX
capabilities_argument["marionette"] = False

driver = webdriver.Firefox(firefox_binary=binary_argument, capabilities=capabilities_argument)

driver.get("http://icanhazip.com")
like image 130
Sean D Avatar answered Feb 19 '23 04:02

Sean D


I was able to resolve this issue by installing the latest geckodriver from https://www.seleniumhq.org/download/ and latest firefox from https://www.mozilla.org/en-US/firefox/. Please consider your windows when downloading geckodriver (32 bit or 64 bit).

I hope this helps.

like image 25
Karan Avatar answered Feb 19 '23 04:02

Karan