Class: TestCentricity::Image

Inherits:
UIElement show all
Defined in:
lib/testcentricity_web/web_elements/image.rb

Constant Summary

Constants inherited from UIElement

UIElement::CSS_SELECTORS, UIElement::XPATH_SELECTORS

Instance Attribute Summary

Attributes inherited from UIElement

#alt_locator, #context, #locator, #locator_type, #name, #parent, #type

Instance Method Summary collapse

Methods inherited from UIElement

#clear_alt_locator, #click, #click_at, #disabled?, #displayed?, #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, #height, #hidden?, #hover, #invoke_siebel_dialog, #right_click, #send_keys, #set, #set_alt_locator, #set_locator_type, #verify_value, #visible?, #wait_until_exists, #wait_until_gone, #wait_until_hidden, #wait_until_value_changes, #wait_until_value_is, #wait_until_visible, #width, #x, #y

Constructor Details

#initialize(name, parent, locator, context) ⇒ Image

Returns a new instance of Image.



3
4
5
6
# File 'lib/testcentricity_web/web_elements/image.rb', line 3

def initialize(name, parent, locator, context)
  super
  @type = :image
end

Instance Method Details

#is_loaded?Boolean

Is image loaded?

Examples:

company_logo_image.is_loaded??

Returns:

  • (Boolean)


14
15
16
17
18
# File 'lib/testcentricity_web/web_elements/image.rb', line 14

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.

Examples:

company_logo_image.wait_until_loaded(5)

Parameters:

  • seconds (Integer or Float) (defaults to: nil)

    wait time in seconds



26
27
28
29
30
31
32
# File 'lib/testcentricity_web/web_elements/image.rb', line 26

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 #{object_ref_message} failed to load within #{timeout} seconds" unless is_loaded?
end