I'm using cucumber to test and I'm using simple_form for the contact form. I get the following error:
Given I am on the login page
And I fill in "student_name" with "sadik"
Unable to find field "student_name" (Capybara::ElementNotFound)
my steps:
Scenario: Add a student to the database
Given I am on the login page
And I fill in "student_name" with "sadik"
When I press "OK"
...
The form:
<%= simple_form_for @student do |f| %>
<%= f.input :name, label: 'student_name' %>,
:input_html => { :field => 'student_name' } %>
<%= f.button :submit %>
<% end %>
I also tried id and name instead of label. But it had no effect.
But the first step is correct:
When /^I go to (.+)$/ do |page_name|
visit path_to(page_name)
end
When /^I fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value|
fill_in(field.gsub(' ', '_'), :with => value)
end
So where is the problem?