Skip to content

[🐛 Bug]: Message: binary is not a Firefox executable #15683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
arghorashy opened this issue Apr 30, 2025 · 17 comments
Closed

[🐛 Bug]: Message: binary is not a Firefox executable #15683

arghorashy opened this issue Apr 30, 2025 · 17 comments
Labels
A-needs-triaging A Selenium member will evaluate this soon! C-py Python Bindings D-firefox I-defect Something is not working as intended OS-linux

Comments

@arghorashy
Copy link

arghorashy commented Apr 30, 2025

Description

I have a python script I have working on one computer, but when I try to run it on my server I get the following error:

    self.driver = webdriver.Firefox(service=service, options=options)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".venv/lib/python3.12/site-packages/selenium/webdriver/firefox/webdriver.py", line 71, in __init__
    super().__init__(command_executor=executor, options=options)
  File ".venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 241, in __init__
    self.start_session(capabilities)
  File ".venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 329, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 384, in execute
    self.error_handler.check_response(response)
  File ".venv/lib/python3.12/site-packages/selenium/webdriver/remote/errorhandler.py", line 232, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.InvalidArgumentException: Message: binary is not a Firefox executable

Here is the code I'm running:

from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
import selenium.webdriver.firefox.service as FirefoxService

options = Options()
service = FirefoxService.Service(executable_path='/snap/bin/geckodriver')
options.binary_location = "/usr/bin/firefox"
webdriver.Firefox(service=service, options=options)

On my computer where this worked, I didn't need to specify locations for geckodriver or firefox. If I get rid of the arguments to webdriver.Firefox, I get the same result, by the way, so I'm not sure they're doing anything...

Here is some relevant version info for the original computer where this worked:

  • OS: Linux Mint 22.1
  • Python v3.12.3
  • Selenium v4.27.1
  • Firefox v135.0.1
  • Gecko - interestingly which geckodriver returns nothing

Here is some version information for the server where I am encountering this issue:

  • OS: Ubuntu 22.04.5 LTS
  • Python v3.12.10
  • Selenium v4.31.0
  • Firefox v138.0
  • Gecko v0.36.0

Reproducible Code

from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
import selenium.webdriver.firefox.service as FirefoxService

options = Options()
service = FirefoxService.Service(executable_path='/snap/bin/geckodriver')
options.binary_location = "/usr/bin/firefox"
webdriver.Firefox(service=service, options=options)

Debugging Logs

self.driver = webdriver.Firefox(service=service, options=options)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".venv/lib/python3.12/site-packages/selenium/webdriver/firefox/webdriver.py", line 71, in __init__
    super().__init__(command_executor=executor, options=options)
  File ".venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 241, in __init__
    self.start_session(capabilities)
  File ".venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 329, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 384, in execute
    self.error_handler.check_response(response)
  File ".venv/lib/python3.12/site-packages/selenium/webdriver/remote/errorhandler.py", line 232, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.InvalidArgumentException: Message: binary is not a Firefox executable
@arghorashy arghorashy added A-needs-triaging A Selenium member will evaluate this soon! I-defect Something is not working as intended labels Apr 30, 2025
@selenium-ci
Copy link
Member

@arghorashy, thank you for creating this issue. We will troubleshoot it as soon as we can.

Selenium Triage Team: remember to follow the Triage Guide

@cgoldberg
Copy link
Contributor

cgoldberg commented Apr 30, 2025

It looks like you are running the Snap version of geckodriver, but a non-Snap version of Firefox? That might be problematic.

If I get rid of the arguments to webdriver.Firefox, I get the same result

That should work (it will download the latest Firefox and geckodriver)

Can you please do the following:

@cgoldberg cgoldberg added J-awaiting answer Question asked of user; a reply moves it to triage again J-logging Applied to issues where logging information would help troubleshoot and removed A-needs-triaging A Selenium member will evaluate this soon! labels Apr 30, 2025
@arghorashy
Copy link
Author

arghorashy commented Apr 30, 2025

