Created
May 29, 2013 23:11
-
-
Save lbspen/5674563 to your computer and use it in GitHub Desktop.
Select date and time for capybara-rspec from rails forms
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def select_date(date, options = {}) | |
field = options[:from] | |
base_id = find(:xpath, ".//label[contains(.,'#{field}')]")[:for] | |
year, month, day = date.split(',') | |
select year, :from => "#{base_id}_1i" | |
select month, :from => "#{base_id}_2i" | |
select day, :from => "#{base_id}_3i" | |
end | |
def select_time(hour, minute, options = {}) | |
field = options[:from] | |
base_id = find(:xpath, ".//label[contains(.,'#{field}')]")[:for] | |
select hour, :from => "#{base_id}_4i" | |
select minute, :from => "#{base_id}_5i" | |
end |
ClayShentrup
commented
May 4, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment