Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 436
Adler Santos Avatar asked Feb 18 '14 09:02

Adler Santos


1 Answers

As stated in documentation, date_field will not yield a <select> tag but an <input type='date'> this is why you cannot use Capybara::Node::Actions#select.

Instead just treat it as a regular input field:

fill_in "reservation_arrival_date", with: "2014/01/01"
like image 60
mdemolin Avatar answered Sep 28 '22 08:09

mdemolin