Thanks for your reply. Per your instructions, I ran this:

import logging
logger = logging.getLogger('selenium')
logger.setLevel(logging.DEBUG)
log_path = './log'
handler = logging.FileHandler(log_path)
logger.addHandler(handler)

from selenium import webdriver
webdriver.Firefox()

In STDOUT I got this:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".venv/lib/python3.12/site-packages/selenium/webdriver/firefox/webdriver.py", line 71, in __init__
    super().__init__(command_executor=executor, options=options)
  File ".venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 250, in __init__
    self.start_session(capabilities)
  File ".venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 342, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 429, in execute
    self.error_handler.check_response(response)
  File ".venv/lib/python3.12/site-packages/selenium/webdriver/remote/errorhandler.py", line 232, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.InvalidArgumentException: Message: binary is not a Firefox executable

In my log file I got this output:

Selenium Manager binary found at: .venv/lib/python3.12/site-packages/selenium/webdriver/common/linux/selenium-manager
Executing process: .venv/lib/python3.12/site-packages/selenium/webdriver/common/linux/selenium-manager --browser firefox --debug --language-binding python --output json
Found geckodriver 0.36.0 in PATH: /snap/bin/geckodriver
firefox detected at /usr/bin/firefox
Running command: /usr/bin/firefox -v
Output: "Mozilla Firefox 138.0"
Detected browser: firefox 138.0
Required driver: geckodriver 0.36.0
Driver path: /snap/bin/geckodriver
Browser path: /usr/bin/firefox
Started executable: `/snap/bin/geckodriver` in a child process with pid: 5691 using 0 to output -3
POST http://localhost:55333/session {'capabilities': {'firstMatch': [{}], 'alwaysMatch': {'browserName': 'firefox', 'acceptInsecureCerts': True, 'moz:debuggerAddress': True, 'pageLoadStrategy': <PageLoadStrategy.normal: 'normal'>, 'browserVersion': None, 'moz:firefoxOptions': {'binary': '/usr/bin/firefox', 'prefs': {'remote.active-protocols': 3}}}}}
Remote response: status=400 | data={"value":{"error":"invalid argument","message":"binary is not a Firefox executable","stacktrace":""}} | headers=HTTPHeaderDict({'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-cache', 'content-length': '101', 'date': 'Wed, 30 Apr 2025 20:59:32 GMT'})
Finished Request

@selenium-ci
Copy link
Member

We need more information about this issue in order to troubleshoot.

Please turn on logging and re-run your code. Information on how to adjust logs for your language can be found in our
Troubleshooting documentation.

@cgoldberg
Copy link
Contributor

@arghorashy
The log shows it is still using your system browser/driver rather than downloading the latest. I'm not sure why that is happening.

Can you try running your code with the SE_FORCE_BROWSER_DOWNLOAD environment variables set to true? So in your shell, just run export SE_FORCE_BROWSER_DOWNLOAD=true, then run your code.

@bonigarcia Do you know what is going on here? Based on the code/log shown in #15683 (comment) , shouldn't Selenium Manager not be using the system driver/browser?

@cgoldberg cgoldberg removed J-awaiting answer Question asked of user; a reply moves it to triage again J-logging Applied to issues where logging information would help troubleshoot labels Apr 30, 2025
@titusfortner
Copy link
Member

If the user has the location of a driver in the PATH environment variable, that driver will be used.

That code is telling Selenium to use the snap driver with a non-snap installation of firefox.
The snap driver is different from the driver you download, so remove its location from PATH if you don't want to use it.

@titusfortner titusfortner added the J-awaiting answer Question asked of user; a reply moves it to triage again label Apr 30, 2025
@arghorashy
Copy link
Author

Someone mentioned that using a non-Snap version of Firefox and a Snap version of geckodriver was part of the problem, so I ran sudo apt remove firefox, as I had only installed it in an attempt to get this to work. To check Firefox was gone, I executed which firefox, expecting it to return nothing, but to my surprise, it returned /snap/bin/firefox. I double-checked which geckodriver, which returned /snap/bin/geckodriver. I assumed this meant they were both from Snap, so I figured things might now work based on the comment about mixing non-Snap and Snap...

