Module: PageObject::Platforms::WatirWebDriver::SelectList

Defined in:
lib/page-object/platforms/watir_webdriver/select_list.rb

Instance Method Summary collapse

Instance Method Details

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

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



12
13
14
# File 'lib/page-object/platforms/watir_webdriver/select_list.rb', line 12

def [](idx)
  Object::PageObject::Elements::Option.new(options[idx], :platform => :watir_webdriver)
end

#include?(value) ⇒ Boolean

Returns true if the select list has one or more options where text or label matches the given value.

Parameters:

  • value (String, Regexp)

    A value.

Returns:

  • (Boolean)


49
50
51
# File 'lib/page-object/platforms/watir_webdriver/select_list.rb', line 49

def include?(value)
  element.include? value
end

#optionsarray of PageObject::Elements::Option

Return an array of Options contained in the select lit.

Returns:



28
29
30
31
32
33
34
35
# File 'lib/page-object/platforms/watir_webdriver/select_list.rb', line 28

def options
  elements = []
  options = element.wd.find_elements(:xpath, child_xpath)
  options.each do |opt|
    elements << Object::PageObject::Elements::Option.new(opt, :platform => :watir_webdriver)
  end
  elements
end

#select(value) ⇒ Object

Select a value from the list



19
20
21
# File 'lib/page-object/platforms/watir_webdriver/select_list.rb', line 19

def select(value)
  element.select(value)
end

#selected?(value) ⇒ Boolean

Returns true if any of the selected options’ text or label match the given value.

Parameters:

  • value (String, Regexp)

    A value.

Returns:

  • (Boolean)


58
59
60
# File 'lib/page-object/platforms/watir_webdriver/select_list.rb', line 58

def selected?(value)
  element.selected? value
end

#selected_optionsArray<String>

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

Returns:

  • (Array<String>)

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



40
41
42
# File 'lib/page-object/platforms/watir_webdriver/select_list.rb', line 40

def selected_options
  element.selected_options.map { |e| e.text }.compact
end