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
Is checkbox checked?.
-
#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.
- #clear_alt_locator ⇒ Object
-
#click ⇒ Object
Click on an object.
-
#click_at(x, y) ⇒ Object
Click at a specific location within an an object.
- #click_header_column(column) ⇒ Object
-
#click_table_cell(row, column) ⇒ Object
Click in the specified cell in a table object.
-
#click_table_cell_link(row, column) ⇒ Object
Click the link object embedded within the specified cell in a table object.
- #collapse_table_row(row, column) ⇒ Object
-
#disabled? ⇒ Boolean
Is UI object disabled (not enabled)?.
-
#double_click ⇒ Object
Double-click on an object.
-
#double_click_table_cell(row, column) ⇒ Object
Double-click in the specified cell in a table object.
- #drag_by(right_offset, down_offset) ⇒ Object
-
#enabled? ⇒ Boolean
Is UI object enabled?.
-
#exists? ⇒ Boolean
Does UI object exists?.
- #expand_all_table_rows(column) ⇒ Object
- #expand_table_row(row, column) ⇒ Object
-
#get_column_count ⇒ Integer
Return number of columns in a table object.
- #get_header_column(column) ⇒ Object
- #get_header_columns ⇒ Object
- #get_list_items(item_locator) ⇒ Object
- #get_locator ⇒ Object
-
#get_max_length ⇒ Integer
Return maxlength character count of a text field.
-
#get_options ⇒ Array
Return array of strings of all options in a select box object.
-
#get_row_count ⇒ Integer
Return number of rows in a table object.
- #get_row_data(row) ⇒ Object
-
#get_selected_option ⇒ String
Return text of first selected option in a select box object.
- #get_siebel_object_type ⇒ Object
-
#get_siebel_options ⇒ Array
Return array of strings of all options in a Siebel OUI select box object.
-
#get_table_cell(row, column) ⇒ String
Return text contained in specified cell of a table object.
- #get_table_row(row) ⇒ Object
- #get_value ⇒ Object
-
#hidden? ⇒ Boolean
Is UI object hidden (not visible)?.
-
#hover ⇒ Object
Hover the cursor over an 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
Is text field set to read-only?.
-
#send_keys(*keys) ⇒ Object
comment_field.send_keys(:enter).
- #set(value) ⇒ Object
- #set_alt_locator(temp_locator) ⇒ Object
-
#set_checkbox_state(state) ⇒ Object
Set the check state of a checkbox object.
-
#set_siebel_checkbox_state(state) ⇒ Object
Set the check state of a Siebel OUI JCheckBox object.
-
#set_table_cell(row, column, value) ⇒ Object
Set the value of the specified cell in a table object.
- #verify_check_state(state, enqueue = false) ⇒ Object
- #verify_options(expected, 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
Is UI object visible?.
-
#wait_until_exists(seconds) ⇒ Object
Wait until the object exists, or until the specified wait time has expired.
-
#wait_until_gone(seconds) ⇒ Object
Wait until the object no longer exists, or until the specified wait time has expired.
-
#wait_until_value_changes(seconds) ⇒ Object
Wait until the object's value changes to a different value, or until the specified wait time has expired.
-
#wait_until_value_is(value, seconds) ⇒ Object
Wait until the object's value equals the specified value, or until the specified wait time has expired.
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
324 325 326 327 328 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 324 def attach_file(file_path) Capybara.ignore_hidden_elements = false page.attach_file(@locator, file_path) Capybara.ignore_hidden_elements = true end |
#checked? ⇒ Boolean
Is checkbox checked?
206 207 208 209 210 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 206 def checked? obj, _ = find_element object_not_found_exception(obj, 'Checkbox') obj.checked? end |
#choose_option(option) ⇒ Object
Select the specified option in a select box object. Supports standard HTML select objects and Chosen select objects.
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 337 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
Select the specified option in a Siebel OUI select box object.
23 24 25 26 27 |
# File 'lib/testcentricity_web/siebel_open_ui_helper.rb', line 23 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
Click on an object
53 54 55 56 57 58 59 60 61 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 53 def click obj, _ = find_element object_not_found_exception(obj, nil) begin obj.click rescue obj.click_at(10, 10) unless Capybara.current_driver == :poltergeist end end |
#click_at(x, y) ⇒ Object
Click at a specific location within an an object
81 82 83 84 85 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 81 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
584 585 586 587 588 589 590 591 592 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 584 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
Click in the specified cell in a table object.
437 438 439 440 441 442 443 444 445 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 437 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
Click the link object embedded within the specified cell in a table object.
471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 471 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
82 83 84 85 86 87 88 89 |
# File 'lib/testcentricity_web/siebel_open_ui_helper.rb', line 82 def collapse_table_row(row, column) if (row, column) set_table_cell_locator(row, column) set_alt_locator("#{@alt_locator}/div/div[contains(@class, 'tree-minus treeclick')]") click if exists? clear_alt_locator end end |
#disabled? ⇒ Boolean
Is UI object disabled (not enabled)?
170 171 172 173 174 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 170 def disabled? obj, _ = find_element object_not_found_exception(obj, nil) obj.disabled? end |
#double_click ⇒ Object
Double-click on an object
68 69 70 71 72 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 68 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
Double-click in the specified cell in a table object.
454 455 456 457 458 459 460 461 462 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 454 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
318 319 320 321 322 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 318 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
Is UI object enabled?
160 161 162 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 160 def enabled? not disabled? end |
#exists? ⇒ Boolean
Does UI object exists?
111 112 113 114 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 111 def exists? obj, _ = find_element obj != nil end |
#expand_all_table_rows(column) ⇒ Object
91 92 93 94 95 96 97 98 |
# File 'lib/testcentricity_web/siebel_open_ui_helper.rb', line 91 def (column) row_count = get_row_count column_count = get_column_count raise "Column #{column} exceeds number of columns (#{column_count}) in table #{@locator}" if column > column_count row_count.downto(1) do |row| (row, column) end end |
#expand_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 (row, column) unless (row, column) set_table_cell_locator(row, column) set_alt_locator("#{@alt_locator}/div/div[contains(@class, 'tree-plus treeclick')]") click if exists? clear_alt_locator end end |
#get_column_count ⇒ Integer
Return number of columns in a table object.
419 420 421 422 423 424 425 426 427 428 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 419 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
594 595 596 597 598 599 600 601 602 603 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 594 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
605 606 607 608 609 610 611 612 613 614 615 616 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 605 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
618 619 620 621 622 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 618 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 ⇒ Integer
Return maxlength character count of a text field.
194 195 196 197 198 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 194 def get_max_length obj, _ = find_element object_not_found_exception(obj, nil) obj.native.attribute('maxlength') end |
#get_options ⇒ Array
Return array of strings of all options in a select box object. Supports standard HTML select objects and Chosen select objects.
367 368 369 370 371 372 373 374 375 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 367 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('option').collect(&:text) end end |
#get_row_count ⇒ Integer
Return number of rows in a table object.
407 408 409 410 411 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 407 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
517 518 519 520 521 522 523 524 525 526 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 517 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 ⇒ String
Return text of first selected option in a select box object. Supports standard HTML select objects and Chosen select objects.
391 392 393 394 395 396 397 398 399 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 391 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('option[selected]').text end end |
#get_siebel_object_type ⇒ Object
100 101 102 103 104 |
# File 'lib/testcentricity_web/siebel_open_ui_helper.rb', line 100 def get_siebel_object_type obj, _ = find_element object_not_found_exception(obj, 'Siebel object') obj.native.attribute('ot') end |
#get_siebel_options ⇒ Array
Return array of strings of all options in a Siebel OUI select box object.
35 36 37 38 39 40 41 42 |
# File 'lib/testcentricity_web/siebel_open_ui_helper.rb', line 35 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) ⇒ String
Return text contained in specified cell of a table object.
536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 536 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
494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 494 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
289 290 291 292 293 294 295 296 297 298 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 289 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
Is UI object hidden (not visible)?
150 151 152 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 150 def hidden? not visible? end |
#hover ⇒ Object
Hover the cursor over an object
312 313 314 315 316 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 312 def hover obj, _ = find_element object_not_found_exception(obj, nil) obj.hover end |
#invoke_siebel_dialog(popup) ⇒ Object
55 56 57 58 |
# File 'lib/testcentricity_web/siebel_open_ui_helper.rb', line 55 def invoke_siebel_dialog(popup) invoke_siebel_popup popup.wait_until_exists(15) end |
#is_table_row_expanded?(row, column) ⇒ Boolean
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/testcentricity_web/siebel_open_ui_helper.rb', line 60 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) set_alt_locator("#{@alt_locator}/div/div[contains(@class, 'tree-plus treeclick')]") = true = false if exists? clear_alt_locator end |
#read_only? ⇒ Boolean
Is text field set to read-only?
182 183 184 185 186 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 182 def read_only? obj, _ = find_element object_not_found_exception(obj, nil) !!obj.native.attribute('readonly') end |
#send_keys(*keys) ⇒ Object
comment_field.send_keys(:enter)
99 100 101 102 103 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 99 def send_keys(*keys) obj, _ = find_element object_not_found_exception(obj, nil) obj.send_keys(*keys) end |
#set(value) ⇒ Object
87 88 89 90 91 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 87 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
Set the check state of a checkbox object.
218 219 220 221 222 223 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 218 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
Set the check state of a Siebel OUI JCheckBox object.
9 10 11 12 13 14 15 |
# File 'lib/testcentricity_web/siebel_open_ui_helper.rb', line 9 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
Set the value of the specified cell in a table object.
570 571 572 573 574 575 576 577 578 579 580 581 582 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 570 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
225 226 227 228 229 230 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 225 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_options(expected, enqueue = false) ⇒ Object
377 378 379 380 381 382 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 377 def (expected, enqueue = false) actual = 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}") end |
#verify_siebel_options(expected, enqueue = false) ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/testcentricity_web/siebel_open_ui_helper.rb', line 44 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
555 556 557 558 559 560 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 555 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
300 301 302 303 304 305 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 300 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
Is UI object visible?
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 122 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
Wait until the object exists, or until the specified wait time has expired.
238 239 240 241 242 243 244 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 238 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
Wait until the object no longer exists, or until the specified wait time has expired.
252 253 254 255 256 257 258 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 252 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
Wait until the object's value changes to a different value, or until the specified wait time has expired.
280 281 282 283 284 285 286 287 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 280 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
Wait until the object's value equals the specified value, or until the specified wait time has expired.
266 267 268 269 270 271 272 |
# File 'lib/testcentricity_web/ui_elements_helper.rb', line 266 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 |