SeleniumHQ/selenium · error · NotImplementedError

You may not select a disabled option

Error message

You may not select a disabled option

What it means

The internal `_set_selected()` helper clicks an option to select it, but only if the option is enabled. If `option.is_enabled()` is False it raises `NotImplementedError('You may not select a disabled option')`, surfacing a disabled-option attempt from any of the select_by_* methods.

Source

Thrown at py/selenium/webdriver/support/select.py:228

            text: The visible text to match against
        """
        if not self.is_multiple:
            raise NotImplementedError("You may only deselect options of a multi-select")
        matched = False
        xpath = f".//option[normalize-space(.) = {self._escape_string(text)}]"
        opts = self._el.find_elements(By.XPATH, xpath)
        for opt in opts:
            if not self._has_css_property_and_visible(opt):
                raise NoSuchElementException(f"Invisible option with text: {text}")
            self._unset_selected(opt)
            matched = True
        if not matched:
            raise NoSuchElementException(f"Could not locate element with visible text: {text}")

    def _set_selected(self, option) -> None:
        if not option.is_selected():
            if not option.is_enabled():
                raise NotImplementedError("You may not select a disabled option")
            option.click()

    def _unset_selected(self, option) -> None:
        if option.is_selected():
            option.click()

    def _escape_string(self, value: str) -> str:
        if '"' in value and "'" in value:
            substrings = value.split('"')
            result = ["concat("]
            for substring in substrings:
                result.append(f'"{substring}"')
                result.append(", '\"', ")
            result = result[0:-1]
            if value.endswith('"'):
                result.append(", '\"'")
            return "".join(result) + ")"

View on GitHub (pinned to aa36b38e69)

Solutions

  1. Filter to enabled options before selecting: ensure `option.is_enabled()`
  2. Choose a different, enabled option matching your intent
  3. Remove the disabled attribute via JS only if testing requires it: `driver.execute_script('arguments[0].removeAttribute("disabled")', opt)`
  4. Catch NotImplementedError and pick an alternate option

Example fix

// before
select.select_by_value("disabled_opt")

// after
opt = next((o for o in select.options if o.get_attribute("value") == "enabled_opt"), None)
if opt and opt.is_enabled():
    select.select_by_value("enabled_opt")
Defensive patterns

Strategy: validation

Validate before calling

opt = next((o for o in select.options if o.get_attribute("value") == value), None)
if opt and opt.is_enabled():
    select.select_by_value(value)

Type guard

def option_enabled(select_obj, value) -> bool:
    for o in select_obj.options:
        if o.get_attribute("value") == value:
            return o.is_enabled()
    return False

Try / catch

try:
    select.select_by_value(value)
except NotImplementedError:
    # option is disabled — choose an enabled alternative
    pass

Prevention

When it happens

Trigger: Any select method (`select_by_value/index/visible_text`) targeting an `<option disabled>` that is not already selected. `_set_selected` sees the option isn't selected and isn't enabled, so it raises before clicking.

Common situations: Selecting a disabled/placeholder option; the option becomes disabled under certain conditions (form state); test data points at an option the UI intentionally disables; race where an option is disabled between location and click.

Related errors


AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14). Data as JSON: /api/errors/e3bc4e53b930175b. Report an issue: GitHub.