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.common.exceptions.InvalidArgumentException: Message: binary is not a Firefox executable
(Session info: ...)
options.binary_location = "/usr/bin/firefox" # not present on this runnerCommon 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
- Find the real path with
which firefoxorwhich google-chromeon the runner. - Set options.binary_location to that path, or omit it to let the driver auto-detect.
- Re-run so the driver validates a real executable.
from selenium.webdriver.firefox.options import Options
opts = Options()
opts.binary_location = "/snap/bin/firefox" # match the runnerInstall the browser in a setup step
Provision the browser explicitly so a known path exists, rather than relying on whatever the image ships.
- uses: browser-actions/setup-firefox@v1
- run: which firefoxHow 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.