SeleniumHQ/selenium · error · ValueError
The driver path is not a valid file: {output['driver_path']}
Error message
The driver path is not a valid file: {output['driver_path']} What it means
After Selenium Manager resolves the driver, `DriverFinder` verifies the returned `driver_path` is a real file. If Selenium Manager reported a path that is not a file (corrupt install, interrupted download, manager bug), it raises `ValueError`, wrapped into `NoSuchDriverException`. This indicates Selenium Manager itself produced an unusable result.
Source
Thrown at py/selenium/webdriver/common/driver_finder.py:71
if self._paths["driver_path"]:
return self._paths
browser = self._options.capabilities["browserName"]
try:
path = self._service.path
if path:
logger.debug(
"Skipping Selenium Manager; path to %s driver specified in Service class: %s", browser, path
)
if not Path(path).is_file():
raise ValueError(f"The path is not a valid file: {path}")
self._paths["driver_path"] = path
else:
output = SeleniumManager().binary_paths(self._to_args())
if Path(output["driver_path"]).is_file():
self._paths["driver_path"] = output["driver_path"]
else:
raise ValueError(f"The driver path is not a valid file: {output['driver_path']}")
if Path(output["browser_path"]).is_file():
self._paths["browser_path"] = output["browser_path"]
else:
raise ValueError(f"The browser path is not a valid file: {output['browser_path']}")
except Exception as err:
msg = f"Unable to obtain driver for {browser}"
raise NoSuchDriverException(msg) from err
return self._paths
def _to_args(self) -> list:
args = ["--browser", self._options.capabilities["browserName"]]
if self._options.browser_version:
args.append("--browser-version")
args.append(str(self._options.browser_version))
binary_location = getattr(self._options, "binary_location", None)
if binary_location:View on GitHub (pinned to aa36b38e69)
Solutions
- Clear the Selenium Manager cache: `rm -rf ~/.cache/selenium` and retry.
- Pin a known-good browser version in options to get a stable driver match.
- Provide the driver explicitly via `Service(executable_path=...)` with a verified file.
- Check the chained cause on the NoSuchDriverException for Selenium Manager stderr output.
Example fix
// before # Selenium Manager returns a non-file driver_path -> NoSuchDriverException // after rm -rf ~/.cache/selenium # clear cache, then re-run driver = webdriver.Chrome() # manager re-downloads cleanly
Defensive patterns
Strategy: retry
Validate before calling
from selenium.webdriver.common.selenium_manager import SeleniumManager out = SeleniumManager().binary_paths(["--browser", "chrome"]) from pathlib import Path assert Path(out["driver_path"]).is_file(), "manager returned an invalid driver_path"
Type guard
from pathlib import Path
def manager_driver_path_valid(out: dict) -> bool:
return Path(out.get("driver_path", "")).is_file() Try / catch
from selenium.common.exceptions import NoSuchDriverException
import shutil
try:
driver = webdriver.Chrome()
except NoSuchDriverException as e:
shutil.rmtree("~/.cache/selenium", ignore_errors=True) # clear cache
driver = webdriver.Chrome() # retry once Prevention
- Clear ~/.cache/selenium on corrupt-download symptoms.
- Pin a stable browser version in options for deterministic driver matches.
- Inspect the chained cause for Selenium Manager stderr.
When it happens
Trigger: Selenium Manager output JSON references a driver_path that doesn't exist on disk. Corrupt Selenium Manager cache. A pinned browser-version that has no matching driver. Network failure during driver download leaving a partial/absent binary.
Common situations: First run in a fresh container where the manager download was interrupted. Corrupted cache under `~/.cache/selenium`. Corporate proxy truncating the download. Manager version mismatch.
Related errors
- The browser path is not a valid file: {output['browser_path'
- Unable to obtain driver for {browser}
- The path is not a valid file: {path}
- Cache behavior must be either "${CacheBehavior.DEFAULT}" or
- Contexts must be an array of non-empty strings
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/db2fcce866711cba.
Report an issue: GitHub.