Module: Capybara::DatepickerDateFill

Defined in:
lib/decidim/dev/test/rspec_support/datepicker_date_fill.rb

Instance Method Summary collapse

Instance Method Details

#fill_in_datepicker(locator = nil, with:, currently_with: nil, fill_options: {}, **find_options) ⇒ Object

fill datepicker field correctly



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/decidim/dev/test/rspec_support/datepicker_date_fill.rb', line 7

def fill_in_datepicker(locator = nil, with:, currently_with: nil, fill_options: {}, **find_options)
  find_options[:with] = currently_with if currently_with
  find_options[:allow_self] = true if locator.nil?
  with.chars.each do |character|
    if character == "/"
      find(:fillable_field, locator, **find_options).send_keys(:divide, **fill_options)
    elsif character == "."
      find(:fillable_field, locator, **find_options).send_keys(:decimal, **fill_options)
    else
      find(:fillable_field, locator, **find_options).send_keys(character, **fill_options)
    end
  end
end