在运行我的规范时,我收到错误,Capybara 无法根据标签等找到元素。然后我想我想要 HTML,或者以某种方式调试错误。
这是 /features/merge.feature
#Just a test!
Scenario: Cannot merge articles when not admin
Given I am not an admin
When I am on the edit article page
Then I should not see the "merge articles" form
这是:/feature/step_definitions/merge.rb - 它只包含“Given”语句!
Given /am not an admin$/ do
visit '/accounts/login'
puts "TEZT"
puts page.native
puts page.native.text
fill_in 'user_login', :with => 'editor_rico'
fill_in 'user_password', :with => 'a'
click_button 'Login'
end
Given /^I am an admin$/ do
visit '/accounts/login'
fill_in 'user_login', :with => 'admin_rico'
fill_in 'user_password', :with => 'a'
click_button 'Login'
end
然后我得到这个错误:
Scenario: Cannot merge articles when not admin
# features/article_merging.feature:20
Given I am not an admin
#features/step_definitions/article_steps.rb:39
cannot fill in, no text field, text area or password field with id, name, or label
'user_login' found (Capybara::ElementNotFound)
(eval):2:in `fill_in'
./features/step_definitions/article_steps.rb:44:in `/am not an admin$/'
features/article_merging.feature:21:in `Given I am not an admin'
在这里和 Cucumber 一起工作很艰难..
1)为什么我得到上述
2)我如何调试它,我想看HTML代码!