Facing the error: "binary is not a Firefox executable" when using Selenium with Firefox WebDriver

25 views Asked by At

Title: Error: "binary is not a Firefox executable" when using Selenium with Firefox WebDriver

Body: I'm encountering an error while trying to use Selenium with Firefox WebDriver. Here's the error message:

selenium.common.exceptions.InvalidArgumentException: Message: binary is not a Firefox executable

I'm using the following code:

from selenium.webdriver.firefox.options import Options
from selenium import webdriver
import time

options = Options()
options.binary_location = r'/usr/bin/firefox' # Provide the path to the Firefox binary

driver = webdriver.Firefox(options=options)

I've set the binary_location to the path of my Firefox binary, but I'm still getting this error. Can someone please help me understand why this error is occurring and how to resolve it? Thank you.

Full error message

Traceback (most recent call last):
  File "/home/myusername/project1/buble/ff.py", line 8, in <module>
    driver = webdriver.Firefox(options=options)
  File "/home/myusername/.local/lib/python3.10/site-packages/selenium/webdriver/firefox/webdriver.py", line 69, in __init__
    super().__init__(command_executor=executor, options=options)
  File "/home/myusername/.local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 208, in __init__
    self.start_session(capabilities)
  File "/home/myusername/.local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 292, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
  File "/home/myusername/.local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 347, in execute
    self.error_handler.check_response(response)
  File "/home/myusername/.local/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.InvalidArgumentException: Message: binary is not a Firefox executable
0

There are 0 answers