Method: Watir::SelectList#option

Defined in:
lib/watir/input_elements.rb

#option(attribute, value) ⇒ Object

this method provides the access to the item in select_list

Usage example:

Given the following html:

get the value attribute of option with visible text 'Female' browser.select_list(:id, 'gender').option(:text, 'Female').value #=> 'F' or find out if the value 'M' is selected browser.select_list(:id, 'gender').option(:value, 'M').selected #=> true

  • attribute - Symbol :value, :text or other attribute - how we find an item in the select box
  • value - string or reg exp - what we are looking for


151
152
153
154
# File 'lib/watir/input_elements.rb', line 151

def option(attribute, value)
  assert_exists
  Option.new(self, attribute, value)
end