Class: TestCentricity::UIElement
- Includes:
- Capybara::DSL, Test::Unit::Assertions
- Defined in:
- lib/testcentricity_web/ui_elements_helper.rb,
lib/testcentricity_web/siebel_open_ui_helper.rb
Instance Attribute Summary collapse
-
#alt_locator ⇒ Object
Returns the value of attribute alt_locator.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#locator ⇒ Object
readonly
Returns the value of attribute locator.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #attach_file(file_path) ⇒ Object
- #checked? ⇒ Boolean
- #choose_option(option) ⇒ Object
- #choose_siebel_option(option) ⇒ Object
- #clear_alt_locator ⇒ Object
- #click ⇒ Object
- #click_at(x, y) ⇒ Object
- #click_header_column(column) ⇒ Object
- #click_table_cell(row, column) ⇒ Object
- #click_table_cell_link(row, column) ⇒ Object
- #collapse_table_row(row, column) ⇒ Object
- #disabled? ⇒ Boolean
- #double_click ⇒ Object
- #double_click_table_cell(row, column) ⇒ Object
- #drag_by(right_offset, down_offset) ⇒ Object
- #enabled? ⇒ Boolean
- #exists? ⇒ Boolean
- #expand_table_row(row, column) ⇒ Object
- #get_column_count ⇒ Object
- #get_header_column(column) ⇒ Object
- #get_header_columns ⇒ Object
- #get_list_items(item_locator) ⇒ Object
- #get_locator ⇒ Object
- #get_max_length ⇒ Object
- #get_options ⇒ Object
- #get_row_count ⇒ Object
- #get_row_data(row) ⇒ Object
- #get_selected_option ⇒ Object
- #get_siebel_object_type ⇒ Object
- #get_siebel_options ⇒ Object
- #get_table_cell(row, column) ⇒ Object
- #get_table_row(row) ⇒ Object
- #get_value ⇒ Object
- #hidden? ⇒ Boolean
- #hover ⇒ Object
-
#initialize(parent, locator, context, type = nil) ⇒ UIElement
constructor
A new instance of UIElement.
- #invoke_siebel_dialog(popup) ⇒ Object
- #is_table_row_expanded?(row, column) ⇒ Boolean
- #read_only? ⇒ Boolean
- #send_keys(*keys) ⇒ Object
- #set(value) ⇒ Object
- #set_alt_locator(temp_locator) ⇒ Object
- #set_checkbox_state(state) ⇒ Object
- #set_siebel_checkbox_state(state) ⇒ Object
- #set_table_cell(row, column, value) ⇒ Object
- #verify_check_state(state, enqueue = false) ⇒ Object
- #verify_siebel_options(expected, enqueue = false) ⇒ Object
- #verify_table_cell(row, column, expected, enqueue = false) ⇒ Object
- #verify_value(expected, enqueue = false) ⇒ Object
- #visible? ⇒ Boolean
- #wait_until_exists(seconds) ⇒ Object
- #wait_until_gone(seconds) ⇒ Object
- #wait_until_value_changes(seconds) ⇒ Object
- #wait_until_value_is(value, seconds) ⇒ Object
Constructor Details
#initialize(parent, locator, context, type = nil) ⇒ UIElement
Returns a new instance of UIElement.
28 29 30 31 32 33 34 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 28 def initialize(parent, locator, context, type = nil) @parent = parent @locator = locator @context = context @type = type @alt_locator = nil end |
Instance Attribute Details
#alt_locator ⇒ Object
Returns the value of attribute alt_locator.
26 27 28 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 26 def alt_locator @alt_locator end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
25 26 27 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 25 def context @context end |
#locator ⇒ Object (readonly)
Returns the value of attribute locator.
25 26 27 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 25 def locator @locator end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
25 26 27 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 25 def parent @parent end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
25 26 27 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 25 def type @type end |
Instance Method Details
#attach_file(file_path) ⇒ Object
218 219 220 221 222 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 218 def attach_file(file_path) Capybara.ignore_hidden_elements = false page.attach_file(@locator, file_path) Capybara.ignore_hidden_elements = true end |
#checked? ⇒ Boolean
135 136 137 138 139 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 135 def checked? obj, _ = find_element object_not_found_exception(obj, 'Checkbox') obj.checked? end |
#choose_option(option) ⇒ Object
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 224 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| obj.select item end else obj.select option end end end |
#choose_siebel_option(option) ⇒ Object
11 12 13 14 15 |
# File 'lib/testcentricity_web/siebel_open_ui_helper.rb', line 11 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 |
#clear_alt_locator ⇒ Object
44 45 46 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 44 def clear_alt_locator @alt_locator = nil end |
#click ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 48 def click obj, _ = find_element object_not_found_exception(obj, nil) begin obj.click rescue obj.click_at(10, 10) end end |
#click_at(x, y) ⇒ Object
64 65 66 67 68 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 64 def click_at(x, y) obj, _ = find_element raise "Object #{@locator} not found" unless obj obj.click_at(x, y) end |
#click_header_column(column) ⇒ Object
393 394 395 396 397 398 399 400 401 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 393 def click_header_column(column) column_count = get_column_count raise "Column #{column} exceeds number of columns (#{column_count}) in table header #{@locator}" if column > column_count (column > 1) ? set_alt_locator("#{@locator}/thead/tr/th[#{column}]") : set_alt_locator("#{@locator}/thead/tr/th") click clear_alt_locator end |
#click_table_cell(row, column) ⇒ Object
276 277 278 279 280 281 282 283 284 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 276 def click_table_cell(row, column) row_count = get_row_count raise "Row #{row} exceeds number of rows (#{row_count}) in table #{@locator}" if row > row_count column_count = get_column_count raise "Column #{column} exceeds number of columns (#{column_count}) in table #{@locator}" if column > column_count set_table_cell_locator(row, column) click clear_alt_locator end |
#click_table_cell_link(row, column) ⇒ Object
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 296 def click_table_cell_link(row, column) row_count = get_row_count raise "Row #{row} exceeds number of rows (#{row_count}) in table #{@locator}" if row > row_count column_count = get_column_count raise "Column #{column} exceeds number of columns (#{column_count}) in table #{@locator}" if column > column_count set_table_cell_locator(row, column) saved_locator = @alt_locator set_alt_locator("#{@alt_locator}/a") set_alt_locator("#{saved_locator}/span/a") unless exists? # if link not present, check for text entry fields and try to dismiss by tabbing out unless exists? set_alt_locator("#{saved_locator}/input") set_alt_locator("#{saved_locator}/textarea") unless exists? send_keys(:tab) if exists? set_alt_locator("#{saved_locator}/a") set_alt_locator("#{saved_locator}/span/a") unless exists? send_keys(:tab) unless exists? end wait_until_exists(1) click clear_alt_locator end |
#collapse_table_row(row, column) ⇒ Object
73 74 75 76 77 78 79 80 |
# File 'lib/testcentricity_web/siebel_open_ui_helper.rb', line 73 def collapse_table_row(row, column) if (row, column) set_table_cell_locator(row, column) set_alt_locator("#{@alt_locator}/div/div[@class='ui-icon ui-icon-triangle-1-s tree-minus treeclick']") click if exists? clear_alt_locator end end |
#disabled? ⇒ Boolean
117 118 119 120 121 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 117 def disabled? obj, _ = find_element object_not_found_exception(obj, nil) obj.disabled? end |
#double_click ⇒ Object
58 59 60 61 62 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 58 def double_click obj, _ = find_element object_not_found_exception(obj, nil) page.driver.browser.mouse.double_click(obj.native) end |
#double_click_table_cell(row, column) ⇒ Object
286 287 288 289 290 291 292 293 294 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 286 def double_click_table_cell(row, column) row_count = get_row_count raise "Row #{row} exceeds number of rows (#{row_count}) in table #{@locator}" if row > row_count column_count = get_column_count raise "Column #{column} exceeds number of columns (#{column_count}) in table #{@locator}" if column > column_count set_table_cell_locator(row, column) double_click clear_alt_locator end |
#drag_by(right_offset, down_offset) ⇒ Object
212 213 214 215 216 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 212 def drag_by(right_offset, down_offset) obj, _ = find_element object_not_found_exception(obj, nil) obj.drag_by(right_offset, down_offset) end |
#enabled? ⇒ Boolean
113 114 115 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 113 def enabled? not disabled? end |
#exists? ⇒ Boolean
82 83 84 85 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 82 def exists? obj, _ = find_element obj != nil end |
#expand_table_row(row, column) ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'lib/testcentricity_web/siebel_open_ui_helper.rb', line 64 def (row, column) unless (row, column) set_table_cell_locator(row, column) set_alt_locator("#{@alt_locator}/div/div[@class='ui-icon ui-icon-triangle-1-e tree-plus treeclick']") click if exists? clear_alt_locator end end |
#get_column_count ⇒ Object
265 266 267 268 269 270 271 272 273 274 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 265 def get_column_count row_count = get_row_count if row_count == 0 page.all(:xpath, "#{@locator}/thead/tr/th", :visible => :all).count else (row_count == 1) ? page.all(:xpath, "#{@locator}/tbody/tr/td", :visible => :all).count : page.all(:xpath, "#{@locator}/tbody/tr[2]/td", :visible => :all).count end end |
#get_header_column(column) ⇒ Object
403 404 405 406 407 408 409 410 411 412 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 403 def get_header_column(column) column_count = get_column_count raise "Column #{column} exceeds number of columns (#{column_count}) in table header #{@locator}" if column > column_count (column > 1) ? set_alt_locator("#{@locator}/thead/tr/th[#{column}]") : set_alt_locator("#{@locator}/thead/tr/th") value = get_value clear_alt_locator value end |
#get_header_columns ⇒ Object
414 415 416 417 418 419 420 421 422 423 424 425 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 414 def get_header_columns columns = [] column_count = get_column_count (1..column_count).each do |column| (column > 1) ? set_alt_locator("#{@locator}/thead/tr/th[#{column}]") : set_alt_locator("#{@locator}/thead/tr/th") columns.push(get_value) end clear_alt_locator columns end |
#get_list_items(item_locator) ⇒ Object
427 428 429 430 431 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 427 def get_list_items(item_locator) obj, _ = find_element object_not_found_exception(obj, nil) obj.all(item_locator).collect(&:text) end |
#get_locator ⇒ Object
36 37 38 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 36 def get_locator @locator end |
#get_max_length ⇒ Object
129 130 131 132 133 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 129 def get_max_length obj, _ = find_element object_not_found_exception(obj, nil) obj.native.attribute('maxlength') end |
#get_options ⇒ Object
247 248 249 250 251 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 247 def obj, _ = find_element object_not_found_exception(obj, nil) obj.all('option').collect(&:text) end |
#get_row_count ⇒ Object
259 260 261 262 263 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 259 def get_row_count wait_until_exists(5) row_count = page.all(:xpath, "#{@locator}/tbody/tr", :visible => :all).count row_count end |
#get_row_data(row) ⇒ Object
342 343 344 345 346 347 348 349 350 351 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 342 def get_row_data(row) row_count = get_row_count raise "Row #{row} exceeds number of rows (#{row_count}) in table #{@locator}" if row > row_count (row > 1) ? set_alt_locator("#{@locator}/tbody/tr[#{row}]") : set_alt_locator("#{@locator}/tbody/tr") value = get_value if exists? clear_alt_locator value end |
#get_selected_option ⇒ Object
253 254 255 256 257 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 253 def get_selected_option obj, _ = find_element object_not_found_exception(obj, nil) obj.find('option[selected]').text end |
#get_siebel_object_type ⇒ Object
82 83 84 85 86 |
# File 'lib/testcentricity_web/siebel_open_ui_helper.rb', line 82 def get_siebel_object_type obj, _ = find_element object_not_found_exception(obj, 'Siebel object') obj.native.attribute('ot') end |
#get_siebel_options ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/testcentricity_web/siebel_open_ui_helper.rb', line 17 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 |
#get_table_cell(row, column) ⇒ Object
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 353 def get_table_cell(row, column) row_count = get_row_count raise "Row #{row} exceeds number of rows (#{row_count}) in table #{@locator}" if row > row_count column_count = get_column_count raise "Column #{column} exceeds number of columns (#{column_count}) in table #{@locator}" if column > column_count set_table_cell_locator(row, column) saved_locator = @alt_locator set_alt_locator("#{saved_locator}/input") unless exists? set_alt_locator("#{saved_locator}/textarea") unless exists? set_alt_locator(saved_locator) end end value = get_value clear_alt_locator value end |
#get_table_row(row) ⇒ Object
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 319 def get_table_row(row) columns = [] row_count = get_row_count raise "Row #{row} exceeds number of rows (#{row_count}) in table #{@locator}" if row > row_count column_count = get_column_count (1..column_count).each do |column| value = '' set_table_cell_locator(row, column) saved_locator = @alt_locator set_alt_locator("#{saved_locator}/input") unless exists? set_alt_locator("#{saved_locator}/textarea") unless exists? set_alt_locator(saved_locator) end end value = get_value if exists? columns.push(value) end clear_alt_locator columns end |
#get_value ⇒ Object
188 189 190 191 192 193 194 195 196 197 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 188 def get_value obj, _ = find_element object_not_found_exception(obj, nil) case obj.tag_name.downcase when 'input', 'select', 'textarea' obj.value else obj.text end end |
#hidden? ⇒ Boolean
109 110 111 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 109 def hidden? not visible? end |
#hover ⇒ Object
206 207 208 209 210 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 206 def hover obj, _ = find_element object_not_found_exception(obj, nil) obj.hover end |
#invoke_siebel_dialog(popup) ⇒ Object
37 38 39 40 |
# File 'lib/testcentricity_web/siebel_open_ui_helper.rb', line 37 def invoke_siebel_dialog(popup) invoke_siebel_popup popup.wait_until_exists(15) end |
#is_table_row_expanded?(row, column) ⇒ Boolean
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/testcentricity_web/siebel_open_ui_helper.rb', line 42 def (row, column) row_count = get_row_count raise "Row #{row} exceeds number of rows (#{row_count}) in table #{@locator}" if row > row_count column_count = get_column_count raise "Column #{column} exceeds number of columns (#{column_count}) in table #{@locator}" if column > column_count set_table_cell_locator(row, column) saved_locator = @alt_locator set_alt_locator("#{@alt_locator}/div/div[@class='ui-icon ui-icon-triangle-1-s tree-minus treeclick']") if exists? = true else set_alt_locator("#{saved_locator}/div/div[@class='ui-icon ui-icon-triangle-1-e tree-plus treeclick']") if exists? = false else raise "Row #{row}/Column #{column} of table #{@locator} does not contain a disclosure triangle" end end clear_alt_locator end |
#read_only? ⇒ Boolean
123 124 125 126 127 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 123 def read_only? obj, _ = find_element object_not_found_exception(obj, nil) !!obj.native.attribute('readonly') end |
#send_keys(*keys) ⇒ Object
76 77 78 79 80 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 76 def send_keys(*keys) obj, _ = find_element object_not_found_exception(obj, nil) obj.send_keys(*keys) end |
#set(value) ⇒ Object
70 71 72 73 74 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 70 def set(value) obj, _ = find_element object_not_found_exception(obj, nil) obj.set(value) end |
#set_alt_locator(temp_locator) ⇒ Object
40 41 42 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 40 def set_alt_locator(temp_locator) @alt_locator = temp_locator end |
#set_checkbox_state(state) ⇒ Object
141 142 143 144 145 146 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 141 def set_checkbox_state(state) obj, _ = find_element object_not_found_exception(obj, 'Checkbox') invalid_object_type_exception(obj, 'checkbox') obj.set(state) end |
#set_siebel_checkbox_state(state) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/testcentricity_web/siebel_open_ui_helper.rb', line 3 def set_siebel_checkbox_state(state) obj, _ = find_element object_not_found_exception(obj, 'Siebel checkbox') raise "#{locator} is not a Siebel CheckBox object" unless get_siebel_object_type == 'JCheckBox' expected = state.to_bool obj.click unless expected == obj.checked? end |
#set_table_cell(row, column, value) ⇒ Object
379 380 381 382 383 384 385 386 387 388 389 390 391 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 379 def set_table_cell(row, column, value) row_count = get_row_count raise "Row #{row} exceeds number of rows (#{row_count}) in table #{@locator}" if row > row_count # column_count = get_column_count # raise "Column #{column} exceeds number of columns (#{column_count}) in table #{@locator}" if column > column_count set_table_cell_locator(row, column) click if exists? saved_locator = @alt_locator set_alt_locator("#{saved_locator}/input") set_alt_locator("#{saved_locator}/textarea") unless exists? set(value) clear_alt_locator end |
#verify_check_state(state, enqueue = false) ⇒ Object
148 149 150 151 152 153 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 148 def verify_check_state(state, enqueue = false) actual = checked? enqueue ? ExceptionQueue.enqueue_assert_equal(state, actual, "Expected #{@locator}") : assert_equal(state, actual, "Expected #{@locator} to be #{state} but found #{actual} instead") end |
#verify_siebel_options(expected, enqueue = false) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/testcentricity_web/siebel_open_ui_helper.rb', line 26 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 #{@locator}") : assert_equal(expected, actual, "Expected list of options in list #{@locator} to be #{expected} but found #{actual}") obj, _ = find_element obj.native.send_keys(:escape) end |
#verify_table_cell(row, column, expected, enqueue = false) ⇒ Object
372 373 374 375 376 377 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 372 def verify_table_cell(row, column, expected, enqueue = false) actual = get_table_cell(row, column) enqueue ? ExceptionQueue.enqueue_assert_equal(expected.strip, actual.strip, "Expected #{@locator} row #{row}/column #{column}") : assert_equal(expected.strip, actual.strip, "Expected #{@locator} row #{row}/column #{column} to display '#{expected}' but found '#{actual}'") end |
#verify_value(expected, enqueue = false) ⇒ Object
199 200 201 202 203 204 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 199 def verify_value(expected, enqueue = false) actual = get_value enqueue ? ExceptionQueue.enqueue_assert_equal(expected.strip, actual.strip, "Expected #{@locator}") : assert_equal(expected.strip, actual.strip, "Expected #{@locator} to display '#{expected}' but found '#{actual}'") end |
#visible? ⇒ Boolean
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 87 def visible? obj, type = find_element exists = obj invisible = false if type == :css Capybara.using_wait_time 0.1 do # is object itself hidden with .ui-helper-hidden class? self_hidden = page.has_css?("#{@locator}.ui-helper-hidden") # is parent of object hidden, thus hiding the object? parent_hidden = page.has_css?(".ui-helper-hidden > #{@locator}") # is grandparent of object, or any other ancestor, hidden? other_ancestor_hidden = page.has_css?(".ui-helper-hidden * #{@locator}") # if any of the above conditions are true, then object is invisible invisible = self_hidden || parent_hidden || other_ancestor_hidden end else invisible = !obj.visible? if exists end # the object is visible if it exists and it is not invisible (exists && !invisible) ? true : false end |
#wait_until_exists(seconds) ⇒ Object
155 156 157 158 159 160 161 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 155 def wait_until_exists(seconds) timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds wait = Selenium::WebDriver::Wait.new(timeout: timeout) wait.until { exists? } rescue raise "Could not find element #{@locator} after #{timeout} seconds" unless exists? end |
#wait_until_gone(seconds) ⇒ Object
163 164 165 166 167 168 169 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 163 def wait_until_gone(seconds) timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds wait = Selenium::WebDriver::Wait.new(timeout: timeout) wait.until { !exists? } rescue raise "Element #{@locator} remained visible after #{timeout} seconds" if exists? end |
#wait_until_value_changes(seconds) ⇒ Object
179 180 181 182 183 184 185 186 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 179 def wait_until_value_changes(seconds) value = get_value timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds wait = Selenium::WebDriver::Wait.new(timeout: timeout) wait.until { get_value != value } rescue raise "Value of UI element #{@locator} failed to change from '#{value}' after #{timeout} seconds" unless exists? end |
#wait_until_value_is(value, seconds) ⇒ Object
171 172 173 174 175 176 177 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 171 def wait_until_value_is(value, seconds) timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds wait = Selenium::WebDriver::Wait.new(timeout: timeout) wait.until { get_value == value } rescue raise "Value of UI element #{@locator} failed to equal '#{value}' after #{timeout} seconds" unless exists? end |