Skip to content
Latchkey

Selenium "InvalidArgumentException: binary is not a Firefox executable" in CI

When you set an explicit browser binary location, the driver validates it at session start. If the path is missing, not executable, or not the browser it expects, Selenium raises InvalidArgumentException naming the bad binary.

What this error means

Session creation fails with "selenium.common.exceptions.InvalidArgumentException: Message: binary is not a Firefox executable" (or the Chrome equivalent) after a binary_location is set in options.

selenium
selenium.common.exceptions.InvalidArgumentException: Message: binary is not a Firefox executable
  (Session info: ...)
  options.binary_location = "/usr/bin/firefox"  # not present on this runner

Common causes

The binary path does not exist on the runner

A binary_location hard-coded for a developer machine or a different image does not resolve on the CI runner, so validation fails.

The path points at a wrapper or the wrong browser

The configured path is a shell wrapper or a different browser, so the driver rejects it as not the expected executable.

How to fix it

Point binary_location at the installed browser

  1. Find the real path with which firefox or which google-chrome on the runner.
  2. Set options.binary_location to that path, or omit it to let the driver auto-detect.
  3. Re-run so the driver validates a real executable.
python
from selenium.webdriver.firefox.options import Options
opts = Options()
opts.binary_location = "/snap/bin/firefox"  # match the runner

Install the browser in a setup step

Provision the browser explicitly so a known path exists, rather than relying on whatever the image ships.

.github/workflows/ci.yml
- uses: browser-actions/setup-firefox@v1
- run: which firefox

How to prevent it

  • Detect the browser path on the runner instead of hard-coding it.
  • Install the browser in a dedicated setup step.
  • Prefer auto-detection over an explicit binary_location where possible.

Frequently asked questions

What causes ""binary is not a Firefox executable""?
A binary_location hard-coded for a developer machine or a different image does not resolve on the CI runner, so validation fails.
How do I fix "binary is not a Firefox executable"?
Point binary_location at the installed browser

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card