Skip to content
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

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

Open
Davide-Leo opened this issue Oct 15, 2024 · 4 comments
Open

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

Davide-Leo opened this issue Oct 15, 2024 · 4 comments

Comments

@Davide-Leo
Copy link

Davide-Leo commented Oct 15, 2024

What happened?

Even by specifying driver path and browser path (as said here: #13169 and here: https://www.selenium.dev/documentation/selenium_manager/#custom-package-managers ) I still get the "binary is not a Firefox executable" message.

from selenium.webdriver import FirefoxOptions
from selenium import webdriver
import selenium.webdriver.firefox.service as FirefoxService

options = FirefoxOptions()

# which firefox
# /usr/bin/firefox
options.binary_location = "/usr/bin/firefox"

# which geckodriver
# /snap/bin/geckodriver
firefoxdriver_bin = "/snap/bin/geckodriver" 
service = FirefoxService.Service(executable_path=firefoxdriver_bin)

driver = webdriver.Firefox(service=service, options=options)
driver.get("https://pythonbasics.org")

By running

/usr/bin/firefox

The browser is properly launched.

How can we reproduce the issue?

python version: Python 3.12.3

apt install firefox
pip install selenium
python provided_script.py

Relevant log output

Traceback (most recent call last):
  File ".../prova.py", line 16, in <module>
    driver = webdriver.Firefox(service=service, options=options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/.../anaconda3/envs/aiweb/lib/python3.12/site-packages/selenium/webdriver/firefox/webdriver.py", line 71, in __init__
    super().__init__(command_executor=executor, options=options)
  File "/home/.../anaconda3/envs/aiweb/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 212, in __init__
    self.start_session(capabilities)
  File "/home/.../anaconda3/envs/aiweb/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 299, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/.../anaconda3/envs/aiweb/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 354, in execute
    self.error_handler.check_response(response)
  File "/home/.../anaconda3/envs/aiweb/lib/python3.12/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

Operating System

Ubuntu 22.04.4 LTS

Selenium version

Version: 4.25.0

What are the browser(s) and version(s) where you see this issue?

/usr/bin/firefox --version

-->

Mozilla Firefox 131.0.2

What are the browser driver(s) and version(s) where you see this issue?

/snap/bin/geckodriver --version

-->

geckodriver 0.35.0 ( 2024-10-08)

The source code of this program is available from
testing/geckodriver in https://hg.mozilla.org/mozilla-central.

This program is subject to the terms of the Mozilla Public License 2.0.
You can obtain a copy of the license at https://mozilla.org/MPL/2.0/.

Are you using Selenium Grid?

No response

Copy link

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


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@Delta456
Copy link
Contributor

I can't reproduce this on my Mac machine with my binary location. The scripts works correctly for me.

from selenium.webdriver import FirefoxOptions
from selenium import webdriver
import selenium.webdriver.firefox.service as FirefoxService

options = FirefoxOptions()

# which firefox
# /usr/bin/firefox
options.binary_location = "/Applications/Firefox.app/Contents/MacOS/firefox"

# which geckodriver
# /snap/bin/geckodriver
firefoxdriver_bin = "/Users/user/Downloads/geckodriver" 
service = FirefoxService.Service(executable_path=firefoxdriver_bin)

driver = webdriver.Firefox(service=service, options=options)
driver.get("https://pythonbasics.org")

@VietND96
Copy link
Member

Execute those path of firefox and geckodriver with --version. Can it return version info properly?

@Davide-Leo
Copy link
Author

The version I have is the one I provided under the section

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants