Sha256: c30dcab600755fbee415dbb2bf89f4a05254e58cbcd37ddbca45db064ac6866a

Contents?: true

Size: 957 Bytes

Versions: 13

Compression:

Stored size: 957 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 set set!
    alias value= set
  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

13 entries across 13 versions & 1 rubygems

Version Path
watir-6.19.1 lib/watir/elements/date_field.rb
watir-6.19.0 lib/watir/elements/date_field.rb
watir-6.18.0 lib/watir/elements/date_field.rb
watir-6.17.0 lib/watir/elements/date_field.rb
watir-6.16.5 lib/watir/elements/date_field.rb
watir-6.16.4 lib/watir/elements/date_field.rb
watir-6.16.3 lib/watir/elements/date_field.rb
watir-6.16.2 lib/watir/elements/date_field.rb
watir-6.16.1 lib/watir/elements/date_field.rb
watir-6.16.0 lib/watir/elements/date_field.rb
watir-6.15.1 lib/watir/elements/date_field.rb
watir-6.15.0 lib/watir/elements/date_field.rb
watir-6.14.0 lib/watir/elements/date_field.rb