无法找到字段 "Netid" (Capybara::ElementNotFound)
Unable to find field "Netid" (Capybara::ElementNotFound)
我查看了与此相关的其他帖子并尝试了所有修复它的提示,但仍然遇到错误。有人可以看看我的代码并告诉我为什么我会继续收到此错误。
.html 代码看起来像
<% provide(:title, "Log in") %>
<h1>Log in</h1>
<h2>Note: authentication currently supports both a TAMU NetID or the use of CAS.</h2>
<h2>To access the CAS authentication system, click <%= link_to "here", new_member_session_path %></h2> <br />
<div class="row">
<div class="col-md-6 col-md-offset-3">
<%= form_for(:session, url: login_path) do |f| %>
<%= f.label :netid %>
<%= f.text_field :username, class: 'form-control' %>
<%= f.submit "Log in", class: "btn btn-primary" %>
<% end %>
</div>
</div>
我的测试看起来像
Background:
Given I am on the home page
When I follow "Login"
And I fill in "Netid" with "admin"
And I press "Log in"
我试过:
"Netid"
"Member[netid]"
"Member[:netid]"
":netid"
"netid"
我认为你是在告诉 Capybara 填写标签而不是输入字段。
在本地启动您的 Rails 应用程序并查看该页面的源代码。您应该会看到该字段类似于 <input type="text" id="session_username" name="session[username]" class="form-control" />
。
尝试将 "Netid" 更改为您在此处看到的 ID 或名称的值。
我查看了与此相关的其他帖子并尝试了所有修复它的提示,但仍然遇到错误。有人可以看看我的代码并告诉我为什么我会继续收到此错误。
.html 代码看起来像
<% provide(:title, "Log in") %>
<h1>Log in</h1>
<h2>Note: authentication currently supports both a TAMU NetID or the use of CAS.</h2>
<h2>To access the CAS authentication system, click <%= link_to "here", new_member_session_path %></h2> <br />
<div class="row">
<div class="col-md-6 col-md-offset-3">
<%= form_for(:session, url: login_path) do |f| %>
<%= f.label :netid %>
<%= f.text_field :username, class: 'form-control' %>
<%= f.submit "Log in", class: "btn btn-primary" %>
<% end %>
</div>
</div>
我的测试看起来像
Background:
Given I am on the home page
When I follow "Login"
And I fill in "Netid" with "admin"
And I press "Log in"
我试过:
"Netid"
"Member[netid]"
"Member[:netid]"
":netid"
"netid"
我认为你是在告诉 Capybara 填写标签而不是输入字段。
在本地启动您的 Rails 应用程序并查看该页面的源代码。您应该会看到该字段类似于 <input type="text" id="session_username" name="session[username]" class="form-control" />
。
尝试将 "Netid" 更改为您在此处看到的 ID 或名称的值。