Class: TestCentricity::UIElement
- Includes:
- Capybara::DSL, Test::Unit::Assertions
- Defined in:
- lib/testcentricity_web/web_elements/ui_elements_helper.rb,
lib/testcentricity_web/web_elements/siebel_open_ui_helper.rb
Direct Known Subclasses
Audio, Button, CellElement, CheckBox, FileField, Image, Label, Link, List, ListElement, Radio, SelectList, Table, TextField, Video
Constant Summary collapse
- XPATH_SELECTORS =
['//', '[@', '[contains('].freeze
- CSS_SELECTORS =
['#', ':nth-child(', ':first-child', ':last-child', ':nth-of-type(', ':first-of-type', ':last-of-type', '^=', '$=', '*=', ':contains('].freeze
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.
-
#locator_type ⇒ Object
Returns the value of attribute locator_type.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#original_style ⇒ Object
Returns the value of attribute original_style.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#aria_checked? ⇒ Boolean
Return state of UI object's aria-checked property.
-
#aria_colcount ⇒ Integer
Return state of UI object's aria-colcount property.
-
#aria_describedby ⇒ String
Return state of UI object's aria-describedby property.
-
#aria_disabled? ⇒ Boolean
Return state of UI object's aria-disabled property.
-
#aria_expanded? ⇒ Boolean
Return state of UI object's aria-expanded property.
-
#aria_haspopup? ⇒ Boolean
Return state of UI object's aria-haspopup property.
-
#aria_hidden? ⇒ Boolean
Return state of UI object's aria-hidden property.
-
#aria_invalid? ⇒ Boolean
Return state of UI object's aria-invalid property.
-
#aria_label ⇒ String
Return state of UI object's aria-label property.
-
#aria_labelledby ⇒ String
Return state of UI object's aria-labelledby property.
-
#aria_live ⇒ String
Return state of UI object's aria-live property.
-
#aria_pressed? ⇒ Boolean
Return state of UI object's aria-pressed property.
-
#aria_readonly? ⇒ Boolean
Return state of UI object's aria-readonly property.
-
#aria_required? ⇒ Boolean
Return state of UI object's aria-required property.
-
#aria_rowcount ⇒ Integer
Return state of UI object's aria-rowcount property.
-
#aria_selected? ⇒ Boolean
Return state of UI object's aria-selected property.
-
#aria_sort ⇒ String
Return state of UI object's aria-sort property.
- #clear_alt_locator ⇒ Object
-
#click ⇒ Object
Click on an object.
-
#click_at(x, y) ⇒ Object
Click at a specific location within an object.
-
#count(visible = true) ⇒ Object
Return the number of occurrences of an object with an ambiguous locator that evaluates to multiple UI elements.
-
#disabled? ⇒ Boolean
Is UI object disabled (not enabled)?.
-
#displayed? ⇒ Boolean
Is UI object displayed in browser window?.
-
#double_click ⇒ Object
Double-click on an object.
- #drag_and_drop(target, right_offset = nil, down_offset = nil) ⇒ Object
- #drag_by(right_offset, down_offset) ⇒ Object
-
#enabled? ⇒ Boolean
Is UI object enabled?.
-
#exists?(visible = true) ⇒ Boolean
Does UI object exists?.
- #get_attribute(attrib) ⇒ Object
- #get_locator ⇒ Object
- #get_locator_type ⇒ Object
- #get_name ⇒ Object
- #get_native_attribute(attrib) ⇒ Object
- #get_object_type ⇒ Object
- #get_siebel_object_type ⇒ Object
- #get_value(visible = true) ⇒ Object (also: #get_caption)
-
#height ⇒ Integer
Return height of object.
-
#hidden? ⇒ Boolean
Is UI object hidden (not visible)?.
-
#highlight(duration = 1) ⇒ Object
Highlight an object with a 3 pixel wide, red dashed border for the specified wait time.
-
#hover ⇒ Object
Hover the cursor over an object.
-
#hover_at(x, y) ⇒ Object
Hover at a specific location within an object.
-
#initialize(name, parent, locator, context) ⇒ UIElement
constructor
A new instance of UIElement.
- #invoke_siebel_dialog(popup, seconds = nil) ⇒ Object
-
#right_click ⇒ Object
Right-click on an object.
-
#role ⇒ String
Return state of UI object's role property.
-
#send_keys(*keys) ⇒ Object
Send keystrokes to this object.
- #set(value) ⇒ Object
- #set_alt_locator(temp_locator) ⇒ Object
- #set_locator_type(locator = nil) ⇒ Object
-
#style ⇒ String
Return UI object's style property.
-
#tabindex ⇒ String
Return state of UI object's tabindex property.
-
#title ⇒ String
Return UI object's title property.
-
#unhighlight ⇒ Object
Restore a highlighted object's original style.
- #verify_value(expected, enqueue = false) ⇒ Object (also: #verify_caption)
-
#visible? ⇒ Boolean
Is UI object visible?.
-
#wait_until_exists(seconds = nil, post_exception = true) ⇒ Object
Wait until the object exists, or until the specified wait time has expired.
-
#wait_until_gone(seconds = nil, post_exception = true) ⇒ Object
Wait until the object no longer exists, or until the specified wait time has expired.
-
#wait_until_hidden(seconds = nil, post_exception = true) ⇒ Object
Wait until the object is hidden, or until the specified wait time has expired.
-
#wait_until_value_changes(seconds = nil, post_exception = true) ⇒ 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 = nil, post_exception = true) ⇒ Object
Wait until the object's value equals the specified value, or until the specified wait time has expired.
-
#wait_until_visible(seconds = nil, post_exception = true) ⇒ Object
Wait until the object is visible, or until the specified wait time has expired.
-
#width ⇒ Integer
Return width of object.
-
#x ⇒ Integer
Return x coordinate of object's location.
-
#y ⇒ Integer
Return y coordinate of object's location.
Constructor Details
#initialize(name, parent, locator, context) ⇒ UIElement
Returns a new instance of UIElement.
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 51 def initialize(name, parent, locator, context) @name = name @parent = parent @locator = locator @context = context @type = nil @alt_locator = nil @original_style = nil set_locator_type end |
Instance Attribute Details
#alt_locator ⇒ Object
Returns the value of attribute alt_locator.
46 47 48 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 46 def alt_locator @alt_locator end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
45 46 47 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 45 def context @context end |
#locator ⇒ Object (readonly)
Returns the value of attribute locator.
45 46 47 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 45 def locator @locator end |
#locator_type ⇒ Object
Returns the value of attribute locator_type.
46 47 48 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 46 def locator_type @locator_type end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
45 46 47 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 45 def name @name end |
#original_style ⇒ Object
Returns the value of attribute original_style.
46 47 48 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 46 def original_style @original_style end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
45 46 47 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 45 def parent @parent end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
45 46 47 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 45 def type @type end |
Instance Method Details
#aria_checked? ⇒ Boolean
Return state of UI object's aria-checked property
741 742 743 744 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 741 def aria_checked? state = get_attribute('aria-checked') state.boolean? ? state : state == 'true' end |
#aria_colcount ⇒ Integer
Return state of UI object's aria-colcount property
665 666 667 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 665 def aria_colcount get_attribute('aria-colcount') end |
#aria_describedby ⇒ String
Return state of UI object's aria-describedby property
625 626 627 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 625 def aria_describedby get_attribute('aria-describedby') end |
#aria_disabled? ⇒ Boolean
Return state of UI object's aria-disabled property
675 676 677 678 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 675 def aria_disabled? state = get_attribute('aria-disabled') state.boolean? ? state : state == 'true' end |
#aria_expanded? ⇒ Boolean
Return state of UI object's aria-expanded property
708 709 710 711 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 708 def state = get_attribute('aria-expanded') state.boolean? ? state : state == 'true' end |
#aria_haspopup? ⇒ Boolean
Return state of UI object's aria-haspopup property
752 753 754 755 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 752 def aria_haspopup? state = get_attribute('aria-haspopup') state.boolean? ? state : state == 'true' end |
#aria_hidden? ⇒ Boolean
Return state of UI object's aria-hidden property
697 698 699 700 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 697 def aria_hidden? state = get_attribute('aria-hidden') state.boolean? ? state : state == 'true' end |
#aria_invalid? ⇒ Boolean
Return state of UI object's aria-invalid property
730 731 732 733 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 730 def aria_invalid? state = get_attribute('aria-invalid') state.boolean? ? state : state == 'true' end |
#aria_label ⇒ String
Return state of UI object's aria-label property
605 606 607 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 605 def aria_label get_attribute('aria-label') end |
#aria_labelledby ⇒ String
Return state of UI object's aria-labelledby property
615 616 617 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 615 def aria_labelledby get_attribute('aria-labelledby') end |
#aria_live ⇒ String
Return state of UI object's aria-live property
635 636 637 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 635 def aria_live get_attribute('aria-live') end |
#aria_pressed? ⇒ Boolean
Return state of UI object's aria-pressed property
763 764 765 766 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 763 def aria_pressed? state = get_attribute('aria-pressed') state.boolean? ? state : state == 'true' end |
#aria_readonly? ⇒ Boolean
Return state of UI object's aria-readonly property
774 775 776 777 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 774 def aria_readonly? state = get_attribute('aria-readonly') state.boolean? ? state : state == 'true' end |
#aria_required? ⇒ Boolean
Return state of UI object's aria-required property
719 720 721 722 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 719 def aria_required? state = get_attribute('aria-required') state.boolean? ? state : state == 'true' end |
#aria_rowcount ⇒ Integer
Return state of UI object's aria-rowcount property
655 656 657 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 655 def aria_rowcount get_attribute('aria-rowcount') end |
#aria_selected? ⇒ Boolean
Return state of UI object's aria-selected property
686 687 688 689 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 686 def aria_selected? state = get_attribute('aria-selected') state.boolean? ? state : state == 'true' end |
#aria_sort ⇒ String
Return state of UI object's aria-sort property
645 646 647 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 645 def aria_sort get_attribute('aria-sort') end |
#clear_alt_locator ⇒ Object
107 108 109 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 107 def clear_alt_locator @alt_locator = nil end |
#click ⇒ Object
Click on an object
116 117 118 119 120 121 122 123 124 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 116 def click obj, type = find_element object_not_found_exception(obj, type) begin obj.click rescue StandardError obj.click_at(10, 10) unless Capybara.current_driver == :poltergeist end end |
#click_at(x, y) ⇒ Object
Click at a specific location within an object
155 156 157 158 159 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 155 def click_at(x, y) obj, = find_element raise "UI #{} not found" unless obj obj.click_at(x, y) end |
#count(visible = true) ⇒ Object
Return the number of occurrences of an object with an ambiguous locator that evaluates to multiple UI elements.
383 384 385 386 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 383 def count(visible = true) obj_locator = @alt_locator.nil? ? @locator : @alt_locator page.all(@locator_type, obj_locator, wait: 0.01, visible: visible, minimum: 0).count end |
#disabled? ⇒ Boolean
Is UI object disabled (not enabled)?
248 249 250 251 252 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 248 def disabled? obj, type = find_element object_not_found_exception(obj, type) obj.disabled? end |
#displayed? ⇒ Boolean
Is UI object displayed in browser window?
452 453 454 455 456 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 452 def displayed? obj, type = find_element(false) object_not_found_exception(obj, type) obj.displayed? end |
#double_click ⇒ Object
Double-click on an object
131 132 133 134 135 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 131 def double_click obj, type = find_element object_not_found_exception(obj, type) page.driver.browser.action.double_click(obj.native).perform end |
#drag_and_drop(target, right_offset = nil, down_offset = nil) ⇒ Object
512 513 514 515 516 517 518 519 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 512 def drag_and_drop(target, right_offset = nil, down_offset = nil) source, type = find_element object_not_found_exception(source, type) page.driver.browser.action.click_and_hold(source.native).perform sleep(1) target_drop, = target.find_element page.driver.browser.action.move_to(target_drop.native, right_offset.to_i, down_offset.to_i).release.perform end |
#drag_by(right_offset, down_offset) ⇒ Object
504 505 506 507 508 509 510 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 504 def drag_by(right_offset, down_offset) obj, type = find_element object_not_found_exception(obj, type) page.driver.browser.action.click_and_hold(obj.native).perform sleep(1) obj.drag_by(right_offset, down_offset) end |
#enabled? ⇒ Boolean
Is UI object enabled?
238 239 240 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 238 def enabled? !disabled? end |
#exists?(visible = true) ⇒ Boolean
Does UI object exists?
185 186 187 188 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 185 def exists?(visible = true) obj, = find_object(visible) obj != nil end |
#get_attribute(attrib) ⇒ Object
779 780 781 782 783 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 779 def get_attribute(attrib) obj, type = find_element(false) object_not_found_exception(obj, type) obj[attrib] end |
#get_locator ⇒ Object
95 96 97 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 95 def get_locator @locator end |
#get_locator_type ⇒ Object
77 78 79 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 77 def get_locator_type @locator_type end |
#get_name ⇒ Object
99 100 101 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 99 def get_name @name end |
#get_native_attribute(attrib) ⇒ Object
785 786 787 788 789 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 785 def get_native_attribute(attrib) obj, type = find_element(false) object_not_found_exception(obj, type) obj.native.attribute(attrib) end |
#get_object_type ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 81 def get_object_type if @type @type else obj, type = find_element object_not_found_exception(obj, type) if obj.tag_name obj.tag_name elsif obj.native.attribute('type') obj.native.attribute('type') end end end |
#get_siebel_object_type ⇒ Object
9 10 11 12 13 |
# File 'lib/testcentricity_web/web_elements/siebel_open_ui_helper.rb', line 9 def get_siebel_object_type obj, = find_element object_not_found_exception(obj, 'Siebel object') obj.native.attribute('ot') end |
#get_value(visible = true) ⇒ Object Also known as:
458 459 460 461 462 463 464 465 466 467 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 458 def get_value(visible = true) obj, type = find_element(visible) object_not_found_exception(obj, type) case obj.tag_name.downcase when 'input', 'select', 'textarea' obj.value else obj.text end end |
#height ⇒ Integer
Return height of object.
406 407 408 409 410 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 406 def height obj, type = find_element(false) object_not_found_exception(obj, type) obj.get_height end |
#hidden? ⇒ Boolean
Is UI object hidden (not visible)?
228 229 230 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 228 def hidden? !visible? end |
#highlight(duration = 1) ⇒ Object
Highlight an object with a 3 pixel wide, red dashed border for the specified wait time. If wait time is zero, then the highlight will remain until the page is refreshed
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 528 def highlight(duration = 1) obj, type = find_element object_not_found_exception(obj, type) # store original style so it can be reset later @original_style = obj.native.attribute('style') # style element with red border page.execute_script( 'arguments[0].setAttribute(arguments[1], arguments[2])', obj, 'style', 'border: 3px solid red; border-style: dashed;' ) # keep element highlighted for duration and then revert to original style if duration.positive? sleep duration page.execute_script( 'arguments[0].setAttribute(arguments[1], arguments[2])', obj, 'style', @original_style ) end end |
#hover ⇒ Object
Hover the cursor over an object
485 486 487 488 489 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 485 def hover obj, type = find_element object_not_found_exception(obj, type) obj.hover end |
#hover_at(x, y) ⇒ Object
Hover at a specific location within an object
498 499 500 501 502 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 498 def hover_at(x, y) obj, = find_element raise "UI #{} not found" unless obj obj.hover_at(x, y) end |
#invoke_siebel_dialog(popup, seconds = nil) ⇒ Object
3 4 5 6 7 |
# File 'lib/testcentricity_web/web_elements/siebel_open_ui_helper.rb', line 3 def invoke_siebel_dialog(popup, seconds = nil) invoke_siebel_popup timeout = seconds.nil? ? 15 : seconds popup.wait_until_exists(timeout) end |
#right_click ⇒ Object
Right-click on an object
142 143 144 145 146 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 142 def right_click obj, type = find_element object_not_found_exception(obj, type) page.driver.browser.action.context_click(obj.native).perform end |
#role ⇒ String
Return state of UI object's role property
585 586 587 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 585 def role get_attribute('role') end |
#send_keys(*keys) ⇒ Object
Send keystrokes to this object.
173 174 175 176 177 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 173 def send_keys(*keys) obj, type = find_element object_not_found_exception(obj, type) obj.send_keys(*keys) end |
#set(value) ⇒ Object
161 162 163 164 165 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 161 def set(value) obj, type = find_element object_not_found_exception(obj, type) obj.set(value) end |
#set_alt_locator(temp_locator) ⇒ Object
103 104 105 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 103 def set_alt_locator(temp_locator) @alt_locator = temp_locator end |
#set_locator_type(locator = nil) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 62 def set_locator_type(locator = nil) locator = @locator if locator.nil? is_xpath = XPATH_SELECTORS.any? { |selector| locator.include?(selector) } is_css = CSS_SELECTORS.any? { |selector| locator.include?(selector) } @locator_type = if is_xpath && !is_css :xpath elsif is_css && !is_xpath :css elsif !is_css && !is_xpath :css else :css end end |
#style ⇒ String
Return UI object's style property
575 576 577 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 575 def style get_attribute('style') end |
#tabindex ⇒ String
Return state of UI object's tabindex property
595 596 597 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 595 def tabindex get_attribute('tabindex') end |
#title ⇒ String
Return UI object's title property
442 443 444 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 442 def title get_attribute(:title) end |
#unhighlight ⇒ Object
Restore a highlighted object's original style
557 558 559 560 561 562 563 564 565 566 567 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 557 def unhighlight obj, type = find_element object_not_found_exception(obj, type) return if @original_style.nil? page.execute_script( 'arguments[0].setAttribute(arguments[1], arguments[2])', obj, 'style', @original_style ) end |
#verify_value(expected, enqueue = false) ⇒ Object Also known as:
471 472 473 474 475 476 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 471 def verify_value(expected, enqueue = false) actual = get_value enqueue ? ExceptionQueue.enqueue_assert_equal(expected.strip, actual.strip, "Expected UI #{}") : assert_equal(expected.strip, actual.strip, "Expected UI #{} to display '#{expected}' but found '#{actual}'") end |
#visible? ⇒ Boolean
Is UI object visible?
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 196 def visible? obj, type = find_object 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 if exists && !invisible true else false end end |
#wait_until_exists(seconds = nil, post_exception = true) ⇒ Object
Wait until the object exists, or until the specified wait time has expired. If the wait time is nil, then the wait time will be Capybara.default_max_wait_time.
261 262 263 264 265 266 267 268 269 270 271 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 261 def wait_until_exists(seconds = nil, post_exception = true) timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds wait = Selenium::WebDriver::Wait.new(timeout: timeout) wait.until { exists? } rescue StandardError if post_exception raise "Could not find UI #{} after #{timeout} seconds" unless exists? else exists? end end |
#wait_until_gone(seconds = nil, post_exception = true) ⇒ Object
Wait until the object no longer exists, or until the specified wait time has expired. If the wait time is nil, then the wait time will be Capybara.default_max_wait_time.
280 281 282 283 284 285 286 287 288 289 290 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 280 def wait_until_gone(seconds = nil, post_exception = true) timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds wait = Selenium::WebDriver::Wait.new(timeout: timeout) wait.until { !exists? } rescue StandardError if post_exception raise "UI #{} remained visible after #{timeout} seconds" if exists? else exists? end end |
#wait_until_hidden(seconds = nil, post_exception = true) ⇒ Object
Wait until the object is hidden, or until the specified wait time has expired. If the wait time is nil, then the wait time will be Capybara.default_max_wait_time.
318 319 320 321 322 323 324 325 326 327 328 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 318 def wait_until_hidden(seconds = nil, post_exception = true) timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds wait = Selenium::WebDriver::Wait.new(timeout: timeout) wait.until { hidden? } rescue StandardError if post_exception raise "UI #{} remained visible after #{timeout} seconds" if visible? else visible? end end |
#wait_until_value_changes(seconds = nil, post_exception = true) ⇒ Object
Wait until the object's value changes to a different value, or until the specified wait time has expired. If the wait time is nil, then the wait time will be Capybara.default_max_wait_time.
359 360 361 362 363 364 365 366 367 368 369 370 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 359 def wait_until_value_changes(seconds = nil, post_exception = true) 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 StandardError if post_exception raise "Value of UI #{} failed to change from '#{value}' after #{timeout} seconds" if get_value == value else get_value == value end end |
#wait_until_value_is(value, seconds = nil, post_exception = true) ⇒ Object
Wait until the object's value equals the specified value, or until the specified wait time has expired. If the wait time is nil, then the wait time will be Capybara.default_max_wait_time.
340 341 342 343 344 345 346 347 348 349 350 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 340 def wait_until_value_is(value, seconds = nil, post_exception = true) timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds wait = Selenium::WebDriver::Wait.new(timeout: timeout) wait.until { compare(value, get_value) } rescue StandardError if post_exception raise "Value of UI #{} failed to equal '#{value}' after #{timeout} seconds" unless get_value == value else get_value == value end end |
#wait_until_visible(seconds = nil, post_exception = true) ⇒ Object
Wait until the object is visible, or until the specified wait time has expired. If the wait time is nil, then the wait time will be Capybara.default_max_wait_time.
299 300 301 302 303 304 305 306 307 308 309 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 299 def wait_until_visible(seconds = nil, post_exception = true) timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds wait = Selenium::WebDriver::Wait.new(timeout: timeout) wait.until { visible? } rescue StandardError if post_exception raise "Could not find UI #{} after #{timeout} seconds" unless visible? else visible? end end |
#width ⇒ Integer
Return width of object.
394 395 396 397 398 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 394 def width obj, type = find_element(false) object_not_found_exception(obj, type) obj.get_width end |
#x ⇒ Integer
Return x coordinate of object's location.
418 419 420 421 422 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 418 def x obj, type = find_element(false) object_not_found_exception(obj, type) obj.get_x end |
#y ⇒ Integer
Return y coordinate of object's location.
430 431 432 433 434 |
# File 'lib/testcentricity_web/web_elements/ui_elements_helper.rb', line 430 def y obj, type = find_element(false) object_not_found_exception(obj, type) obj.get_y end |