SeleniumHQ/selenium · critical · NoSuchDriverException
Unable to obtain driver for {browser}
Error message
Unable to obtain driver for {browser} What it means
`DriverFinder._binary_paths` wraps ANY exception during driver/browser resolution and re-raises it as `NoSuchDriverException(f"Unable to obtain driver for {browser}")` with the original exception chained as `__cause__`. This is the user-facing catch-all: the original `ValueError` (bad path), Selenium Manager failure, or network error is preserved on `.cause__`. Browser is the `browserName` capability from options.
Source
Thrown at py/selenium/webdriver/common/driver_finder.py:78
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:
args.append("--browser-path")
args.append(str(binary_location))
proxy = self._options.proxy
if proxy and (proxy.http_proxy or proxy.ssl_proxy):
args.append("--proxy")
value = proxy.ssl_proxy if proxy.ssl_proxy else proxy.http_proxyView on GitHub (pinned to aa36b38e69)
Solutions
- Inspect `e.__cause__` and `e.__context__` for the real underlying failure.
- Ensure network access for Selenium Manager to download the driver, or supply a local driver via Service.
- Verify `options` carries a valid `browserName` (chrome/firefox/edge/safari).
- Clear cache (`rm -rf ~/.cache/selenium`) and retry to rule out a corrupt cached resolution.
- Pin browser/driver versions in options for deterministic resolution.
Example fix
// before
driver = webdriver.Chrome() # NoSuchDriverException: Unable to obtain driver for chrome
// after
try:
driver = webdriver.Chrome()
except NoSuchDriverException as e:
print("root cause:", e.__cause__)
# then either supply a local driver or fix the environment Defensive patterns
Strategy: try-catch
Validate before calling
from pathlib import Path
# pre-flight: ensure driver or browser is resolvable
if not Path(Service().path or "").is_file():
print("no explicit driver; Selenium Manager will resolve one - ensure network access") Type guard
def has_valid_browsername(options) -> bool:
return bool(options.capabilities.get("browserName")) Try / catch
from selenium.common.exceptions import NoSuchDriverException
try:
driver = webdriver.Chrome(options=options)
except NoSuchDriverException as e:
print("root cause:", e.__cause__)
if "path is not a valid file" in str(e.__cause__):
driver = webdriver.Chrome() # let Selenium Manager resolve
else:
raise Prevention
- Always inspect e.__cause__ / e.__context__ to find the real failure.
- Ensure network access for Selenium Manager downloads in fresh environments.
- Verify options.capabilities["browserName"] is set and valid.
- Clear ~/.cache/selenium to rule out stale resolutions.
When it happens
Trigger: Any failure in `_binary_paths`: invalid explicit service.path, Selenium Manager producing non-file paths, Selenium Manager crashing/returning an error, a missing `browserName` capability (KeyError), or network failure reaching the driver download.
Common situations: First run in CI with no driver and no network. Wrong browser name. Selenium Manager binary missing or incompatible. Stale cache. All of errors 136-138 surface through this wrapper.
Related errors
- The driver path is not a valid file: {output['driver_path']}
- The browser path is not a valid file: {output['browser_path'
- The path is not a valid file: {path}
- Unable to obtain browser driver. For more informatio
- Unable to obtain Selenium Manager at ${filePath}
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/5dadb0707e15ae95.
Report an issue: GitHub.