Class: FireWatir::SelectList
- Inherits:
-
InputElement
- Object
- Element
- InputElement
- FireWatir::SelectList
- Defined in:
- lib/firewatir/elements/select_list.rb
Overview
Description:
Class for SelectList element.
Constant Summary collapse
- INPUT_TYPES =
["select-one", "select-multiple"]
Constants inherited from Element
Element::FIRST_ORDERED_NODE_TYPE, Element::NUMBER_TYPE, Element::ORDERED_NODE_ITERATOR_TYPE, Element::TO_S_SIZE
Constants included from Container
Container::DEFAULT_HIGHLIGHT_COLOR, Container::MACHINE_IP
Instance Attribute Summary collapse
-
#o ⇒ Object
Returns the value of attribute o.
Attributes inherited from InputElement
Attributes inherited from Element
Instance Method Summary collapse
-
#[](key) ⇒ Object
Description: Get option element at specified index in select list.
-
#clear ⇒ Object
(also: #clearSelection)
Description: Clears the selected items in the select box.
- #each ⇒ Object
-
#option(attribute, value) ⇒ Object
Description: Get the option using attribute and its value.
-
#options ⇒ Object
(also: #getAllContents)
Description: Gets all the items in the select list as an array.
-
#select(item) ⇒ Object
(also: #set)
Description: Selects an item by text.
-
#select_value(item) ⇒ Object
Description: Selects an item by value.
-
#selected_options ⇒ Object
(also: #getSelectedItems)
Description: Gets all the selected items in the select list as an array.
Methods inherited from InputElement
Methods inherited from Element
#assert_enabled, #assert_exists, #attribute_value, #click, #contains_text, #disabled, #document_var, #element_by_xpath, #element_type, #elements_by_xpath, #enabled?, #exists?, #fire_event, #initialize, #inspect, #method_missing, #text, #to_s, #visible?, #wait
Methods included from Container
#button, #cell, #checkbox, #dd, #dl, #dt, #file_field, #form, #frame, #hidden, #image, #link, #radio, #row, #select_list, #show_all_objects, #table, #text_field
Methods included from JsshSocket
#js_eval, #js_eval_method, #jssh_socket, #read_socket
Constructor Details
This class inherits a constructor from FireWatir::InputElement
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class FireWatir::Element
Instance Attribute Details
#o ⇒ Object
Returns the value of attribute o.
9 10 11 |
# File 'lib/firewatir/elements/select_list.rb', line 9 def o @o end |
Instance Method Details
#[](key) ⇒ Object
Description:
Get option element at specified index in select list.
Input:
key - option index
Output:
Option element at specified index
49 50 51 52 53 |
# File 'lib/firewatir/elements/select_list.rb', line 49 def [] (key) assert_exists = return Option.new(self, :jssh_name, [key - 1]) end |
#clear ⇒ Object Also known as: clearSelection
Description:
Clears the selected items in the select box.
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/firewatir/elements/select_list.rb', line 15 def clear assert_exists #highlight( :set) wait = false each do |selectBoxItem| if selectBoxItem.selected selectBoxItem.selected = false wait = true end end self.wait if wait #highlight( :clear) end |
#each ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/firewatir/elements/select_list.rb', line 30 def each assert_exists = #puts arr_options[0]#.length for i in 0...length - 1 do yield Option.new(self, :jssh_name, [i]) end end |
#option(attribute, value) ⇒ Object
Description:
Get the option using attribute and its value.
Input:
- attribute - Attribute used to find the option.
- value - value of that attribute.
128 129 130 131 |
# File 'lib/firewatir/elements/select_list.rb', line 128 def option (attribute, value) assert_exists Option.new(self, attribute, value) end |
#options ⇒ Object Also known as: getAllContents
Description:
Gets all the items in the select list as an array.
An empty array is returned if the select box has no contents.
Output:
Array containing the items of the select list.
86 87 88 89 90 91 92 |
# File 'lib/firewatir/elements/select_list.rb', line 86 def assert_exists #element.log "There are #{@o.length} items" returnArray = [] each { |thisItem| returnArray << thisItem.text } return returnArray end |
#select(item) ⇒ Object Also known as: set
Description:
Selects an item by text. If you need to select multiple items you need to call this function for each item.
Input:
- item - Text of item to be selected.
62 63 64 |
# File 'lib/firewatir/elements/select_list.rb', line 62 def select( item ) select_items_in_select_list(:text, item) end |
#select_value(item) ⇒ Object
Description:
Selects an item by value. If you need to select multiple items you need to call this function for each item.
Input:
-
item - Value of the item to be selected.
74 75 76 |
# File 'lib/firewatir/elements/select_list.rb', line 74 def select_value( item ) select_items_in_select_list(:value, item) end |
#selected_options ⇒ Object Also known as: getSelectedItems
Description:
Gets all the selected items in the select list as an array.
An empty array is returned if the select box has no selected item.
Output:
Array containing the selected items of the select list.
104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/firewatir/elements/select_list.rb', line 104 def assert_exists returnArray = [] #element.log "There are #{@o.length} items" each do |thisItem| #puts "#{thisItem.selected}" if thisItem.selected #element.log "Item ( #{thisItem.text} ) is selected" returnArray << thisItem.text end end return returnArray end |