Sha256: ca1f2b0da3cc25b9242ecebc95fd144033e299318a773db3be1455357e5eeb3e

Contents?: true

Size: 994 Bytes

Versions: 6

Compression:

Stored size: 994 Bytes

Contents

module Watir
  class DateField < Input

    #
    # Enter the provided value.
    #

    def set!(date)
      date = Date.parse date if date.is_a?(String)

      message = "DateField##{__callee__} only accepts instances of Date or Time"
      raise ArgumentError, message unless [Date, ::Time].include?(date.class)

      date_string = date.strftime("%Y-%m-%d")
      element_call(:wait_for_writable) { execute_js(:setValue, @element, date_string) }
    end
    alias_method :set, :set!
    alias_method :value=, :set

    protected

  end # DateField

  module Container
    def date_field(*args)
      DateField.new(self, extract_selector(args).merge(tag_name: "input", type: "date"))
    end

    def date_fields(*args)
      DateFieldCollection.new(self, extract_selector(args).merge(tag_name: "input", type: "date"))
    end
  end # Container

  class DateFieldCollection < InputCollection
    private

    def element_class
      DateField
    end
  end # DateFieldCollection
end # Watir

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
watir-6.13.0 lib/watir/elements/date_field.rb
watir-6.12.0 lib/watir/elements/date_field.rb
watir-6.11.0 lib/watir/elements/date_field.rb
watir-6.11.0.beta2 lib/watir/elements/date_field.rb
watir-6.11.0.beta1 lib/watir/elements/date_field.rb
watir-6.10.3 lib/watir/elements/date_field.rb