Class: Watir::Select
- Inherits:
-
Object
- Object
- Watir::Select
- Defined in:
- lib/watir-formhandler/select.rb
Overview
Extends the Watir::Select class for the #set and #field_value methods and also adds the means to select multiple options when possible.
Instance Method Summary collapse
-
#field_value ⇒ String+
Selected option(s) of this Select.
-
#select_multiple(*values) ⇒ Array<String>
Selects the given options of this Select.
-
#set(*values) ⇒ String+
Selects the given option(s) of this Select.
Instance Method Details
#field_value ⇒ String+
Selected option(s) of this Select.
32 33 34 35 |
# File 'lib/watir-formhandler/select.rb', line 32 def field_value opts = opts.count == 1 ? opts.first.text : opts.map(&:text) end |
#select_multiple(*values) ⇒ Array<String>
Selects the given options of this Select.
23 24 25 26 |
# File 'lib/watir-formhandler/select.rb', line 23 def select_multiple(*values) clear values.flatten.each{ |value| select(value) } end |
#set(*values) ⇒ String+
Selects the given option(s) of this Select. If this Select has the ‘multiple’ attribute, it accept an array, otherwise it will call the internal ‘#select’ method.
11 12 13 14 15 16 17 |
# File 'lib/watir-formhandler/select.rb', line 11 def set(*values) if multiple? select_multiple(*values) else select(values.first) end end |