【发布时间】:2019-10-25 23:39:22
【问题描述】:
在运行我的规范时,我遇到了 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 /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 代码!
【问题讨论】:
标签: ruby-on-rails ruby cucumber bdd