Module: PageObject::Platforms::SeleniumWebDriver::SelectList
- Defined in:
- lib/page-object/platforms/selenium_webdriver/select_list.rb
Instance Method Summary collapse
-
#[](idx) ⇒ PageObject::Elements::Option
Return the PageObject::Elements::Option for the index provided.
-
#clear ⇒ Object
Deselect all selected options.
-
#include?(value) ⇒ Boolean
Returns true if the select list has one or more options where text or label matches the given value.
-
#options ⇒ array of PageObject::Elements::Option
Return an array of Options contained in the select list.
-
#select(value) ⇒ Object
Select a value from the list.
-
#select_value(value) ⇒ Object
Select the option(s) whose value attribute matches the given string.
-
#selected?(value) ⇒ Boolean
Returns true if any of the selected options’ text match the given value.
-
#selected_options ⇒ Array<String>
An array of strings representing the text of the currently selected options.
-
#selected_values ⇒ Array<String>
An array of strings representing the value of the currently selected options.
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/selenium_webdriver/select_list.rb', line 12 def [](idx) [idx] end |
#clear ⇒ Object
Deselect all selected options.
80 81 82 |
# File 'lib/page-object/platforms/selenium_webdriver/select_list.rb', line 80 def clear .select { |e| e.selected? }.each { |o| o.click } end |
#include?(value) ⇒ Boolean
Returns true if the select list has one or more options where text or label matches the given value.
63 64 65 |
# File 'lib/page-object/platforms/selenium_webdriver/select_list.rb', line 63 def include?(value) .any? { |e| e.text == value } end |
#options ⇒ array of PageObject::Elements::Option
Return an array of Options contained in the select list.
40 41 42 |
# File 'lib/page-object/platforms/selenium_webdriver/select_list.rb', line 40 def .map { |e| ::PageObject::Elements::Option.new(e, :platform => :selenium_webdriver) } end |
#select(value) ⇒ Object
Select a value from the list
19 20 21 22 23 |
# File 'lib/page-object/platforms/selenium_webdriver/select_list.rb', line 19 def select(value) .find do |option| option.text == value end.click end |
#select_value(value) ⇒ Object
Select the option(s) whose value attribute matches the given string
29 30 31 32 33 34 |
# File 'lib/page-object/platforms/selenium_webdriver/select_list.rb', line 29 def select_value(value) = .find_all do |option| option.attribute('value') == value end .each {|opt| opt.click} end |
#selected?(value) ⇒ Boolean
Returns true if any of the selected options’ text match the given value.
72 73 74 75 |
# File 'lib/page-object/platforms/selenium_webdriver/select_list.rb', line 72 def selected?(value) selected = .select { |e| e if e.selected? } selected.any? { |e| e.text == value } end |
#selected_options ⇒ Array<String>
Returns An array of strings representing the text of the currently selected options.
47 48 49 |
# File 'lib/page-object/platforms/selenium_webdriver/select_list.rb', line 47 def .map { |e| e.text if e.selected? }.compact end |
#selected_values ⇒ Array<String>
Returns An array of strings representing the value of the currently selected options.
54 55 56 |
# File 'lib/page-object/platforms/selenium_webdriver/select_list.rb', line 54 def selected_values .map { |e| e.attribute('value') if e.selected? }.compact end |