我正在使用 cucumber 进行测试,我正在使用 simple_form 作为联系表。我收到以下错误:
Given I am on the login page
And I fill in "student_name" with "sadik"
Unable to find field "student_name" (Capybara::ElementNotFound)
我的步骤:
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"
...
表格:
<%= simple_form_for @student do |f| %>
<%= f.input :name, label: 'student_name' %>,
:input_html => { :field => 'student_name' } %>
<%= f.button :submit %>
<% end %>
我还尝试了 id 和 name 而不是标签。但它没有任何效果。
但第一步是正确的:
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
那么问题出在哪里?