Class: TestCentricity::SelectList
- Defined in:
- lib/testcentricity_web/elements/select_list.rb
Instance Attribute Summary collapse
-
#list_item ⇒ Object
Returns the value of attribute list_item.
-
#selected_item ⇒ Object
Returns the value of attribute selected_item.
Attributes inherited from UIElement
#alt_locator, #context, #locator, #name, #parent, #type
Instance Method Summary collapse
-
#choose_option(option) ⇒ Object
Select the specified option in a select box object.
-
#choose_siebel_option(option) ⇒ Object
Select the specified option in a Siebel OUI select box object.
- #define_list_elements(element_spec) ⇒ Object
-
#get_option_count ⇒ Integer
(also: #get_item_count)
Return the number of options in a select box object.
-
#get_options ⇒ Array
(also: #get_list_items)
Return array of strings of all options in a select box object.
-
#get_selected_option ⇒ String
(also: #selected?)
Return text of first selected option in a select box object.
-
#get_siebel_options ⇒ Array
Return array of strings of all options in a Siebel OUI select box object.
-
#initialize(name, parent, locator, context) ⇒ SelectList
constructor
A new instance of SelectList.
-
#read_only? ⇒ Boolean
Is Siebel JComboBox set to read-only?.
- #verify_options(expected, enqueue = false) ⇒ Object
- #verify_siebel_options(expected, enqueue = false) ⇒ Object
Methods inherited from UIElement
#clear_alt_locator, #click, #click_at, #disabled?, #double_click, #drag_and_drop, #drag_by, #enabled?, #exists?, #get_attribute, #get_locator, #get_name, #get_native_attribute, #get_object_type, #get_siebel_object_type, #get_value, #hidden?, #hover, #invoke_siebel_dialog, #right_click, #send_keys, #set, #set_alt_locator, #verify_value, #visible?, #wait_until_exists, #wait_until_gone, #wait_until_hidden, #wait_until_value_changes, #wait_until_value_is, #wait_until_visible
Constructor Details
#initialize(name, parent, locator, context) ⇒ SelectList
Returns a new instance of SelectList.
6 7 8 9 10 11 12 13 14 |
# File 'lib/testcentricity_web/elements/select_list.rb', line 6 def initialize(name, parent, locator, context) super @type = :selectlist list_spec = { :list_item => 'option', :selected_item => 'option[selected]' } define_list_elements(list_spec) end |
Instance Attribute Details
#list_item ⇒ Object
Returns the value of attribute list_item.
3 4 5 |
# File 'lib/testcentricity_web/elements/select_list.rb', line 3 def list_item @list_item end |
#selected_item ⇒ Object
Returns the value of attribute selected_item.
4 5 6 |
# File 'lib/testcentricity_web/elements/select_list.rb', line 4 def selected_item @selected_item end |
Instance Method Details
#choose_option(option) ⇒ Object
Select the specified option in a select box object. Accepts a String or Hash. Supports standard HTML select objects and Chosen select objects.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/testcentricity_web/elements/select_list.rb', line 40 def choose_option(option) obj, = find_element object_not_found_exception(obj, nil) obj.click if first(:css, 'li.active-result') if option.is_a?(Array) option.each do |item| page.find(:css, 'li.active-result', text: item.strip).click end else first(:css, 'li.active-result', text: option).click end else if option.is_a?(Array) option.each do |item| select_item(obj, item) end else select_item(obj, option) end end end |
#choose_siebel_option(option) ⇒ Object
Select the specified option in a Siebel OUI select box object.
133 134 135 136 137 |
# File 'lib/testcentricity_web/elements/select_list.rb', line 133 def choose_siebel_option(option) Capybara.wait_on_first_by_default = true invoke_siebel_popup first(:xpath, "//li[@class='ui-menu-item']", :exact => true, :match => :prefer_exact, text: option).click end |
#define_list_elements(element_spec) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/testcentricity_web/elements/select_list.rb', line 16 def define_list_elements(element_spec) element_spec.each do |element, value| case element when :list_item @list_item = value when :selected_item @selected_item = value end end end |
#get_option_count ⇒ Integer Also known as: get_item_count
Return the number of options in a select box object. Supports standard HTML select objects and Chosen select objects.
89 90 91 92 93 94 95 96 97 |
# File 'lib/testcentricity_web/elements/select_list.rb', line 89 def get_option_count obj, = find_element object_not_found_exception(obj, nil) if first(:css, 'li.active-result') obj.all('li.active-result').count else obj.all(@list_item).count end end |
#get_options ⇒ Array Also known as: get_list_items
Return array of strings of all options in a select box object. Supports standard HTML select objects and Chosen select objects.
70 71 72 73 74 75 76 77 78 |
# File 'lib/testcentricity_web/elements/select_list.rb', line 70 def obj, = find_element object_not_found_exception(obj, nil) if first(:css, 'li.active-result') obj.all('li.active-result').collect(&:text) else obj.all(@list_item).collect(&:text) end end |
#get_selected_option ⇒ String Also known as: selected?
Return text of first selected option in a select box object. Supports standard HTML select objects and Chosen select objects.
115 116 117 118 119 120 121 122 123 |
# File 'lib/testcentricity_web/elements/select_list.rb', line 115 def get_selected_option obj, = find_element object_not_found_exception(obj, nil) if first(:css, 'li.active-result') obj.first("//li[contains(@class, 'result-selected')]").text else obj.first(@selected_item).text end end |
#get_siebel_options ⇒ Array
Return array of strings of all options in a Siebel OUI select box object.
145 146 147 148 149 150 151 152 |
# File 'lib/testcentricity_web/elements/select_list.rb', line 145 def invoke_siebel_popup sleep(0.5) = page.all(:xpath, "//li[@class='ui-menu-item']").collect(&:text) obj, = find_element obj.native.send_keys(:escape) end |
#read_only? ⇒ Boolean
Is Siebel JComboBox set to read-only?
171 172 173 174 175 |
# File 'lib/testcentricity_web/elements/select_list.rb', line 171 def read_only? obj, = find_element object_not_found_exception(obj, nil) !obj.native.attribute('readonly') end |
#verify_options(expected, enqueue = false) ⇒ Object
101 102 103 104 105 106 |
# File 'lib/testcentricity_web/elements/select_list.rb', line 101 def (expected, enqueue = false) actual = enqueue ? ExceptionQueue.enqueue_assert_equal(expected, actual, "Expected list of options in list #{}") : assert_equal(expected, actual, "Expected list of options in list #{} to be #{expected} but found #{actual}") end |
#verify_siebel_options(expected, enqueue = false) ⇒ Object
154 155 156 157 158 159 160 161 162 163 |
# File 'lib/testcentricity_web/elements/select_list.rb', line 154 def (expected, enqueue = false) invoke_siebel_popup sleep(0.5) actual = page.all(:xpath, "//li[@class='ui-menu-item']").collect(&:text) enqueue ? ExceptionQueue.enqueue_assert_equal(expected, actual, "Expected list of options in list #{}") : assert_equal(expected, actual, "Expected list of options in list #{} to be #{expected} but found #{actual}") obj, = find_element obj.native.send_keys(:escape) end |