Sha256: 52e7d2e9a595443430646edd50bbc67f533495b164e7c1ca7511ca018cbd1731

Contents?: true

Size: 970 Bytes

Versions: 2

Compression:

Stored size: 970 Bytes

Contents

module TestCentricity
  class Image < UIElement
    def initialize(name, parent, locator, context)
      super
      @type = :image
    end

    # Is image loaded?
    #
    # @return [Boolean]
    # @example
    #   company_logo_image.is_loaded??
    #
    def is_loaded?
      obj, _ = find_element
      object_not_found_exception(obj, nil)
      obj.native.attribute('complete')
    end

    # Wait until the image is fully loaded, or until the specified wait time has expired.
    #
    # @param seconds [Integer or Float] wait time in seconds
    # @example
    #   company_logo_image.wait_until_loaded(5)
    #
    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 '#{get_name}' (#{get_locator}) failed to load within #{timeout} seconds" unless is_loaded?
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
testcentricity_web-1.0.12 lib/testcentricity_web/elements/image.rb
testcentricity_web-1.0.11 lib/testcentricity_web/elements/image.rb