Sha256: b59fb02b59e9f53446fb066817e4d6aad22d0d96a84bc3d61aec61d8bc97e529

Contents?: true

Size: 879 Bytes

Versions: 9

Compression:

Stored size: 879 Bytes

Contents

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

    alias_method :readonly?, :read_only?

    #
    # @private
    #
    # subclasses can use this to validate the incoming element
    #

    def self.from(parent, element)
      unless element.tag_name == "input"
        raise TypeError, "can't create #{self} from #{element.inspect}"
      end

      new(parent, :element => element)
    end

    def enabled?
      !disabled?
    end

    #
    # Return the type attribute of the element, or 'text' if the attribute is invalid.
    # TODO: discuss.
    #
    # @return [String]
    #

    def type
      assert_exists
      value = @element.attribute("type").to_s

      # we return 'text' if the type is invalid
      # not sure if we really should do this
      TextFieldLocator::NON_TEXT_TYPES.include?(value) ? value : 'text'
    end

  end # Input
end # Watir

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
watir-webdriver-0.1.7 lib/watir-webdriver/elements/input.rb
watir-webdriver-0.1.6 lib/watir-webdriver/elements/input.rb
watir-webdriver-0.1.5 lib/watir-webdriver/elements/input.rb
watir-webdriver-0.1.4 lib/watir-webdriver/elements/input.rb
watir-webdriver-0.1.3 lib/watir-webdriver/elements/input.rb
watir-webdriver-0.1.2 lib/watir-webdriver/elements/input.rb
ayanko-watir-webdriver-0.1.1.1 lib/watir-webdriver/elements/input.rb
watir-webdriver-0.1.1 lib/watir-webdriver/elements/input.rb
watir-webdriver-0.1.0 lib/watir-webdriver/elements/input.rb