Sha256: fcf95b765fbf609ef9c06c6dea62c1486aebf7898d5b0ac34f0af107d4d74acc

Contents?: true

Size: 952 Bytes

Versions: 92

Compression:

Stored size: 952 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

92 entries across 92 versions & 2 rubygems

Version Path
testcentricity_web-3.0.9 lib/testcentricity_web/web_elements/image.rb
testcentricity_web-3.0.8 lib/testcentricity_web/web_elements/image.rb
testcentricity_web-3.0.7 lib/testcentricity_web/web_elements/image.rb
testcentricity_web-3.0.6 lib/testcentricity_web/web_elements/image.rb
testcentricity_web-3.0.5 lib/testcentricity_web/web_elements/image.rb
testcentricity_web-3.0.4 lib/testcentricity_web/web_elements/image.rb
testcentricity_web-3.0.3 lib/testcentricity_web/web_elements/image.rb
testcentricity_web-3.0.2 lib/testcentricity_web/web_elements/image.rb
testcentricity_web-3.0.1 lib/testcentricity_web/web_elements/image.rb
testcentricity_web-3.0.0 lib/testcentricity_web/web_elements/image.rb
testcentricity-2.4.3 lib/testcentricity/web_elements/image.rb
testcentricity_web-2.4.3 lib/testcentricity_web/web_elements/image.rb
testcentricity-2.4.2 lib/testcentricity/web_elements/image.rb
testcentricity_web-2.4.2 lib/testcentricity_web/web_elements/image.rb
testcentricity-2.4.1 lib/testcentricity/web_elements/image.rb
testcentricity_web-2.4.1 lib/testcentricity_web/web_elements/image.rb
testcentricity-2.4.0 lib/testcentricity/web_elements/image.rb
testcentricity_web-2.4.0 lib/testcentricity_web/web_elements/image.rb
testcentricity-2.3.19 lib/testcentricity/web_elements/image.rb
testcentricity_web-2.3.19 lib/testcentricity_web/web_elements/image.rb