The default fill_in method of Capybara is case sensitive. This is apparently due to their use of XPath. Anyhow, this seems to not be very well aligned with the entire idea of DSLs and letting non programmers write tests. After some searching i found a stack overflow problem that didn't fix my issue but anyhow… I simply used a little ruby and the capybara library to find the field myself with some case insensitive regex and the ruby detect method. Yay!
see http://stackoverflow.com/questions/4157964/cucumber-find-the-input-with-label-text-x
my web_steps.rb file
When= /^i enter "([^"]*)" in the "([^"]*)" field$/i do |value, fieldname|
@thefield = all("label").detect { |l| (l.text =~ /#{fieldname}/i).nil? == false }
if @thefield.nil? then
raise Exception.new("Couldn't find field '#{fieldname}'")
end
fill_in @thefield[:for], :with=>value
end
admin.feature
Scenario: Adding a Provider
Given I am on the "Provider List" page
When I click the "New Provider" link
Then I should see the "New Provider" form
When I enter "xyz" in the "Name" field
And i enter "/jook/test1" in the "public url" field
And i enter "/jook/secured/test1" in the "Secure URL" field
And I click on the "Save" button
Then I am on the "Provider List" page
And i can see "xyz" in the table
Comments