Skip to content
Latchkey

Selenium "'chromedriver' executable needs to be in PATH" in CI

On Selenium versions or code paths that do not invoke Selenium Manager, the binding looks up chromedriver on PATH. If no driver was installed and no Service path is set, it raises WebDriverException with this message.

What this error means

Driver creation fails with "selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH" even though Chrome is present on the runner.

selenium
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs
to be in PATH. Please see https://chromedriver.chromium.org/home

Common causes

No ChromeDriver installed on the runner

The job installed Chrome but never installed a matching ChromeDriver, and the code does not let Selenium Manager fetch one.

A custom Service path that does not point at the binary

An explicit Service(executable_path=...) is set to a path that does not exist on the runner, so the binding falls back to a PATH lookup that fails.

How to fix it

Let Selenium Manager resolve the driver

  1. Upgrade Selenium to 4.6 or newer.
  2. Construct the driver without an executable path so Selenium Manager downloads chromedriver.
  3. Re-run; the driver is fetched to a managed cache, not PATH.
python
from selenium import webdriver
driver = webdriver.Chrome()  # Selenium Manager resolves chromedriver

Or install chromedriver and add it to PATH

When you manage the driver, install it in a setup step and ensure that directory is on PATH for later steps.

.github/workflows/ci.yml
- uses: nanasess/setup-chromedriver@v2
- run: echo "chromedriver on PATH" && chromedriver --version

How to prevent it

  • Prefer Selenium Manager so the driver does not have to be on PATH.
  • If pinning a Service path, verify the binary exists on the runner first.
  • Install the driver in a dedicated setup step before the test step.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →