{"record":{"id":"64f53ba455234baf","repo":"SeleniumHQ/selenium","slug":"you-may-only-select-all-options-of-a-multi-select","errorCode":null,"errorMessage":"you may only select all options of a multi-select","messagePattern":"you may only select all options of a multi-select","errorType":"exception","errorClass":"Error::UnsupportedOperationError","httpStatus":null,"severity":"error","filePath":"rb/lib/selenium/webdriver/support/select.rb","lineNumber":144,"sourceCode":"          when :text\n            deselect_by_text what\n          when :value\n            deselect_by_value what\n          when :index\n            deselect_by_index what\n          else\n            raise ArgumentError, \"can't deselect options by #{how.inspect}\"\n          end\n        end\n\n        #\n        # Select all unselected options. Only valid if the element supports multiple selections.\n        #\n        # @raise [Error::UnsupportedOperationError] if the element does not support multiple selections.\n        #\n\n        def select_all\n          raise Error::UnsupportedOperationError, 'you may only select all options of a multi-select' unless multiple?\n\n          options.each { |e| select_option e }\n        end\n\n        #\n        # Deselect all selected options. Only valid if the element supports multiple selections.\n        #\n        # @raise [Error::UnsupportedOperationError] if the element does not support multiple selections.\n        #\n\n        def deselect_all\n          raise Error::UnsupportedOperationError, 'you may only deselect all options of a multi-select' unless multiple?\n\n          options.each { |e| deselect_option e }\n        end\n\n        private\n","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/support/select.rb#L126-L162","documentation":"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.","triggerScenarios":"Calling select.select_all when the underlying <select> does not have the 'multiple' attribute (i.e. select.multiple? is false).","commonSituations":"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.","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."],"exampleFix":"# before\nselect.select_all\n\n# after\nif select.multiple?\n  select.select_all\nelse\n  select.select_by(:index, 0)\nend","handlingStrategy":"validation","validationCode":"select.select_all if select.multiple?","typeGuard":"def multi_select?(select)\n  select.multiple?\nend","tryCatchPattern":"begin\n  select.select_all\nrescue Selenium::WebDriver::Error::UnsupportedOperationError\n  select.select_by(:index, 0) # fallback for single-select\nend","preventionTips":["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."],"tags":["select","unsupported-operation","ruby"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}