4

I was trying to open the firefox browser using selenium webdriver. I already have my geckodriver in /usr/local/bin as I'm working on project of web scraping and crawling.

  • Geckodriver version-21.0
  • Firefox version-64.0 (quantum)
  • Selenium version- 3.141.0.

Also tried geckodriver of versions i.e 17.0,19.0,23.0; to find the combination.

What I have tried is in the following code.

from selenium import webdriver
from selenium.webdriver.support.select import Select
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.common.keys import Keys
from bs4 import BeautifulSoup

driver=webdriver.Firefox()
driver.get("https://kissanime.ru/")
driver.maximize_window()

While executing the code it popped an error:

Traceback (most recent call last):
  File "downloader.py", line 9, in <module>
    driver=webdriver.Firefox()
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/firefox/webdriver.py", line 174, in __init__
keep_alive=True)
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.6/dist-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
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Make sure you're using the correct 32/64 bit version of the binaries - it should be uniform - e.g. if the firefox is 64bit, so must be the geckodriver. – Todor Minakov Dec 30 '18 at 06:38

1 Answers1

4

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 WebBrowsing Session i.e. Firefox Browser session.

Your main issue may be the incompatibility between the version of the binaries you are using as follows:

Solution

  • Upgrade Selenium to current levels Version 3.141.59.
  • Upgrade GeckoDriver to GeckoDriver v0.23.0 level.
  • Ensure GeckoDriver is present in the specified location.
  • Ensure GeckoDriver is having executable permission for non-root users.
  • Upgrade Firefox version to Firefox v64.0. levels.
  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
  • (WindowsOS only) Use CCleaner tool to wipe off all the OS chores before and after the execution of your Test Suite.
  • (LinuxOS only) Free Up and Release the Unused/Cached Memory in Ubuntu/Linux Mint before and after the execution of your Test Suite.
  • If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
  • Take a System Reboot.
  • Pass the argument executable_path along with the absolute path of the GeckoDriver while initiating the WebDriver/WebBrowser session as follows:

    • Windows OS format:

      driver = webdriver.Firefox(executable_path=r'C:\path\to\geckodriver.exe')
      
    • Linux and MAC OS X format:

      driver = webdriver.Firefox(executable_path='/path/to/geckodriver')
      
  • Execute your Test as a non-root user.

  • Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • I'm alredy using the latest version of selenium i.e 3.141.0 for python, have latest firefox version i.e 64.0 and latest geckodriver i.e 23.0, as you recommened to clear cached memory tried that too and also passed executable_path but ended with the same error. – Devansh Mishra Dec 28 '18 at 05:04
  • @DevanshMishra Can you update the question with your current code trials and error trace logs? – undetected Selenium Dec 28 '18 at 05:07