I ran this:

import logging
logger = logging.getLogger('selenium')
logger.setLevel(logging.DEBUG)
log_path = './log'
handler = logging.FileHandler(log_path)
logger.addHandler(handler)

from selenium import webdriver
webdriver.Firefox()

I got this in STDOUT (not the original "binary is not a Firefox executable" message):

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".venv/lib/python3.12/site-packages/selenium/webdriver/firefox/webdriver.py", line 71, in __init__
    super().__init__(command_executor=executor, options=options)
  File ".venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 250, in __init__
    self.start_session(capabilities)
  File ".venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 342, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 429, in execute
    self.error_handler.check_response(response)
  File ".venv/lib/python3.12/site-packages/selenium/webdriver/remote/errorhandler.py", line 232, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 1

I got this in the log file (500 error):

Selenium Manager binary found at: .venv/lib/python3.12/site-packages/selenium/webdriver/common/linux/selenium-manager
Executing process: .venv/lib/python3.12/site-packages/selenium/webdriver/common/linux/selenium-manager --browser firefox --debug --language-binding python --output json
Found geckodriver 0.36.0 in PATH: /snap/bin/geckodriver
Found firefox in PATH: /snap/bin/firefox
Using firefox snap: /snap/firefox/current/usr/lib/firefox/firefox
Running command: /snap/firefox/current/usr/lib/firefox/firefox -v
Output: "Mozilla Firefox 138.0"
Detected browser: firefox 138.0
Required driver: geckodriver 0.36.0
Driver path: /snap/bin/geckodriver
Browser path: /snap/firefox/current/usr/lib/firefox/firefox
Started executable: `/snap/bin/geckodriver` in a child process with pid: 7454 using 0 to output -3
POST http://localhost:51705/session {'capabilities': {'firstMatch': [{}], 'alwaysMatch': {'browserName': 'firefox', 'acceptInsecureCerts': True, 'moz:debuggerAddress': True, 'pageLoadStrategy': <PageLoadStrategy.normal: 'normal'>, 'browserVersion': None, 'moz:firefoxOptions': {'binary': '/snap/firefox/current/usr/lib/firefox/firefox', 'prefs': {'remote.active-protocols': 3}}}}}
Remote response: status=500 | data={"value":{"error":"unknown error","message":"Process unexpectedly closed with status 1","stacktrace":""}} | headers=HTTPHeaderDict({'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-cache', 'content-length': '105', 'date': 'Thu, 01 May 2025 00:56:58 GMT'})
Finished Request

I then tried running export SE_FORCE_BROWSER_DOWNLOAD=true and then running the same set of python commands again. Here is what I got in STDOUT (back to the "binary is not a Firefox executable" mesage):

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".venv/lib/python3.12/site-packages/selenium/webdriver/firefox/webdriver.py", line 71, in __init__
    super().__init__(command_executor=executor, options=options)
  File ".venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 250, in __init__
    self.start_session(capabilities)
  File ".venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 342, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 429, in execute
    self.error_handler.check_response(response)
  File ".venv/lib/python3.12/site-packages/selenium/webdriver/remote/errorhandler.py", line 232, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.InvalidArgumentException: Message: binary is not a Firefox executable

This is what I got in the log file (400 error):

