Sha256: a1795df1850d8a00f6f398086a7ed4c7b7e90d7d401ecef22f5260a726df0a7f

Contents?: true

Size: 1.02 KB

Versions: 13

Compression:

Stored size: 1.02 KB

Contents

module Watir
  class DateTimeField < Input
    #
    # Enter the provided value.
    #

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

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

      date_time_string = date.strftime('%Y-%m-%dT%H:%M')
      element_call(:wait_for_writable) { execute_js(:setValue, @element, date_time_string) }
    end
    alias set set!
    alias value= set
  end # DateTimeField

  module Container
    def date_time_field(*args)
      DateTimeField.new(self, extract_selector(args).merge(tag_name: 'input', type: 'datetime-local'))
    end

    def date_time_fields(*args)
      DateTimeFieldCollection.new(self, extract_selector(args).merge(tag_name: 'input', type: 'datetime-local'))
    end
  end # Container

  class DateTimeFieldCollection < InputCollection
    private

    def element_class
      DateTimeField
    end
  end # DateTimeFieldCollection
end # Watir

Version data entries

13 entries across 13 versions & 1 rubygems

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