Sha256: c2bb409f27705278289a9cb0c9ac405e3dec4e335a4ab5185db27ceb157f4589

Contents?: true

Size: 1.2 KB

Versions: 4

Compression:

Stored size: 1.2 KB

Contents

module Watir
  class Image < HTMLElement

    #
    # Returns true if image is loaded.
    #
    # @return [Boolean]
    #

    def loaded?
      return false unless complete?

      driver.execute_script(
        'return typeof arguments[0].naturalWidth != "undefined" && arguments[0].naturalWidth > 0',
        @element
      )
    end

    #
    # Returns the image's width in pixels.
    #
    # @return [Fixnum] width
    #

    def width
      assert_exists
      driver.execute_script "return arguments[0].width", @element
    end

    #
    # Returns the image's height in pixels.
    #
    # @return [Fixnum] width
    #

    def height
      assert_exists
      driver.execute_script "return arguments[0].height", @element
    end

    def file_created_date
      assert_exists
      raise NotImplementedError, "not currently supported by Selenium"
    end

    def file_size
      assert_exists
      raise NotImplementedError, "not currently supported by Selenium"
    end

    def save(path)
      assert_exists
      raise NotImplementedError, "not currently supported by Selenium"
    end

  end # Image

  module Container
     alias_method :image, :img
     alias_method :images, :imgs
  end # Container
end # Watir

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
watir-6.0.0.beta4 lib/watir/elements/image.rb
watir-6.0.0.beta3 lib/watir/elements/image.rb
watir-6.0.0.beta2 lib/watir/elements/image.rb
watir-6.0.0.beta1 lib/watir/elements/image.rb