0

I am trying to write a program using selenium in python that will open a firefox window and go to twitter. I have placed the geckdriver.exe in my python 3.6 folder and installed firefox. I have also ran 'pip install selnium' and installed selenium.

This is the code i have written:

from selenium import webdriver

browser = webdriver.Firefox(executable_path="C:\\Users\\Harry\\AppData\\Local\\Programs\\Python\\Python36-32\\geckodriver.exe")
browser.get("https://www.twitter.com/")`

When run the output is:

PS C:\Users\Harry\Desktop\Coding\Python\Bots\TwitterBot> python app.py Traceback (most recent call last): File "app.py", line 5, in browser = webdriver.Firefox() File "C:\Users\Harry\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 174, in init keep_alive=True) File "C:\Users\Harry\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in init self.start_session(capabilities, browser_profile) File "C:\Users\Harry\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session response = self.execute(Command.NEW_SESSION, parameters) File "C:\Users\Harry\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "C:\Users\Harry\AppData\Local\Programs\Python\Python36-32\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

Why is this and what can i do to fix it? I am using python 3.6 and Visual Studio Code to code my program. Firefox version is latest one out at time of writing.

CEH
  • 5,701
  • 2
  • 16
  • 40
hskerr4
  • 11
  • 1
  • https://github.com/mozilla/geckodriver/issues/1178 This github issue might help. – CEH Dec 16 '19 at 19:48

1 Answers1

0

I think you have to try one of these solutions:

  • Use DesiredCapabilities:

    from Selenium import webdriver
    
    from Selenium.webdriver.common.desired_capabilities import DesiredCapabilities
    
    cap = DesiredCapabilities().FIREFOX
    
    cap["marionette"] = False
    
    browser = webdriver.Firefox(capabilities=cap, executable_path="C:\\Users\\Harry\\AppData\\Local\\Programs\\Python\\Python36-32\\geckodriver.exe")
    
    browser.get('https://twitter.com/')
    
    browser.quit()
    
  • Updating Firefox and Selenium and reinstall geckodriver

Mahrez BenHamad
  • 1,791
  • 1
  • 15
  • 21