{"record":{"id":"687e78de5ab659f2","repo":"SeleniumHQ/selenium","slug":"service-path-cannot-be-none","errorCode":null,"errorMessage":"Service path cannot be None.","messagePattern":"Service path cannot be None\\.","errorType":"exception","errorClass":"WebDriverException","httpStatus":null,"severity":"critical","filePath":"py/selenium/webdriver/common/service.py","lineNumber":107,"sourceCode":"        raise NotImplementedError(\"This method needs to be implemented in a sub class\")\n\n    @property\n    def path(self) -> str:\n        return self._path or \"\"\n\n    @path.setter\n    def path(self, value: str) -> None:\n        self._path = str(value)\n\n    def start(self) -> None:\n        \"\"\"Starts the Service.\n\n        Raises:\n            WebDriverException: Raised either when it can't start the service\n                or when it can't connect to the service\n        \"\"\"\n        if self._path is None:\n            raise WebDriverException(\"Service path cannot be None.\")\n        self._start_process(self._path)\n\n        count = 0\n        try:\n            while True:\n                self.assert_process_still_running()\n                if self.is_connectable():\n                    break\n                # sleep increasing: 0.01, 0.06, 0.11, 0.16, 0.21, 0.26, 0.31, 0.36, 0.41, 0.46, 0.5\n                sleep(min(0.01 + 0.05 * count, 0.5))\n                count += 1\n                if count == 70:\n                    raise WebDriverException(f\"Can not connect to the Service {self._path}\")\n        except BaseException:\n            try:\n                self.stop()\n            except Exception:\n                logger.error(\"Error stopping service after a failed start.\", exc_info=True)","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/py/selenium/webdriver/common/service.py#L89-L125","documentation":"Raised by Service.start() at the very first line if self._path is None. The _path is computed in __init__ as 'env_path() or executable_path', so it is None only when no driver_path_env_key env var is set AND no executable_path was passed to the constructor. This guard fires before any process is launched.","triggerScenarios":"Constructing a browser-specific Service with executable_path=None (the default) while the corresponding driver env var (e.g. SE_CHROMEDRIVER, SE_GECKODRIVER, SE_EDGEDRIVER) is unset, and then calling .start(). This typically happens only when Selenium Manager is also unavailable to supply the path automatically.","commonSituations":"Disabling Selenium Manager or using a very old selenium version, explicitly passing executable_path=None, or a misconfigured CI where the expected env var is empty rather than absent. Also seen when someone passes executable_path as a variable that evaluated to None.","solutions":["Pass an explicit driver path: Service(executable_path='/path/to/chromedriver').","Set the driver env var for your browser, e.g. export SE_GECKODRIVER=/usr/bin/geckodriver.","Let Selenium Manager resolve the driver automatically by upgrading selenium and not overriding executable_path.","Verify the variable you pass to executable_path is not None before constructing the Service."],"exampleFix":"# before\nservice = Service(executable_path=None)  # or just Service()\nservice.start()  # -> Service path cannot be None.\n\n# after\nfrom selenium.webdriver.chrome.service import Service\nservice = Service(executable_path='/usr/local/bin/chromedriver')","handlingStrategy":"validation","validationCode":"from selenium.webdriver.chrome.service import Service\npath = os.getenv('SE_CHROMEDRIVER') or '/usr/local/bin/chromedriver'\nassert path and Path(path).is_file(), 'No driver path; set SE_CHROMEDRIVER or pass executable_path'\nservice = Service(executable_path=path)","typeGuard":"def is_valid_driver_path(p) -> bool:\n    return isinstance(p, str) and p and Path(p).is_file()","tryCatchPattern":"from selenium.common.exceptions import WebDriverException\ntry:\n    service.start()\nexcept WebDriverException as e:\n    if 'Service path cannot be None' in str(e):\n        service.path = '/usr/local/bin/chromedriver'\n        service.start()","preventionTips":["Always pass an explicit executable_path in environments without Selenium Manager.","Set the browser-specific driver env var (SE_CHROMEDRIVER etc.) in CI.","Validate the path variable is not None before constructing the Service."],"tags":["service","configuration","driver-path","startup"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}