Cucumber step to pick a datetime in Rails' horrible datetime_select

Posted . Visible to the public.

Please don't use the horrible datetime_select Show archive.org snapshot helper. It has a terrible UI. Always prefer to use a visual time picker like Rome Show archive.org snapshot instead.

In case everything has failed and you do need a Cucumber step to pick a datetime datetime_select, here it is:

When(/^I select the time (\d+)\-(\d+)\-(\d+) (\d+):(\d+) from "(.*?)"$/) do |year, month, day, hour, minute, label_text|
  label = page.find('label', text: label_text)
  id = label['for']
  select year,   from: "#{id}_1i"
  select month,  from: "#{id}_2i"
  select day,    from: "#{id}_3i"
  select hour,   from: "#{id}_4i"
  select minute, from: "#{id}_5i"
end
Profile picture of Henning Koch
Henning Koch
Last edit
Henning Koch
License
Source code in this card is licensed under the MIT License.
Posted by Henning Koch to makandra dev (2015-05-12 06:57)