Class: Dill::Select

Inherits:
Field show all
Defined in:
lib/dill/widgets/select.rb

Overview

A select.

Instance Method Summary collapse

Methods inherited from Field

find_in, present_in?

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

included

Constructor Details

This class inherits a constructor from Dill::Widget

Instance Method Details

#getString

Returns The text of the selected option.

Returns:

  • (String)

    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_cellObject



25
26
27
# File 'lib/dill/widgets/select.rb', line 25

def to_cell
  get
end

#to_sObject

Returns the text of the selected option, or the empty string if no option is selected.

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