Skip to content

Instantly share code, notes, and snippets.

View NilsHaldenwang's full-sized avatar

Nils Haldenwang NilsHaldenwang

View GitHub Profile
@amiel
amiel / capybara_select_dates_and_times.rb
Created March 7, 2012 01:02 — forked from szimek/capybara_select_dates_and_times.rb
Cucumber steps for selecting time and date (using Capybara)
require "xpath" # XPath is a separate gem now
module Cucumber
module Rails
module CapybaraSelectDatesAndTimes
def select_date(field, options = {})
date = Date.parse(options[:with])
selector = %Q{.//fieldset[contains(./legend, "#{field}")]}
within(:xpath, selector) do
find(:xpath, './/select[contains(@id, "_1i")]').find(:xpath, ::XPath::HTML.option(date.year.to_s)).select_option