0
-rwxr-xr-x 1 kyle kyle 6132584 Feb 24 09:27 /usr/local/bin/geckodriver

echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/kyle/.dotnet/tools

It is my understanding selenium should be able to find the driver automatically. That does not seem to work for me.

pip show selenium
Name: selenium
Version: 4.18.1

If I try and run my python script with:

driver = webdriver.Firefox()

I get

Message: Unable to obtain driver for firefox using Selenium Manager.

If I use

driver = webdriver.Firefox("/usr/local/bin/geckodriver")
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/selenium/webdriver/common/driver_finder.py", line 38, in get_path
    path = SeleniumManager().driver_location(options) if path is None else path
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/selenium/webdriver/common/selenium_manager.py", line 87, in driver_location
    browser = options.capabilities["browserName"]
              ^^^^^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'capabilities'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/kyle/Documents/ElecticityUsage.py", line 181, in <module>
    driver = webdriver.Firefox("/usr/local/bin/geckodriver")
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/selenium/webdriver/firefox/webdriver.py", line 59, in __init__
    self.service.path = DriverFinder.get_path(self.service, options)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/selenium/webdriver/common/driver_finder.py", line 40, in get_path
    msg = f"Unable to obtain driver for {options.capabilities['browserName']} using Selenium Manager."
                                         ^^^^^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'capabilities'
2
  • newest Selenium should download driver. Commented Aug 19, 2025 at 23:38
  • you can't do webdriver.Firefox("/usr/local/bin/geckodriver") because it treats it as different parameter. Commented Aug 19, 2025 at 23:40

2 Answers 2

1

Newer Selenium should download driver automatically.

But if you need to use existing driver then in current version you have to use

#from selenium.webdriver.chrome.service import Service
from selenium.webdriver.firefox.service import Service

service = Service(executable_path="/usr/local/bin/geckodriver")
driver = webdriver.Firefox(service=service)

In older Selenium you can also use module webdriver_manager to download it automatically

#from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.firefox import GeckoDriverManager

#driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
driver = webdriver.Firefox(service=Service(GeckoDriverManager().install()))

If you get

Message: Unable to obtain driver for firefox using Selenium Manager.

then you may have to check what version of Firefox you have because maybe you have too new version and driver doesn't exist for this version.

Sign up to request clarification or add additional context in comments.

2 Comments

Also note.. if Firefox isn't found on your PATH, Selenium Manager will download it along with the matching geckodriver version.
It's more likely you have too old a version of Firefox, not too new. Geckodriver release usually coincides with Firefox release and can usually also handle beta and newer versions.
-1

So ideally your line of code:

driver = webdriver.Firefox()

should have worked as Selenium Manager can silently download the matching GeckoDriver and you don't have to explicitly mention the geckodriver path anymore.

5 Comments

OP's problem was that he passed a string to the Firefox(). Nothing in this answer is relevant or helpful.
yeah, so where in my answer did I say OP passed the right argument type? Can you reread the complete answer once and come again to let me know if the solution I provided is missing something?
You didn't say anything about the argument type... if you did, it might have answered the question. You just incorrectly pointed out that the error message "implied" something that it definitely didn't. Answers are supposed to answer the question asked, not give general advice for what you perceive the OP might want to do.
It's isn't necessary to mention what happened when in Selenium's history since Selenium's birth with v1.0.0. Though you said it right that Answers are supposed to answer the question still you are confused with the universal solution of using Selenium Manager which is implemented since version v4.6. I think you should start understanding other's answers & perspectives too in order to help OP find the most helpful solution.
I removed the irrelevant information from the answer.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.