Rspec 为什么赢了';t水豚在选择菜单中选择正确的项目?

Rspec 为什么赢了';t水豚在选择菜单中选择正确的项目?,rspec,capybara,Rspec,Capybara,当您保存并打开页面时,您可以看到我的表单包含: <label class="select optional control-label" for="assignment_role_id">Role</label> <select class="select optional" id="assignment_role_id" name="assignment[role_id]"> <option value="819">admin<

当您保存并打开页面时,您可以看到我的表单包含:

<label class="select optional control-label" for="assignment_role_id">Role</label>
  <select class="select optional" id="assignment_role_id" name="assignment[role_id]">
    <option value="819">admin</option>
    <option value="820">customer</option>
</select>
……还有

Failure/Error: select("customer", :from => :assignment_role_id)
     Capybara::ElementNotFound:
       cannot select option, no option with text 'customer' in select box 'assignment_role_id'
Failure/Error: select("customer", :from => :role_id)
     Capybara::ElementNotFound:
       cannot select option, no option with text 'customer' in select box 'role_id'
……还有

Failure/Error: select("customer", :from => :assignment_role_id)
     Capybara::ElementNotFound:
       cannot select option, no option with text 'customer' in select box 'assignment_role_id'
Failure/Error: select("customer", :from => :role_id)
     Capybara::ElementNotFound:
       cannot select option, no option with text 'customer' in select box 'role_id'
解决办法是:

select("customer", :from => "assignment[role_id]")
解决办法是:

select("customer", :from => "assignment[role_id]")

您是否尝试过删除
标记中的换行符?实际上所有换行符都在一行上。为了便于阅读,我将其展开。您是否尝试过删除
标记中的换行符?它实际上都在一行上。为了便于阅读,我将其展开。如果您使用的是水豚,我建议您熟悉操作、查找器和匹配器()。以下是相关的自述文件:如果您正在使用水豚,我建议您熟悉操作、查找器和匹配器()。以下是相关的自述: