Class: TestCentricity::Image
- Defined in:
- lib/testcentricity_web/elements/image.rb
Instance Attribute Summary
Attributes inherited from UIElement
#alt_locator, #context, #locator, #parent, #type
Instance Method Summary collapse
-
#initialize(parent, locator, context) ⇒ Image
constructor
A new instance of Image.
-
#is_loaded? ⇒ Boolean
Is image loaded?.
-
#wait_until_loaded(seconds = nil) ⇒ Object
Wait until the image is fully loaded, or until the specified wait time has expired.
Methods inherited from UIElement
#clear_alt_locator, #click, #click_at, #disabled?, #double_click, #drag_by, #enabled?, #exists?, #get_attribute, #get_list_items, #get_locator, #get_native_attribute, #get_object_type, #get_siebel_object_type, #get_value, #hidden?, #hover, #invoke_siebel_dialog, #send_keys, #set, #set_alt_locator, #verify_value, #visible?, #wait_until_exists, #wait_until_gone, #wait_until_value_changes, #wait_until_value_is, #wait_until_visible
Constructor Details
#initialize(parent, locator, context) ⇒ Image
Returns a new instance of Image.
3 4 5 6 7 8 9 |
# File 'lib/testcentricity_web/elements/image.rb', line 3 def initialize(parent, locator, context) @parent = parent @locator = locator @context = context @type = :image @alt_locator = nil end |
Instance Method Details
#is_loaded? ⇒ Boolean
Is image loaded?
17 18 19 20 21 |
# File 'lib/testcentricity_web/elements/image.rb', line 17 def is_loaded? obj, _ = find_element object_not_found_exception(obj, nil) obj.native.attribute('complete') end |
#wait_until_loaded(seconds = nil) ⇒ Object
Wait until the image is fully loaded, or until the specified wait time has expired.
29 30 31 32 33 34 35 |
# File 'lib/testcentricity_web/elements/image.rb', line 29 def wait_until_loaded(seconds = nil) timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds wait = Selenium::WebDriver::Wait.new(timeout: timeout) wait.until { is_loaded? } rescue raise "Image #{@locator} failed to load within #{timeout} seconds" unless is_loaded? end |