Selenium Manager binary found at: .venv/lib/python3.12/site-packages/selenium/webdriver/common/linux/selenium-manager
Executing process: .venv/lib/python3.12/site-packages/selenium/webdriver/common/linux/selenium-manager --browser firefox --debug --language-binding python --output json
Found geckodriver 0.36.0 in PATH: /snap/bin/geckodriver
Required browser: firefox 138.0
firefox 138.0 already exists
firefox 138.0 is available at /home/arg/.cache/selenium/firefox/linux64/138.0/firefox
Required driver: geckodriver 0.36.0
Driver path: /snap/bin/geckodriver
Browser path: /home/arg/.cache/selenium/firefox/linux64/138.0/firefox
Started executable: `/snap/bin/geckodriver` in a child process with pid: 7788 using 0 to output -3
POST http://localhost:60397/session {'capabilities': {'firstMatch': [{}], 'alwaysMatch': {'browserName': 'firefox', 'acceptInsecureCerts': True, 'moz:debuggerAddress': True, 'pageLoadStrategy': <PageLoadStrategy.normal: 'normal'>, 'browserVersion': None, 'moz:firefoxOptions': {'binary': '/home/arg/.cache/selenium/firefox/linux64/138.0/firefox', 'prefs': {'remote.active-protocols': 3}}}}}
Remote response: status=400 | data={"value":{"error":"invalid argument","message":"binary is not a Firefox executable","stacktrace":""}} | headers=HTTPHeaderDict({'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-cache', 'content-length': '101', 'date': 'Thu, 01 May 2025 01:00:33 GMT'})
Finished Request

Finally, I decided to pull out the big guns and run sudo snap remove firefox and even for good measure, sudo snap remove geckodriver. I verified both were gone using which commands.

I ran the same python commands with the environment variable still set. Here is what I got on the console:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".venv/lib/python3.12/site-packages/selenium/webdriver/firefox/webdriver.py", line 71, in __init__
    super().__init__(command_executor=executor, options=options)
  File ".venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 250, in __init__
    self.start_session(capabilities)
  File ".venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 342, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 429, in execute
    self.error_handler.check_response(response)
  File ".venv/lib/python3.12/site-packages/selenium/webdriver/remote/errorhandler.py", line 232, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 1

Here is what I got in the log file:

Selenium Manager binary found at: .venv/lib/python3.12/site-packages/selenium/webdriver/common/linux/selenium-manager
Executing process: .venv/lib/python3.12/site-packages/selenium/webdriver/common/linux/selenium-manager --browser firefox --debug --language-binding python --output json
geckodriver not found in PATH
Required browser: firefox 138.0
firefox 138.0 already exists
firefox 138.0 is available at /home/arg/.cache/selenium/firefox/linux64/138.0/firefox
Required driver: geckodriver 0.36.0
Acquiring lock: /home/arg/.cache/selenium/geckodriver/linux64/0.36.0/sm.lock
Downloading geckodriver 0.36.0 from https://github.com/mozilla/geckodriver/releases/download/v0.36.0/geckodriver-v0.36.0-linux64.tar.gz
Driver path: /home/arg/.cache/selenium/geckodriver/linux64/0.36.0/geckodriver
Browser path: /home/arg/.cache/selenium/firefox/linux64/138.0/firefox
Started executable: `/home/arg/.cache/selenium/geckodriver/linux64/0.36.0/geckodriver` in a child process with pid: 10572 using 0 to output -3
POST http://localhost:53541/session {'capabilities': {'firstMatch': [{}], 'alwaysMatch': {'browserName': 'firefox', 'acceptInsecureCerts': True, 'moz:debuggerAddress': True, 'pageLoadStrategy': <PageLoadStrategy.normal: 'normal'>, 'browserVersion': None, 'moz:firefoxOptions': {'binary': '/home/arg/.cache/selenium/firefox/linux64/138.0/firefox', 'prefs': {'remote.active-protocols': 3}}}}}
Remote response: status=500 | data={"value":{"error":"unknown error","message":"Process unexpectedly closed with status 1","stacktrace":""}} | headers=HTTPHeaderDict({'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-cache', 'content-length': '105', 'date': 'Thu, 01 May 2025 01:07:29 GMT'})
Finished Request

Thanks for your help so far.

@cgoldberg
Copy link
Contributor

cgoldberg commented May 1, 2025

The log looks like it downloaded Firefox and geckodriver (progress!), but Firefox didn't start.

Can you verify you are able to run Firefox without Selenium?

  • run: /home/arg/.cache/selenium/firefox/linux64/138.0/firefox

