Class: Symbiont::WebObjects::SelectList
- Defined in:
- lib/symbiont/web_objects/select_list.rb
Instance Attribute Summary
Attributes inherited from WebObject
Class Method Summary collapse
Instance Method Summary collapse
-
#[](idx) ⇒ Symbiont::WebObjects::Option
This method is used to return an Option object based on the index provided.
-
#include?(value) ⇒ Boolean
This method checks to see if the select list has one or more options where the text or the label matches the provided value.
-
#initialize(web_object) ⇒ SelectList
constructor
A new instance of SelectList.
-
#options ⇒ array of Symbiont::WebObjects::Option
This method returns an array of Option objects that are contained within a select list object.
-
#select(value) ⇒ Object
Selects an option from the select list.
-
#select_value(value) ⇒ Object
Selects the option whose value attribute matches the provided string.
-
#selected?(value) ⇒ Boolean
This method returns true if any of the text or the label of any option that is selected matches the provided value.
-
#selected_options ⇒ Array<String>
This method returns an array of strings that contain the text of the currently selected options in a select list.
-
#selected_values ⇒ Array<String>
This method returns an array of strings that contain the values of the currently selected options in a select list.
Methods inherited from WebObject
#==, #attribute, #clear, #click, #disabled?, #double_click, #enabled?, #exists?, #fire_event, #flash, #focus, #hover, #html, #id, #inspect, #parent, provide_locator_for, #scroll_into_view, selector_mapping, #send_keys, #style, #tag_name, #text, #value, #visible?, #wait_until, #when_actionable, #when_not_actionable, #when_not_visible, #when_visible
Constructor Details
#initialize(web_object) ⇒ SelectList
Returns a new instance of SelectList.
5 6 7 |
# File 'lib/symbiont/web_objects/select_list.rb', line 5 def initialize(web_object) @web_object = web_object end |
Class Method Details
.usable_selectors ⇒ Object
9 10 11 |
# File 'lib/symbiont/web_objects/select_list.rb', line 9 def self.usable_selectors super + [:value, :text, :label] end |
Instance Method Details
#[](idx) ⇒ Symbiont::WebObjects::Option
This method is used to return an Option object based on the index provided.
15 16 17 |
# File 'lib/symbiont/web_objects/select_list.rb', line 15 def [](idx) ::Symbiont::WebObjects::Option.new([idx]) end |
#include?(value) ⇒ Boolean
This method checks to see if the select list has one or more options where the text or the label matches the provided value.
67 68 69 |
# File 'lib/symbiont/web_objects/select_list.rb', line 67 def include?(value) web_object.include? value end |
#options ⇒ array of Symbiont::WebObjects::Option
This method returns an array of Option objects that are contained within a select list object.
32 33 34 35 36 37 38 39 |
# File 'lib/symbiont/web_objects/select_list.rb', line 32 def web_objects = [] = web_object.wd.find_elements(:xpath, option_xpath) .each do |opt| web_objects << ::Symbiont::WebObjects::Option.new(opt) end web_objects end |
#select(value) ⇒ Object
Selects an option from the select list.
20 21 22 |
# File 'lib/symbiont/web_objects/select_list.rb', line 20 def select(value) web_object.select(value) end |
#select_value(value) ⇒ Object
Selects the option whose value attribute matches the provided string.
25 26 27 |
# File 'lib/symbiont/web_objects/select_list.rb', line 25 def select_value(value) web_object.select_value(value) end |
#selected?(value) ⇒ Boolean
This method returns true if any of the text or the label of any option that is selected matches the provided value.
59 60 61 |
# File 'lib/symbiont/web_objects/select_list.rb', line 59 def selected?(value) web_object.selected? value end |
#selected_options ⇒ Array<String>
This method returns an array of strings that contain the text of the currently selected options in a select list.
44 45 46 |
# File 'lib/symbiont/web_objects/select_list.rb', line 44 def web_object..map { |e| e.text }.compact end |
#selected_values ⇒ Array<String>
This method returns an array of strings that contain the values of the currently selected options in a select list.
51 52 53 |
# File 'lib/symbiont/web_objects/select_list.rb', line 51 def selected_values web_object..map { |e| e.value }.compact end |