Sha256: 4512f2a1128daf64ad70788bd4bff1e16a550c55ff1664ba7334e8ea28cdb2ed

Contents?: true

Size: 1.17 KB

Versions: 6

Compression:

Stored size: 1.17 KB

Contents

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

    alias_method :readonly?, :read_only?

    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 = rescue_no_match { @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

    #
    # not sure about this
    #
    # this is mostly useful if you're using Browser#element_by_xpath, and want to
    # 'cast' the returned Input instance to one of the subclasses
    #

    def to_checkbox
      assert_exists
      Watir::CheckBox.new(@parent, :element, @element)
    end

    def to_radio
      assert_exists
      Watir::Radio.new(@parent, :element, @element)
    end

    def to_button
      assert_exists
      Watir::Button.new(@parent, :element, @element)
    end

    def to_select_list
      assert_exists
      Watir::SelectList.new(@parent, :element, @element)
    end

  end # Input
end # Watir

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
watir-webdriver-0.0.3 lib/watir-webdriver/elements/input.rb
watir-webdriver-0.0.2 lib/watir-webdriver/elements/input.rb
watir-webdriver-0.0.1 lib/watir-webdriver/elements/input.rb
watir-webdriver-0.0.1.dev7 lib/watir-webdriver/elements/input.rb
watir-webdriver-0.0.1.dev6 lib/watir-webdriver/elements/input.rb
watir-webdriver-0.0.1.dev5 lib/watir-webdriver/elements/input.rb