如何解决 Capybara::ElementNotFound 错误
我遇到了以下问题,这是我第一次使用水豚,你知道我如何解决这个问题吗,谢谢
我使用rails 3.0.0和以下gems
gem 'rails', '3.0.0'
gem 'capybara'
gem 'database_cleaner'
gem 'cucumber-rails'
gem 'cucumber'
gem 'rspec-rails'
gem 'spork'
gem 'launchy'
senario中有以下内容
When I go to the new customer page
And I fill in "Email" with "[email protected]"
我在我的customer_steps中的 .rb 我
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
当我运行我的场景时,我收到此错误消息
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 "[email protected]" # 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 "[email protected]"'
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
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'
I have the following in my senario
When I go to the new customer page
And I fill in "Email" with "[email protected]"
in my customer_steps.rb I have
When /^I fill in "([^"]*)" with "([^"]*)"$/ do |arg1, arg2|
fill_in arg1, :with => arg2
end
In my view
- 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 "[email protected]" # 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 "[email protected]"'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我发现我的错误了!!!
在这一步之前
我忘记了访问......
I found my mistake!!!
before the step was
I forgot the visit...
使用该字段的 id 代替,它应该类似于
如果@customer 是对象客户模型
Use this id of the field instead, which should be like
if the @customer is a object customer model