{"record":{"id":"5dadb0707e15ae95","repo":"SeleniumHQ/selenium","slug":"unable-to-obtain-driver-for-browser","errorCode":null,"errorMessage":"Unable to obtain driver for {browser}","messagePattern":"Unable to obtain driver for (.+?)","errorType":"exception","errorClass":"NoSuchDriverException","httpStatus":null,"severity":"critical","filePath":"py/selenium/webdriver/common/driver_finder.py","lineNumber":78,"sourceCode":"                logger.debug(\n                    \"Skipping Selenium Manager; path to %s driver specified in Service class: %s\", browser, path\n                )\n                if not Path(path).is_file():\n                    raise ValueError(f\"The path is not a valid file: {path}\")\n                self._paths[\"driver_path\"] = path\n            else:\n                output = SeleniumManager().binary_paths(self._to_args())\n                if Path(output[\"driver_path\"]).is_file():\n                    self._paths[\"driver_path\"] = output[\"driver_path\"]\n                else:\n                    raise ValueError(f\"The driver path is not a valid file: {output['driver_path']}\")\n                if Path(output[\"browser_path\"]).is_file():\n                    self._paths[\"browser_path\"] = output[\"browser_path\"]\n                else:\n                    raise ValueError(f\"The browser path is not a valid file: {output['browser_path']}\")\n        except Exception as err:\n            msg = f\"Unable to obtain driver for {browser}\"\n            raise NoSuchDriverException(msg) from err\n        return self._paths\n\n    def _to_args(self) -> list:\n        args = [\"--browser\", self._options.capabilities[\"browserName\"]]\n\n        if self._options.browser_version:\n            args.append(\"--browser-version\")\n            args.append(str(self._options.browser_version))\n\n        binary_location = getattr(self._options, \"binary_location\", None)\n        if binary_location:\n            args.append(\"--browser-path\")\n            args.append(str(binary_location))\n\n        proxy = self._options.proxy\n        if proxy and (proxy.http_proxy or proxy.ssl_proxy):\n            args.append(\"--proxy\")\n            value = proxy.ssl_proxy if proxy.ssl_proxy else proxy.http_proxy","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/py/selenium/webdriver/common/driver_finder.py#L60-L96","documentation":"`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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\ndriver = webdriver.Chrome()  # NoSuchDriverException: Unable to obtain driver for chrome\n// after\ntry:\n    driver = webdriver.Chrome()\nexcept NoSuchDriverException as e:\n    print(\"root cause:\", e.__cause__)\n    # then either supply a local driver or fix the environment","handlingStrategy":"try-catch","validationCode":"from pathlib import Path\n# pre-flight: ensure driver or browser is resolvable\nif not Path(Service().path or \"\").is_file():\n    print(\"no explicit driver; Selenium Manager will resolve one - ensure network access\")","typeGuard":"def has_valid_browsername(options) -> bool:\n    return bool(options.capabilities.get(\"browserName\"))","tryCatchPattern":"from selenium.common.exceptions import NoSuchDriverException\ntry:\n    driver = webdriver.Chrome(options=options)\nexcept NoSuchDriverException as e:\n    print(\"root cause:\", e.__cause__)\n    if \"path is not a valid file\" in str(e.__cause__):\n        driver = webdriver.Chrome()  # let Selenium Manager resolve\n    else:\n        raise","preventionTips":["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."],"tags":["driver-finder","selenium-manager","setup","critical","no-such-driver"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}