Verify geckodriver can start also:

  • run /home/arg/.cache/selenium/firefox/linux64/138.0/firefox

@bonigarcia
Copy link
Member

The error binary is not a Firefox executable happened when Firefox was installed using SNAP. Selenium Manager supports Firefox SNAP browser/drivers as of version 0.4.30 (i.e., Selenium 4.3.x). So in theory, nothing needs to be done starting in that version.

@github-actions github-actions bot added A-needs-triaging A Selenium member will evaluate this soon! and removed J-awaiting answer Question asked of user; a reply moves it to triage again labels May 1, 2025
@arghorashy
Copy link
Author

@bonigarcia - In the first post I made, I got the binary is not a Firefox executable even when my Firefox install was in /usr/bin/firefox because I'd gotten it from apt, rather than Snap, so I believe the cause of getting this message is not that clear cut...? Of course, I could be wrong.

I ran firefox from the .cache folder (/home/arg/.cache/selenium/firefox/linux64/138.0/firefox) and it crashed with this message: Error: no DISPLAY environment variable specified

That's fair as this is a server, so I ran it gain with the -headless flag and it outputs this without returning unless I ctrl+c which makes me think it's working:

*** You are running in headless mode.
[GFX1-]: glxtest: Unable to open a connection to the X server
[GFX1-]: RenderCompositorSWGL failed mapping default framebuffer, no dt

I ran geckodriver from the .cache folder (/home/arg/.cache/selenium/geckodriver/linux64/0.36.0/geckodriver) and it hangs with this output which also seems like a good sign: 1746105993302 geckodriver INFO Listening on 127.0.0.1:4444

@cgoldberg
Copy link
Contributor

@arghorashy So it looks like geckodriver starts fine, but Firefox can't... So your issue isn't related to Selenium.

I'm not sure why Firefox requires X11/Wayland in headless mode, but you might need to install one of those on your server. Once you can get Firefox to launch, Selenium should work fine.

@arghorashy
Copy link
Author

arghorashy commented May 1, 2025

I ran sudo apt install xauth xorg openbox and then ssh'd back into my machine with the -X flag and ran /home/arg/.cache/selenium/firefox/linux64/138.0/firefox and didn't get any of the GFX1 errors.

I then went run the python code I've been running over and over again and a Firefox browser opened!

It's at this point that I realized that I was running the wrong python code for this test! I'd forgotten the headless option. Here is the amended python code:

import logging
logger = logging.getLogger('selenium')
logger.setLevel(logging.DEBUG)
log_path = './log'
handler = logging.FileHandler(log_path)
logger.addHandler(handler)

from selenium import webdriver
from selenium.webdriver.firefox.options import Options
options = Options()
options.add_argument('--headless')
webdriver.Firefox(options)

I logged out and logged back in without the -X switch and ran this code and everything works.

So it looks like geckodriver starts fine, but Firefox can't...

So this wasn't quite right. When I ran firefox -headless, the GFX1 errors are not saying that Firefox is not working. The problem was that the separate test in python I was running was wrong and was trying to run Firefox in non-headless mode.

The Real Problem

I don't think all the errors I experienced can be attributed to this mistake though... I reinstalled Firefox (sudo apt install firefox, which firefox = /usr/bin/firefox) and re-ran the above code to get this in STDOUT:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".venv/lib/python3.12/site-packages/selenium/webdriver/firefox/webdriver.py", line 71, in __init__
    super().__init__(command_executor=executor, options=options)
  File ".venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 250, in __init__
    self.start_session(capabilities)
  File ".venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 342, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 429, in execute
    self.error_handler.check_response(response)
  File ".venv/lib/python3.12/site-packages/selenium/webdriver/remote/errorhandler.py", line 232, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.InvalidArgumentException: Message: binary is not a Firefox executable

I get this in the log file:

