Method: Watir::Container#select_list

Defined in:
lib/watir/container.rb

#select_list(how, what = nil) ⇒ Object Also known as: selectBox

This is the main method for accessing a selection list. Usually a <select> HTML tag.

*  how   - symbol - how we access the selection list, :index, :id, :name etc
*  what  - string, integer or regular expression - what we are looking for,

Valid values for ‘how’ are listed in the Watir Wiki - wiki.openqa.org/display/WTR/Methods+supported+by+Element

returns a SelectList object

Typical usage

browser.select_list(:id, 'currency')                   # access the select box with an id of currency
browser.select_list(:name, 'country')                  # access the select box with a name of country
browser.select_list(:name, /n_/)                       # access the first select box whose name matches n_
browser.select_list(:index, 2)                         # access the second select box on the page (1 based, so the first field is accessed with :index,1)
browser.select(:xpath, "//select[@id='currency']/")    # access the select box with an id of currency


361
362
363
# File 'lib/watir/container.rb', line 361

def select_list(how, what=nil)
  SelectList.new(self, how, what)
end