Asad Ullah Butt
Asad Ullah Butt

Reputation: 64

Why can't selenium work with Firefox but it works seamlessly after re-installation?

So I started with 'Automate the boring stuff with Python' and now studying Chapter 11, i.e. Web scraping. During this, I struggled to get my selenium working with Firefox. The version details are as follows:

Windows 10 Pro (64 bit)
Firefox: 81.0 (64 bit) (Latest at the time of writing)
Python: 3.7.9
Selenium: 3.141.0
Geckodriver: 0.27

When I ran the following script, it crashed with an exception:

from selenium import webdriver
driver = webdriver.Firefox()
driver.get("http://www.python.org")

Exception:

Unable to find a matching set of capabilities

I downloaded Firefox installer (using the Firefox browser) , installed it again, which was the same version and the problem magically disappeared. My question is more about the cause of the problem, which is still unknown to me. What could have caused the script to crash for the first time, since practically I did not change anything.

Upvotes: 1

Views: 48

Answers (1)

GProst
GProst

Reputation: 10227

2 guesses:

  1. You had lower version of Firefox before you reinstalled
  2. Could be because of some conflict with the browser that's set default in your OS, to avoid that you could explicitly specify paths to Firefox binaries:
driver = webdriver.Firefox(
  executable_path='/path/to/geckodriver', 
  firefox_binary='/path/to/firefox/binary'
)

Upvotes: 2

Related Questions