{"record":{"id":"c36c0caafe65e447","repo":"SeleniumHQ/selenium","slug":"binary-location-must-be-a-string-c36c0c","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/wpewebkit/options.py","lineNumber":43,"sourceCode":"\n    def __init__(self) -> None:\n        super().__init__()\n        self._binary_location = \"\"\n\n    @property\n    def binary_location(self) -> str:\n        \"\"\"Return the location of the browser binary or 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 the browser binary to launch.\n\n        Args:\n            value: path to the browser binary\n        \"\"\"\n        if not isinstance(value, str):\n            raise TypeError(self.BINARY_LOCATION_ERROR)\n        self._binary_location = value\n\n    def to_capabilities(self) -> dict:\n        \"\"\"Create a capabilities dictionary with all set options.\"\"\"\n        caps = self._caps\n\n        browser_options = {}\n        if self.binary_location:\n            browser_options[\"binary\"] = self.binary_location\n        if self.arguments:\n            browser_options[\"args\"] = self.arguments\n\n        caps[Options.KEY] = browser_options\n\n        return caps\n\n    @property\n    def default_capabilities(self) -> dict[str, str]:","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/py/selenium/webdriver/wpewebkit/options.py#L25-L61","documentation":"Raised by the binary_location setter on wpewebkit.Options when the assigned value is not a str. The error message comes from the inherited BINARY_LOCATION_ERROR constant ('Binary Location Must be a String') defined in selenium.webdriver.common.options. The getter returns self._binary_location (initialized to empty string ''), and to_capabilities() only includes the binary in capabilities if it is truthy (non-empty).","triggerScenarios":"Assigning options.binary_location = Path('/usr/bin/WPEWebProcess') (a pathlib.Path object) instead of a string; assigning None, an int, or any non-str type; passing a binary path from a variable that was not explicitly converted to str.","commonSituations":"Using pathlib.Path for file paths and forgetting to call str(); passing None as a sentinel for 'default' instead of empty string; reading path from environment or config that returns a non-string type; cross-binding code that passes a Path where str is expected.","solutions":["Convert to str before assignment: options.binary_location = str(path_obj).","Pass a string literal: options.binary_location = '/usr/bin/WPEWebDriver'.","If the path may be None, default to empty string: options.binary_location = path or ''."],"exampleFix":"// before\nfrom pathlib import Path\noptions.binary_location = Path('/usr/bin/WPEWebProcess')\n// after\nfrom pathlib import Path\noptions.binary_location = str(Path('/usr/bin/WPEWebProcess'))","handlingStrategy":"type-guard","validationCode":"path = '/usr/bin/WPEWebDriver'  # or str(some_path_obj)\nif not isinstance(path, str):\n    path = str(path)\noptions.binary_location = path","typeGuard":"def is_valid_binary_location(value) -> bool:\n    return isinstance(value, str)","tryCatchPattern":"null","preventionTips":["Always convert pathlib.Path to str before assigning to binary_location.","Use str() wrapping when the source type is uncertain.","Default to empty string '' for 'use system default', not None."],"tags":["selenium","wpewebkit","options","type-error","binary-location","python"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}