Class: PageObject::Elements::SelectList

Inherits:
Element
  • Object
show all
Defined in:
lib/page-object/elements/select_list.rb

Instance Attribute Summary

Attributes inherited from Element

#element

Instance Method Summary collapse

Methods inherited from Element

#==, #check_exists, #check_visible, #children, #disabled?, #following_sibling, #following_siblings, #initialize, #method_missing, #name, #parent, plural_form, #preceding_sibling, #preceding_siblings, #present?, #respond_to_missing?, #siblings, #wait_until, #when_not_present, #when_present

Methods included from NestedElements

included

Constructor Details

This class inherits a constructor from PageObject::Elements::Element

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class PageObject::Elements::Element

Instance Method Details

#[](idx) ⇒ PageObject::Elements::Option

Return the PageObject::Elements::Option for the index provided. Index is zero based.


11
12
13
# File 'lib/page-object/elements/select_list.rb', line 11

def [](idx)
  options[idx]
end

#optionsarray of PageObject::Elements::Option

Return an array of Options contained in the select list.

Returns:


20
21
22
# File 'lib/page-object/elements/select_list.rb', line 20

def options
  element.options.map { |e| PageObject::Elements::Option.new(e) }
end

#selected_optionsArray<String>

Returns An array of strings representing the text of the currently selected options.

Returns:

  • (Array<String>)

    An array of strings representing the text of the currently selected options.


27
28
29
# File 'lib/page-object/elements/select_list.rb', line 27

def selected_options
  element.selected_options.map(&:text).compact
end

#selected_valuesArray<String>

Returns An array of strings representing the value of the currently selected options.

Returns:

  • (Array<String>)

    An array of strings representing the value of the currently selected options.


34
35
36
# File 'lib/page-object/elements/select_list.rb', line 34

def selected_values
  element.selected_options.map(&:value).compact
end