{"record":{"id":"d0d81362fd93877b","repo":"SeleniumHQ/selenium","slug":"element-scroll-behavior-out-of-range","errorCode":null,"errorMessage":"Element Scroll Behavior out of range.","messagePattern":"Element Scroll Behavior out of range\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py/selenium/webdriver/ie/options.py","lineNumber":83,"sourceCode":"        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\"\n    FORCE_SHELL_WINDOWS_API = \"ie.forceShellWindowsApi\"\n    FULL_PAGE_SCREENSHOT = \"ie.enableFullPageScreenshot\"\n    IGNORE_PROTECTED_MODE_SETTINGS = \"ignoreProtectedModeSettings\"\n    IGNORE_ZOOM_LEVEL = \"ignoreZoomSetting\"\n    INITIAL_BROWSER_URL = \"initialBrowserUrl\"\n    NATIVE_EVENTS = \"nativeEvents\"","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/py/selenium/webdriver/ie/options.py#L65-L101","documentation":"Raised as ValueError specifically when setting elementScrollBehavior to a value that is not ElementScrollBehavior.TOP (0) or ElementScrollBehavior.BOTTOM (1). This is a range/enum validation layered on top of the type check — even a correct int type will be rejected if it is outside the two valid enum values.","triggerScenarios":"Assigning options.element_scroll_behavior = 2, options.element_scroll_behavior = -1, or any int other than 0 or 1 triggers the ValueError. The type check passes (it is an int) but the range check fails.","commonSituations":"Developers who don't know about the ElementScrollBehavior enum and guess integer values. Copying values from documentation that uses a different numbering scheme.","solutions":["Use the ElementScrollBehavior enum: from selenium.webdriver.ie.options import ElementScrollBehavior; options.element_scroll_behavior = ElementScrollBehavior.TOP","If using raw ints, restrict to 0 (TOP) or 1 (BOTTOM) only","Check the enum definition to confirm valid values before assignment"],"exampleFix":"// before\noptions.element_scroll_behavior = 2\n\n// after\nfrom selenium.webdriver.ie.options import ElementScrollBehavior\noptions.element_scroll_behavior = ElementScrollBehavior.TOP","handlingStrategy":"validation","validationCode":"from selenium.webdriver.ie.options import ElementScrollBehavior\nvalid = [ElementScrollBehavior.TOP, ElementScrollBehavior.BOTTOM]\nif value not in valid:\n    raise ValueError(f'element_scroll_behavior must be one of {valid}')\noptions.element_scroll_behavior = value","typeGuard":"from selenium.webdriver.ie.options import ElementScrollBehavior\ndef is_valid_scroll_behavior(v) -> bool:\n    return v in (ElementScrollBehavior.TOP, ElementScrollBehavior.BOTTOM)","tryCatchPattern":"try:\n    options.element_scroll_behavior = value\nexcept ValueError:\n    options.element_scroll_behavior = ElementScrollBehavior.TOP","preventionTips":["Always use the ElementScrollBehavior enum instead of raw integers","Confirm valid values from the enum definition before assignment","Restrict raw int values to 0 or 1"],"tags":["ie","options","enum-validation","scroll-behavior","value-error"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}