運行我的規格時,我得到錯誤,其中水豚無法找到基於他們的標籤等元素。然後,我想我想要的HTML,或以某種方式調試錯誤。如何從使用水豚的黃瓜步驟中獲得整個頁面的響應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'
就吃一個粗略的時間與黃瓜在這裏工作..
1)爲什麼我得到上述
2)如何做我調試它,我想看看HTML代碼!
謝謝@mrcasals - 這工作完美。我也讀過你實際上可以做的事情:放入page.body。 – imbageek 2013-03-17 11:15:17
不錯的提示呢!但是使用我的例子的意義在於,如果你預編譯你的應用程序資產,你將會看到你的步驟正確地再現了什麼(也就是說,用HTML和CSS),這總是很好的:)但是,如果你急着要把page.body'放進去也可以工作:) – mrcasals 2013-03-20 11:42:30