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.
-
#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 lit.
-
#select(value) ⇒ Object
Select a value from the list.
-
#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 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 |
#include?(value) ⇒ Boolean
Returns true if the select list has one or more options where text or label matches the given value.
43 44 45 |
# File 'lib/page-object/platforms/selenium_webdriver/select_list.rb', line 43 def include?(value) .any? { |e| e.text == value } end |
#options ⇒ array of PageObject::Elements::Option
Return an array of Options contained in the select lit.
27 28 29 |
# File 'lib/page-object/platforms/selenium_webdriver/select_list.rb', line 27 def .map { |e| ::PageObject::Elements::Option.new(e, :platform => :selenium_webdriver) } end |
#select(value) ⇒ Object
Select a value from the list
19 20 21 |
# File 'lib/page-object/platforms/selenium_webdriver/select_list.rb', line 19 def select(value) element.send_keys(value) end |
#selected?(value) ⇒ Boolean
Returns true if any of the selected options’ text match the given value.
52 53 54 55 |
# File 'lib/page-object/platforms/selenium_webdriver/select_list.rb', line 52 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 value of the currently selected options.
34 35 36 |
# File 'lib/page-object/platforms/selenium_webdriver/select_list.rb', line 34 def .map { |e| e.text if e.selected? }.compact end |