Class: Dill::Select
Overview
A select.
Instance Method Summary collapse
-
#get ⇒ String
The text of the selected option.
-
#set(option) ⇒ Object
Selects the given
option. - #to_cell ⇒ Object
-
#to_s ⇒ Object
The text of the selected option, or the empty string if no option is selected.
Methods inherited from Field
Methods inherited from Widget
#absent?, action, #click, #diff, find_in, #gone?, #has_action?, #initialize, #inspect, #present?, present_in?, root, #root, selector, #text, #value, widget, widget_delegator
Methods included from WidgetParts::Container
#has_no_widget?, #has_widget?, #widget
Methods included from WidgetParts::Struct
Constructor Details
This class inherits a constructor from Dill::Widget
Instance Method Details
#get ⇒ String
Returns The text of the selected option.
5 6 7 8 9 |
# File 'lib/dill/widgets/select.rb', line 5 def get option = root.find('[selected]') rescue nil option && option.text end |
#set(option) ⇒ Object
Selects the given option.
You may pass in the option text or value.
14 15 16 17 18 |
# File 'lib/dill/widgets/select.rb', line 14 def set(option) root. find(:xpath, "option[@value = '#{option}' or . = '#{option}']"). select_option end |
#to_cell ⇒ Object
25 26 27 |
# File 'lib/dill/widgets/select.rb', line 25 def to_cell get end |
#to_s ⇒ Object
Returns the text of the selected option, or the empty string if no option is selected.
23 |
# File 'lib/dill/widgets/select.rb', line 23 def_delegator :get, :to_s |