Sha256: a395e7f360dbb5c1f15a493371b71c10f8530c038345f70bb601ef9a00483193

Contents?: true

Size: 1.21 KB

Versions: 6

Compression:

Stored size: 1.21 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 WebDriver"
    end

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

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

  end # Image

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
watir-webdriver-0.9.9 lib/watir-webdriver/elements/image.rb
watir-webdriver-0.9.3 lib/watir-webdriver/elements/image.rb
watir-webdriver-0.9.2 lib/watir-webdriver/elements/image.rb
watir-webdriver-0.9.1 lib/watir-webdriver/elements/image.rb
watir-webdriver-0.9.0 lib/watir-webdriver/elements/image.rb
watir-webdriver-0.8.0 lib/watir-webdriver/elements/image.rb