{"record":{"id":"8f926c916a9d3639","repo":"SeleniumHQ/selenium","slug":"unexpected-tag-name-tag-name-inspect","errorCode":null,"errorMessage":"unexpected tag name #{tag_name.inspect}","messagePattern":"unexpected tag name #(.+?)","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"rb/lib/selenium/webdriver/support/select.rb","lineNumber":31,"sourceCode":"# Unless required by applicable law or agreed to in writing,\n# software distributed under the License is distributed on an\n# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n# KIND, either express or implied.  See the License for the\n# specific language governing permissions and limitations\n# under the License.\n\nmodule Selenium\n  module WebDriver\n    module Support\n      class Select\n        #\n        # @param [Element] element The select element to use\n        #\n\n        def initialize(element)\n          tag_name = element.tag_name\n\n          raise ArgumentError, \"unexpected tag name #{tag_name.inspect}\" unless tag_name.casecmp('select').zero?\n\n          @element = element\n          @multi = ![nil, 'false'].include?(element.dom_attribute(:multiple))\n        end\n\n        #\n        # Does this select element support selecting multiple options?\n        #\n        # @return [Boolean]\n        #\n\n        def multiple?\n          @multi\n        end\n\n        #\n        # Get all options for this select element\n        #","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/support/select.rb#L13-L49","documentation":"Support::Select.new asserts that the element's tag name equals 'select' (case-insensitive via casecmp). Support::Select only models HTML <select> elements, so passing any other element type (div, ul, input, option) is a programming error caught at construction. This prevents later method calls (options, select_all) from producing confusing failures.","triggerScenarios":"Calling Selenium::WebDriver::Support::Select.new(element) where element.tag_name is anything other than 'select' — e.g. a <div> custom dropdown, a <ul>, an <option>, or a locator that matched the wrong element.","commonSituations":"Locating a custom (non-native) dropdown built with div/ul and wrapping it in Select; a flaky locator that occasionally matches a sibling element; migrating from a native select to a custom widget but keeping the Select wrapper.","solutions":["Verify the element is actually a <select> via element.tag_name before constructing Select.","Fix the locator/find to target the <select> element specifically.","For custom (non-select) dropdowns, do not use Support::Select — interact with the elements directly via click."],"exampleFix":"# before\nel = driver.find_element(id: 'my-dropdown') # a <div>\nselect = Selenium::WebDriver::Support::Select.new(el)\n\n# after\nel = driver.find_element(tag_name: 'select')\nselect = Selenium::WebDriver::Support::Select.new(el)","handlingStrategy":"type-guard","validationCode":"el = driver.find_element(id: 'my-select')\nif el.tag_name.casecmp('select').zero?\n  Selenium::WebDriver::Support::Select.new(el)\nelse\n  raise \"#{el.tag_name} is not a <select>; use direct clicks for custom dropdowns\"\nend","typeGuard":"def select_element?(el)\n  el.respond_to?(:tag_name) && el.tag_name.casecmp('select').zero?\nend","tryCatchPattern":"begin\n  Selenium::WebDriver::Support::Select.new(el)\nrescue ArgumentError => e\n  raise unless e.message.include?('unexpected tag name')\n  # handle custom dropdown with direct clicks\nend","preventionTips":["Locate with tag_name: 'select' to avoid matching the wrong element.","Check element.tag_name before wrapping in Select.","Do not use Support::Select for div/ul-based custom dropdowns."],"tags":["select","validation","argument-error","ruby"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}