Sha256: 48cfaa51e13efd00c79726f3719f585f13f1fd571e642c43f03b2575ad8b5e4c

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

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

    # perhaps we'll need a custom locate(), since this should also cover textareas
    attributes Watir::TextArea.typed_attributes

    container_method  :text_field
    collection_method :text_fields

    def locate
      TextFieldLocator.new(@parent.wd, @selector, self.class.attribute_list).locate
    end

    def inspect
      '#<%s:0x%x located=%s selector=%s>' % [self.class, hash*2, !!@element, selector_without_type.inspect]
    end

    def selector_string
      selector_without_type.inspect
    end

    def set(*args)
      assert_exists
      assert_writable

      @element.clear

      append(*args)
    end
    alias_method :value=, :set

    def append(*args)
      assert_exists
      assert_writable

      @element.send_keys(*args)
    end

    def clear
      assert_exists
      @element.clear
    end


    def value
      # since 'value' is an attribute on input fields, we override this here
      assert_exists
      @element.value
    end

    private

    def selector_without_type
      s = @selector.dup
      s[:type] = '(any text type)'
      s
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
watir-webdriver-0.0.1.dev lib/watir-webdriver/elements/text_field.rb