如何解决 Capybara::ElementNotFound 错误 [英] How to solve a Capybara::ElementNotFound Error
本文介绍了如何解决 Capybara::ElementNotFound 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我遇到以下问题,这是我第一次使用capybara,你知道我该如何解决这个问题,谢谢
I'm stuck with the following problem, this is the first time I use capybara, have you an idea how I can solve this issue, thanks
我使用 rails 3.0.0 和以下 gems
I use rails 3.0.0 and the following gems
gem 'rails', '3.0.0'
gem 'capybara'
gem 'database_cleaner'
gem 'cucumber-rails'
gem 'cucumber'
gem 'rspec-rails'
gem 'spork'
gem 'launchy'
我的 senario 中有以下内容
I have the following in my senario
When I go to the new customer page
And I fill in "Email" with "john@example.com"
在我的 customer_steps.rb 我有
in my customer_steps.rb I have
When /^I fill in "([^"]*)" with "([^"]*)"$/ do |arg1, arg2|
fill_in arg1, :with => arg2
end
在我看来
- form_for @customer do |f|
= f.label :email, 'Email'
= f.text_field :email
= f.submit
当我运行我的场景时,我会收到此错误消息
When I run my scenario I get this error message
Scenario: Register new customer # features/manage_customers.feature:7
When I go to the new customer page # features/step_definitions/customer_steps.rb:1
And I fill in "Email" with "john@example.com" # features/step_definitions/customer_steps.rb:5
cannot fill in, no text field, text area or password field with id, name, or label 'Email' found (Capybara::ElementNotFound)
./features/step_definitions/customer_steps.rb:6:in `/^I fill in "([^"]*)" with "([^"]*)"$/'
features/manage_customers.feature:9:in `And I fill in "Email" with "john@example.com"'
推荐答案
我发现我的错误了!!!
I found my mistake!!!
When I go to the new customer page
在这一步之前
When /^I go to (.+)$/ do |page_name|
path_to page_name
end
我忘记来访了...
When /^I go to (.+)$/ do |page_name|
visit path_to(page_name)
end
这篇关于如何解决 Capybara::ElementNotFound 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文