SeleniumHQ/selenium · error · NotImplementedError
You may only deselect all options of a multi-select
Error message
You may only deselect all options of a multi-select
What it means
`deselect_all()` clears every option, but only multi-selects support multiple selections. On a single-select it raises `NotImplementedError` because deselect-all is undefined for non-multiple selects (a single select always has exactly one chosen option).
Source
Thrown at py/selenium/webdriver/support/select.py:155
if not self._has_css_property_and_visible(candidate):
raise NoSuchElementException(f"Invisible option with text: {text}")
self._set_selected(candidate)
if not self.is_multiple:
return
matched = True
if not matched:
raise NoSuchElementException(f"Could not locate element with visible text: {text}")
def deselect_all(self) -> None:
"""Clear all selected entries.
This is only valid when the SELECT supports multiple selections.
throws NotImplementedError If the SELECT does not support
multiple selections
"""
if not self.is_multiple:
raise NotImplementedError("You may only deselect all options of a multi-select")
for opt in self.options:
self._unset_selected(opt)
def deselect_by_value(self, value: str) -> None:
"""Deselect all options that have a value matching the argument.
Example:
When given "foo" this would deselect an option like:
`<option value="foo">Bar</option>`
Args:
value: The value to match against
Raises:
NoSuchElementException: If there is no option with specified value in SELECT
"""
if not self.is_multiple:View on GitHub (pinned to aa36b38e69)
Solutions
- Check `select.is_multiple` before calling: `if select.is_multiple: select.deselect_all()`
- For a single-select, 'clear' by selecting a different/blank option instead
- Catch NotImplementedError to handle single-selects gracefully
Example fix
// before
select.deselect_all()
// after
if select.is_multiple:
select.deselect_all()
else:
select.select_by_index(0) # reset to default Defensive patterns
Strategy: validation
Validate before calling
if select.is_multiple:
select.deselect_all() Type guard
def is_multi(select_obj) -> bool:
return bool(select_obj.is_multiple) Prevention
- Check select.is_multiple before deselect_all
- For single-selects, reset by selecting the default option
- Branch generic helpers on is_multiple
When it happens
Trigger: Calling `select.deselect_all()` on a `<select>` without the `multiple` attribute (`is_multiple` is False). The guard `if not self.is_multiple:` fires immediately.
Common situations: Generic helper code that assumes all selects are multi-select; a select that lost its `multiple` attribute after a page change; test reuse across different form types.
Related errors
- You may only deselect options of a multi-select
- Could not locate element with value: {value}
- You may only deselect all options of a multi-select
- You may only deselect options of a multi-select
- Select only works on <select> elements, not on {webelement.t
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/00cd9cc46d25224d.
Report an issue: GitHub.