Selenium Manager binary found at: .venv/lib/python3.12/site-packages/selenium/webdriver/common/linux/selenium-manager
Executing process: .venv/lib/python3.12/site-packages/selenium/webdriver/common/linux/selenium-manager --browser firefox --debug --language-binding python --output json
Found geckodriver 0.36.0 in PATH: /snap/bin/geckodriver
firefox detected at /usr/bin/firefox
Running command: /usr/bin/firefox -v
Output: "Mozilla Firefox 138.0"
Detected browser: firefox 138.0
Required driver: geckodriver 0.36.0
Driver path: /snap/bin/geckodriver
Browser path: /usr/bin/firefox
Started executable: `/snap/bin/geckodriver` in a child process with pid: 7207 using 0 to output -3
POST http://localhost:36443/session {'capabilities': {'firstMatch': [{}], 'alwaysMatch': {'browserName': 'firefox', 'acceptInsecureCerts': True, 'moz:debuggerAddress': True, 'pageLoadStrategy': <PageLoadStrategy.normal: 'normal'>, 'browserVersion': None, 'moz:firefoxOptions': {'binary': '/usr/bin/firefox', 'prefs': {'remote.active-protocols': 3}, 'args': ['--headless']}}}}
Remote response: status=400 | data={"value":{"error":"invalid argument","message":"binary is not a Firefox executable","stacktrace":""}} | headers=HTTPHeaderDict({'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-cache', 'content-length': '101', 'date': 'Thu, 01 May 2025 14:15:49 GMT'})
Finished Request

I noticed that now I'm using /snap/bin/geckodriver and /usr/bin/firefox, which someone suggested might be a problem, so I ran sudo apt remove firefox and ran the test again and it worked! Checking the log file, I see that we're using /snap/bin/geckodriver and /snap/firefox/current/usr/lib/firefox/firefox. Both Snap! So it seems the fundamental roadblock I was experiencing was due to the fact that my geckodriver was from Snap, but Firefox was not.

I wonder if the error message should be made more clear? At least for my system, when I install firefox via apt, I end up with this mixed /snap/bin/geckodriver + /usr/bin/firefox which seems to be fatal!

@cgoldberg
Copy link
Contributor

If it was me, I would steer clear of using Snap packaged Firefox and geckodriver and just let Selenium Manager deal with it.

@titusfortner
Copy link
Member

Remove the snap directory from PATH environment variable
Selenium manager will use any driver found in a directory listed in that environment variable

Your code is still using the snap driver with a non snap browser

@arghorashy
Copy link
Author

Your code is still using the snap driver with a non snap browser

Even though the log file cites these two paths?

/snap/bin/geckodriver
/snap/firefox/current/usr/lib/firefox/firefox

Seems like both are from Snap to me...

@titusfortner
Copy link
Member

Look at the log file you pasted above. Selenium manager controls the browser location and this is what it is saying it is using:

Driver path: /snap/bin/geckodriver
Browser path: /usr/bin/firefox

@arghorashy
Copy link
Author

Sorry for the confusion, but if you read the end of my post carefully, you'll see that that log file you are quoting is from the run where I reinstalled Firefox (sudo apt install firefox) and where my geckodriver was from snap but my Firefox was not.

Because my post was getting long, I did not post the log file for the final run I tried after running sudo apt remove firefox. Instead, I just posted the paths of geckodriver / firefox as they appeared in the log file.

Checking the log file, I see that we're using /snap/bin/geckodriver and /snap/firefox/current/usr/lib/firefox/firefox. Both Snap! So it seems the fundamental roadblock I was experiencing was due to the fact that my geckodriver was from Snap, but Firefox was not.

Just wanted to make sure that it was clear that I didn't need to abandon snap entirely to get my problems to go away. Rather, I just had to ensure I wasn't mismatching snap and non-snap...

Of course, I do take your point that it still might be best to just forgo snap altogether.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-needs-triaging A Selenium member will evaluate this soon! C-py Python Bindings D-firefox I-defect Something is not working as intended OS-linux
Projects
None yet
Development

No branches or pull requests

5 participants