{"record":{"id":"971c25cc02546891","repo":"SeleniumHQ/selenium","slug":"binary-location-must-be-a-string","errorCode":null,"errorMessage":"Binary Location Must be a String","messagePattern":"Binary Location Must be a String","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"py/selenium/webdriver/chromium/options.py","lineNumber":52,"sourceCode":"        self._extensions: list[str] = []\n        self._experimental_options: dict[str, str | int | dict | list[str]] = {}\n        self._debugger_address: str | None = None\n        self._enable_webextensions: bool = False\n\n    @property\n    def binary_location(self) -> str:\n        \"\"\"Returns the location of the binary, otherwise an empty string.\"\"\"\n        return self._binary_location\n\n    @binary_location.setter\n    def binary_location(self, value: str) -> None:\n        \"\"\"Allows you to set where the chromium binary lives.\n\n        Args:\n            value: Path to the Chromium binary.\n        \"\"\"\n        if not isinstance(value, str):\n            raise TypeError(self.BINARY_LOCATION_ERROR)\n        self._binary_location = value\n\n    @property\n    def debugger_address(self) -> str | None:\n        \"\"\"Returns the address of the remote devtools instance.\"\"\"\n        return self._debugger_address\n\n    @debugger_address.setter\n    def debugger_address(self, value: str) -> None:\n        \"\"\"Set the address of the remote devtools instance for active wait connection.\n\n        Args:\n            value: Address of remote devtools instance if any (hostname[:port]).\n        \"\"\"\n        if not isinstance(value, str):\n            raise TypeError(\"Debugger Address must be a string\")\n        self._debugger_address = value\n","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/py/selenium/webdriver/chromium/options.py#L34-L70","documentation":"The `binary_location` setter on `chromium.options.ChromiumOptions` enforces that the value is a `str`. It stores the path to the browser executable (Chrome/Chromium/Edge). Any non-string (Path object, None, int) is rejected with `BINARY_LOCATION_ERROR` (\"Binary Location Must be a String\"). Note the inconsistent Title Case of this message versus other validators.","triggerScenarios":"`options.binary_location = pathlib.Path(\"/usr/bin/chromium\")` (a pathlib.Path, not a str), `options.binary_location = None`, `options.binary_location = 123`. Passing a Path object is the most common hit because modern Python code tends to use pathlib.","commonSituations":"Using `pathlib.Path` instead of a plain string. Copying a snippet that assigns `None` to disable. Cross-binding habits (other Selenium bindings accept Path-like objects).","solutions":["Convert the Path to a string: `options.binary_location = str(pathlib.Path(\"/usr/bin/chromium\"))`.","Pass a raw string: `options.binary_location = \"/usr/bin/chromium\"`.","Leave it unset to let Selenium Manager locate the browser automatically."],"exampleFix":"// before\nimport pathlib\noptions.binary_location = pathlib.Path(\"/usr/bin/chromium\")  # TypeError\n// after\noptions.binary_location = str(pathlib.Path(\"/usr/bin/chromium\"))","handlingStrategy":"validation","validationCode":"import pathlib\np = pathlib.Path(\"/usr/bin/chromium\")\nbinary = str(p) if not isinstance(p, str) else p\nassert isinstance(binary, str), \"binary_location must be str\"\noptions.binary_location = binary","typeGuard":"def is_binary_location(value) -> bool:\n    return isinstance(value, str)","tryCatchPattern":"try:\n    options.binary_location = path\nexcept TypeError:\n    options.binary_location = str(path)","preventionTips":["Coerce pathlib.Path to str before assigning to binary_location.","Leave binary_location unset to use Selenium Manager auto-detection.","Add a unit test that assigns a Path to catch regressions early."],"tags":["options","binary-location","type-check","chromium"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}