SeleniumHQ/selenium · error · Error::UnsupportedOperationError
you may only select all options of a multi-select
Error message
you may only select all options of a multi-select
What it means
Support::Select#select_all iterates every option and selects it, which is only meaningful for a <select multiple>. On a single-select calling select_all is a logic error, so the binding raises Error::UnsupportedOperationError before touching the DOM.
Source
Thrown at rb/lib/selenium/webdriver/support/select.rb:144
when :text
deselect_by_text what
when :value
deselect_by_value what
when :index
deselect_by_index what
else
raise ArgumentError, "can't deselect options by #{how.inspect}"
end
end
#
# Select all unselected options. Only valid if the element supports multiple selections.
#
# @raise [Error::UnsupportedOperationError] if the element does not support multiple selections.
#
def select_all
raise Error::UnsupportedOperationError, 'you may only select all options of a multi-select' unless multiple?
options.each { |e| select_option e }
end
#
# Deselect all selected options. Only valid if the element supports multiple selections.
#
# @raise [Error::UnsupportedOperationError] if the element does not support multiple selections.
#
def deselect_all
raise Error::UnsupportedOperationError, 'you may only deselect all options of a multi-select' unless multiple?
options.each { |e| deselect_option e }
end
private
View on GitHub (pinned to aa36b38e69)
Solutions
- Guard with select.multiple? before calling select_all.
- Confirm the <select> has the 'multiple' attribute in HTML.
- For single-selects, use select_by(:text/:index/:value) instead of select_all.
Example fix
# before select.select_all # after if select.multiple? select.select_all else select.select_by(:index, 0) end
Defensive patterns
Strategy: validation
Validate before calling
select.select_all if select.multiple?
Type guard
def multi_select?(select) select.multiple? end
Try / catch
begin select.select_all rescue Selenium::WebDriver::Error::UnsupportedOperationError select.select_by(:index, 0) # fallback for single-select end
Prevention
- Always guard select_all/deselect_all with multiple?.
- Confirm the <select> has the multiple attribute.
- Use select_by for single-selects instead of select_all.
When it happens
Trigger: Calling select.select_all when the underlying <select> does not have the 'multiple' attribute (i.e. select.multiple? is false).
Common situations: A generic helper that always calls select_all regardless of select type; the page changed a multi-select to a single-select; locator matched the wrong select element.
Related errors
- you may only deselect all options of a multi-select
- you may only deselect option of a multi-select
- Full Page Screenshots are not supported for #{inspect}
- unexpected tag name #{tag_name.inspect}
- no options are selected
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/64f53ba455234baf.
Report an issue: GitHub.