Sha256: cab7b1e95a933868ee76e1ff03586a91071d564a5fff9bd25ef3f9fbc4a44684

Contents?: true

Size: 954 Bytes

Versions: 4

Compression:

Stored size: 954 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_ref_message} failed to load within #{timeout} seconds" unless is_loaded?
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
testcentricity_web-1.0.16 lib/testcentricity_web/elements/image.rb
testcentricity_web-1.0.15 lib/testcentricity_web/elements/image.rb
testcentricity_web-1.0.14 lib/testcentricity_web/elements/image.rb
testcentricity_web-1.0.13 lib/testcentricity_web/elements/image.rb