{"record":{"id":"e3a57ddcbd4570ac","repo":"SeleniumHQ/selenium","slug":"self-name-should-be-of-type-self-expected-type-e3a57d","errorCode":null,"errorMessage":"{self.name} should be of type {self.expected_type.__name__}","messagePattern":"(.+?) should be of type (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py/selenium/webdriver/ie/options.py","lineNumber":77,"sourceCode":"\n    When an attribute assignment happens:\n\n    Example:\n        `self.browser_attach_timeout` = 30\n        `__set__` method sets/updates the value of the key `browserAttachTimeout` in `_options`\n        dictionary in `Options` class.\n    \"\"\"\n\n    def __init__(self, name, expected_type):\n        self.name = name\n        self.expected_type = expected_type\n\n    def __get__(self, obj, cls):\n        return obj._options.get(self.name)\n\n    def __set__(self, obj, value) -> None:\n        if not isinstance(value, self.expected_type):\n            raise ValueError(f\"{self.name} should be of type {self.expected_type.__name__}\")\n\n        if self.name == \"elementScrollBehavior\" and value not in [\n            ElementScrollBehavior.TOP,\n            ElementScrollBehavior.BOTTOM,\n        ]:\n            raise ValueError(\"Element Scroll Behavior out of range.\")\n        obj._options[self.name] = value\n\n\nclass Options(ArgOptions):\n    KEY = \"se:ieOptions\"\n    SWITCHES = \"ie.browserCommandLineSwitches\"\n\n    BROWSER_ATTACH_TIMEOUT = \"browserAttachTimeout\"\n    ELEMENT_SCROLL_BEHAVIOR = \"elementScrollBehavior\"\n    ENSURE_CLEAN_SESSION = \"ie.ensureCleanSession\"\n    FILE_UPLOAD_DIALOG_TIMEOUT = \"ie.fileUploadDialogTimeout\"\n    FORCE_CREATE_PROCESS_API = \"ie.forceCreateProcessApi\"","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/py/selenium/webdriver/ie/options.py#L59-L95","documentation":"Raised as ValueError by the _IeOptionsDescriptor.__set__ descriptor when the assigned value does not match the expected_type declared for that option. Each IE option (browser_attach_timeout expects int, ensure_clean_session expects bool, etc.) is backed by a descriptor that validates type on assignment, preventing type mismatches from reaching the IE driver where they would cause confusing protocol errors.","triggerScenarios":"Assigning options.browser_attach_timeout = '30' (str instead of int), options.ensure_clean_session = 1 (int instead of bool), or options.initial_browser_url = 123 (int instead of str) triggers the ValueError.","commonSituations":"Config values deserialized from JSON/YAML that arrive as strings. Integer 0/1 used for boolean options. Env var values that are always strings.","solutions":["Convert the value to the expected type before assignment (int(value), bool(value), str(value))","Check the descriptor declaration in ie/options.py to see the expected_type for each option","Use native Python literals of the correct type directly"],"exampleFix":"// before\noptions.browser_attach_timeout = '30'\n\n// after\noptions.browser_attach_timeout = 30","handlingStrategy":"type-guard","validationCode":"value = '30'\noptions.browser_attach_timeout = int(value)  # convert to expected type before assignment","typeGuard":"def matches_expected_type(value, expected_type) -> bool:\n    return isinstance(value, expected_type)","tryCatchPattern":"try:\n    options.browser_attach_timeout = value\nexcept ValueError:\n    options.browser_attach_timeout = int(value)","preventionTips":["Check the descriptor declaration in ie/options.py for each option's expected_type","Convert config values to the correct Python type before assignment","Use native Python literals of the correct type"],"tags":["ie","type-validation","options","descriptor","value-error"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}