0
下面是我的形式,你可以看到,会有输入领域的许多行都具有相同的类:水豚FILL_IN多个输入字段
<%= q.simple_fields_for :choices do |c|%>
<div class="row-fluid choice-row">
<%= c.text_field :sort_order, class: 'span1' %>
<%= c.text_field :title, class: 'span9' %>
<%= c.link_to_remove 'Remove', class: 'btn btn-danger span2 pull-right' %>
</div>
<% end %>
对于我的测试,我想:
fill_in(:sort_order, with: '3')
fill_in(:title, with: 'Choice 3')
我也试过:
fill_in('Sort Order', with: '3')
fill_in('Title', with: 'Choice 3')
和:
fill_in('Sort Order', :with => '3')
fill_in('Title', :with => 'Choice 3')
我得到的错误是:
Failure/Error: fill_in(:title, with: 'Choice 3')
Capybara::ElementNotFound:
cannot fill in, no text field, text area or password field with id, name, or label 'title' found
是否有人可以推荐我怎么能填充特定的输入,好比说第三排?
使用字段的ID而不是'Title'。 – psantos
我还没有分配一个ID。即使我这样做,也不会每个输入都有相同的ID。我如何区分第三行输入和第五行? –
每个字段的ID是唯一的。你可以检查你的字段,看看哪些ID号分配给它 – psantos