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-2.3.6.1 lib/testcentricity_web/elements/image.rb
testcentricity_web-2.3.6 lib/testcentricity_web/elements/image.rb
testcentricity_web-2.3.5 lib/testcentricity_web/elements/image.rb
testcentricity_web-2.3.4 lib/testcentricity_web/elements/image.rb
testcentricity_web-2.3.3 lib/testcentricity_web/elements/image.rb
testcentricity_web-2.3.2 lib/testcentricity_web/elements/image.rb
testcentricity_web-2.3.1 lib/testcentricity_web/elements/image.rb
testcentricity_web-2.3.0 lib/testcentricity_web/elements/image.rb
testcentricity_web-2.2.1 lib/testcentricity_web/elements/image.rb
testcentricity_web-2.2.0 lib/testcentricity_web/elements/image.rb
testcentricity_web-2.1.10 lib/testcentricity_web/elements/image.rb
testcentricity_web-2.1.9 lib/testcentricity_web/elements/image.rb
testcentricity_web-2.1.8.3 lib/testcentricity_web/elements/image.rb
testcentricity_web-2.1.7 lib/testcentricity_web/elements/image.rb
testcentricity_web-2.1.6 lib/testcentricity_web/elements/image.rb
testcentricity_web-2.1.5 lib/testcentricity_web/elements/image.rb
testcentricity_web-2.1.4 lib/testcentricity_web/elements/image.rb
testcentricity_web-2.1.3 lib/testcentricity_web/elements/image.rb
testcentricity_web-2.1.2 lib/testcentricity_web/elements/image.rb
testcentricity_web-2.1.1 lib/testcentricity_web/elements/image.rb