{"record":{"id":"29ff496b17841e54","repo":"SeleniumHQ/selenium","slug":"cannot-locate-option-with-value-value-inspect","errorCode":null,"errorMessage":"cannot locate option with value: #{value.inspect}","messagePattern":"cannot locate option with value: #(.+?)","errorType":"exception","errorClass":"Error::NoSuchElementError","httpStatus":null,"severity":"error","filePath":"rb/lib/selenium/webdriver/support/select.rb","lineNumber":184,"sourceCode":"          return select_options(opts) unless opts.empty?\n\n          raise Error::NoSuchElementError, \"cannot locate element with text: #{text.inspect}\"\n        end\n\n        def select_by_index(index)\n          opts = find_by_index index\n\n          return select_option(opts.first) unless opts.empty?\n\n          raise Error::NoSuchElementError, \"cannot locate element with index: #{index.inspect}\"\n        end\n\n        def select_by_value(value)\n          opts = find_by_value value\n\n          return select_options(opts) unless opts.empty?\n\n          raise Error::NoSuchElementError, \"cannot locate option with value: #{value.inspect}\"\n        end\n\n        def deselect_by_text(text)\n          raise Error::UnsupportedOperationError, 'you may only deselect option of a multi-select' unless multiple?\n\n          opts = find_by_text text\n\n          return deselect_options(opts) unless opts.empty?\n\n          raise Error::NoSuchElementError, \"cannot locate element with text: #{text.inspect}\"\n        end\n\n        def deselect_by_value(value)\n          raise Error::UnsupportedOperationError, 'you may only deselect option of a multi-select' unless multiple?\n\n          opts = find_by_value value\n\n          return deselect_options(opts) unless opts.empty?","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/support/select.rb#L166-L202","documentation":"In private select_by_value, if no <option> has an @value attribute matching the argument, the binding raises Error::NoSuchElementError. This is the value-attribute equivalent of 491 (text). Note it matches the value attribute, not visible text.","triggerScenarios":"Calling select.select_by(:value, 'foo') when no <option value=\"foo\"> exists. Common when the value differs from visible text, or the value is dynamically generated.","commonSituations":"Typo in value; value is a generated/id-like token that changed; option has no value attribute (empty) and the test passed a non-empty string; race where options aren't rendered yet.","solutions":["Inspect select.options.map { |o| o.attribute(:value) } to see the real value attributes.","If visible text is more stable, use select_by(:text) instead.","Add an explicit wait for the desired option's presence before selecting."],"exampleFix":"# before\nselect.select_by(:value, 'foo')\n\n# after\nSelenium::WebDriver::Wait.new.until { select.options.any? { |o| o.attribute(:value) == 'foo' } }\nselect.select_by(:value, 'foo')","handlingStrategy":"validation","validationCode":"Selenium::WebDriver::Wait.new.until { select.options.any? { |o| o.attribute(:value) == value } }\nselect.select_by(:value, value)","typeGuard":"def option_with_value?(select, value)\n  select.options.any? { |o| o.attribute(:value) == value }\nend","tryCatchPattern":"begin\n  select.select_by(:value, value)\nrescue Selenium::WebDriver::Error::NoSuchElementError => e\n  raise unless e.message.include?('cannot locate option with value')\n  # value not present — wait/retry or assert\nend","preventionTips":["Inspect select.options.map { |o| o.attribute(:value) } for real values.","Wait for the option to be present before selecting.","Use select_by(:text) when the value attribute is generated/unstable."],"tags":["select","no-such-element","ruby"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}