{"record":{"id":"cde1ce6186e21c24","repo":"SeleniumHQ/selenium","slug":"browsername-not-specified-in-session-capabilities","errorCode":null,"errorMessage":"browserName not specified in session capabilities","messagePattern":"browserName not specified in session capabilities","errorType":"exception","errorClass":"KeyError","httpStatus":null,"severity":"warning","filePath":"py/selenium/webdriver/remote/webdriver.py","lineNumber":362,"sourceCode":"        if not isinstance(self.file_detector, file_detector_class):\n            last_detector = self.file_detector\n            self.file_detector = file_detector_class(*args, **kwargs)\n        try:\n            yield\n        finally:\n            if last_detector:\n                self.file_detector = last_detector\n\n    @property\n    def mobile(self) -> Mobile:\n        return self._mobile\n\n    @property\n    def name(self) -> str:\n        \"\"\"Returns the name of the underlying browser for this instance.\"\"\"\n        if \"browserName\" in self.caps:\n            return self.caps[\"browserName\"]\n        raise KeyError(\"browserName not specified in session capabilities\")\n\n    def start_client(self) -> None:\n        \"\"\"Called before starting a new session.\n\n        This method may be overridden to define custom startup behavior.\n        \"\"\"\n        pass\n\n    def stop_client(self) -> None:\n        \"\"\"Called after executing a quit command.\n\n        This method may be overridden to define custom shutdown\n        behavior.\n        \"\"\"\n        pass\n\n    def start_session(self, capabilities: dict) -> None:\n        \"\"\"Creates a new session with the desired capabilities.","sourceCodeStart":344,"sourceCodeEnd":380,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/py/selenium/webdriver/remote/webdriver.py#L344-L380","documentation":"Raised by the `name` property when `self.caps` (the session capabilities dict) has no `'browserName'` key. The property is meant to return the browser name, so an absent key is a hard failure surfaced as KeyError. Typically this indicates the session was created against a backend that did not report a browserName in capabilities.","triggerScenarios":"Reading driver.name on a session that connected to a Selenium Grid routing to an opaque/driverless backend, a custom Appium/remote endpoint, or a misconfigured node that omitted browserName from the returned caps.","commonSituations":"Grid nodes with incomplete capability configs; drivers created with hand-built capabilities that omit browserName; older remote ends or cloud providers that return sparse caps.","solutions":["Ensure the remote/Grid node advertises browserName in session capabilities.","Provide browserName in the Options you pass (e.g. opts.browser_name / set via the browser-specific Options).","Don't rely on driver.name when the backend is not a standard browser; read caps.get('browserName') defensively instead."],"exampleFix":"# before\nname = driver.name  # KeyError if browserName absent\n\n# after\nname = driver.caps.get('browserName', 'unknown')","handlingStrategy":"validation","validationCode":"name = driver.caps.get('browserName')\nif name is None:\n    # backend didn't report browserName; read caps defensively","typeGuard":null,"tryCatchPattern":"try:\n    name = driver.name\nexcept KeyError:\n    name = driver.caps.get('browserName', 'unknown')","preventionTips":["Don't assume browserName is present for non-standard remotes; use caps.get.","Validate the remote node's capabilities response when integrating a new Grid."],"tags":["capabilities","validation","grid","webdriver"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}