Search code examples
ruby-on-railscapybararspec2form-helpersdatefield

How to select a date in a Rails date_field form helper using Capybara


I have a reservation search form that contains the following date_field helper:

<%= date_field(:reservation, :arrival_date) %>

How do I select a specific date for this date_field tag using Capybara?

I tried select "2014-01-01", from: "reservation_arrival_date" in my spec but I get a Capybara::ElementNotFound: error when running the spec.

Thanks in advance!


Solution

  • Instead of finding a way to click and select a date in the date_field tag, I instead did the following:

    page.find('#reservation_arrival_date').set("2014-01-01")
    

    This works really well and I find this approach very simple. But I'm not sure how "awkward" this may seem for an integration test.