Sha256: 3d694676d71fdd8e9cbfca99c4e4ea1183ca2e3a078f77cd3d33ebb79054d980

Contents?: true

Size: 1.15 KB

Versions: 11

Compression:

Stored size: 1.15 KB

Contents

# encoding: utf-8
module Watir
  class Image < HTMLElement

    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 [Integer] width
    #

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

    #
    # returns the image's height in pixels
    #
    # @return [Integer] height
    #

    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

11 entries across 11 versions & 1 rubygems

Version Path
watir-webdriver-0.6.1 lib/watir-webdriver/elements/image.rb
watir-webdriver-0.6.0 lib/watir-webdriver/elements/image.rb
watir-webdriver-0.5.8 lib/watir-webdriver/elements/image.rb
watir-webdriver-0.5.7 lib/watir-webdriver/elements/image.rb
watir-webdriver-0.5.6 lib/watir-webdriver/elements/image.rb
watir-webdriver-0.5.5 lib/watir-webdriver/elements/image.rb
watir-webdriver-0.5.4 lib/watir-webdriver/elements/image.rb
watir-webdriver-0.5.3 lib/watir-webdriver/elements/image.rb
watir-webdriver-0.5.2 lib/watir-webdriver/elements/image.rb
watir-webdriver-0.5.1 lib/watir-webdriver/elements/image.rb
watir-webdriver-0.5.0 lib/watir-webdriver/elements/image.rb