SeleniumHQ/selenium · error · ValueError
Element Scroll Behavior out of range.
Error message
Element Scroll Behavior out of range.
What it means
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.
Source
Thrown at py/selenium/webdriver/ie/options.py:83
dictionary in `Options` class.
"""
def __init__(self, name, expected_type):
self.name = name
self.expected_type = expected_type
def __get__(self, obj, cls):
return obj._options.get(self.name)
def __set__(self, obj, value) -> None:
if not isinstance(value, self.expected_type):
raise ValueError(f"{self.name} should be of type {self.expected_type.__name__}")
if self.name == "elementScrollBehavior" and value not in [
ElementScrollBehavior.TOP,
ElementScrollBehavior.BOTTOM,
]:
raise ValueError("Element Scroll Behavior out of range.")
obj._options[self.name] = value
class Options(ArgOptions):
KEY = "se:ieOptions"
SWITCHES = "ie.browserCommandLineSwitches"
BROWSER_ATTACH_TIMEOUT = "browserAttachTimeout"
ELEMENT_SCROLL_BEHAVIOR = "elementScrollBehavior"
ENSURE_CLEAN_SESSION = "ie.ensureCleanSession"
FILE_UPLOAD_DIALOG_TIMEOUT = "ie.fileUploadDialogTimeout"
FORCE_CREATE_PROCESS_API = "ie.forceCreateProcessApi"
FORCE_SHELL_WINDOWS_API = "ie.forceShellWindowsApi"
FULL_PAGE_SCREENSHOT = "ie.enableFullPageScreenshot"
IGNORE_PROTECTED_MODE_SETTINGS = "ignoreProtectedModeSettings"
IGNORE_ZOOM_LEVEL = "ignoreZoomSetting"
INITIAL_BROWSER_URL = "initialBrowserUrl"
NATIVE_EVENTS = "nativeEvents"View on GitHub (pinned to aa36b38e69)
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
Example fix
// before options.element_scroll_behavior = 2 // after from selenium.webdriver.ie.options import ElementScrollBehavior options.element_scroll_behavior = ElementScrollBehavior.TOP
Defensive patterns
Strategy: validation
Validate before calling
from selenium.webdriver.ie.options import ElementScrollBehavior
valid = [ElementScrollBehavior.TOP, ElementScrollBehavior.BOTTOM]
if value not in valid:
raise ValueError(f'element_scroll_behavior must be one of {valid}')
options.element_scroll_behavior = value Type guard
from selenium.webdriver.ie.options import ElementScrollBehavior
def is_valid_scroll_behavior(v) -> bool:
return v in (ElementScrollBehavior.TOP, ElementScrollBehavior.BOTTOM) Try / catch
try:
options.element_scroll_behavior = value
except ValueError:
options.element_scroll_behavior = ElementScrollBehavior.TOP Prevention
- 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
When it happens
Trigger: 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.
Common situations: Developers who don't know about the ElementScrollBehavior enum and guess integer values. Copying values from documentation that uses a different numbering scheme.
Related errors
- {self.name} should be of type {self.expected_type.__name__}
- Cache behavior must be either "${CacheBehavior.DEFAULT}" or
- Select element doesn't contain any option element
- Binary Location Must be a String
- Debugger Address must be a string
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/d0d81362fd93877b.
Report an issue: GitHub.