更新:
“RackTest 驱动程序无法单击不在表单中的按钮。” 通过 jnicklas
参考:https ://groups.google.com/forum/?fromgroups=#!topic/ruby-capybara/ECc4U_dux08
起源:
我已经为这个问题苦苦挣扎了几个小时,但不明白为什么。请你帮助我好吗?
index.html.haml
.welcome.ac
%h1.brand.text-info GroupMeal
%h2.tagline
The simplest way of scheduling meals with your groups and friends
%p
- if !current_user
%button#fblogin.btn.btn-info.btn-large Login with Facebook
- else
%a.btn.btn-info.btn-large{:href => '/signout'} Sign out\
authentications_spec.rb
describe "page" do
before do
visit root_path
end
it { should have_button('Login with Facebook') } # 1. This case is passed
describe "with valid information" do
before do
click_button('Login with Facebook') # 2. But this line is broken
end
it { should have_link('Sign out', href: '/signout') }
end
end
案例 1:验证“使用 Facebook 登录”按钮是否存在 --> 通过。
案例 2:click_button --> 失败并收到以下错误。
Failure/Error: click_button('Login with Facebook')
NoMethodError:
undefined method `node_name' for nil:NilClass
我不明白为什么该按钮存在但无法单击。