2010-09-04 5 views
5

Je suis coincé avec le problème suivant, c'est la première fois que je l'utilise capybara, vous avez une idée comment je peux résoudre ce problème, merciComment résoudre un Capybara :: ElementNotFound Erreur

J'utilise Rails 3.0 .0 et les gemmes suivantes

gem 'rails', '3.0.0' 
gem 'capybara' 
gem 'database_cleaner' 
gem 'cucumber-rails' 
gem 'cucumber' 
gem 'rspec-rails' 
gem 'spork' 
gem 'launchy' 

je suit dans mon senario

When I go to the new customer page 
And I fill in "Email" with "[email protected]" 

dans mon customer_steps.rb Je

When /^I fill in "([^"]*)" with "([^"]*)"$/ do |arg1, arg2| 
    fill_in arg1, :with => arg2 
end 

À mon avis

- form_for @customer do |f| 
    = f.label :email, 'Email' 
    = f.text_field :email 
    = f.submit 

Quand je lance mon scénario, je reçois ce message d'erreur

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]"' 

Répondre

4

J'ai trouvé mon erreur !!!

When I go to the new customer page 

avant l'étape était

When /^I go to (.+)$/ do |page_name| 
    path_to page_name 
end 

J'ai oublié la visite ...

When /^I go to (.+)$/ do |page_name| 
    visit path_to(page_name) 
end 
2

Utilisez cet identifiant du champ à la place, ce qui devrait être comme

Et je remplis "customer_email" avec "[email protected]"

si le client @customer est un client modèle d'objet

+0

grâce Rishav pour votre réponse, je l'ai déjà essayé et a obtenu la même erreur, est-il façon de «vider» le code HTML de la page pour voir si capybara recherche dans le bon code? – denisjacquemin

+0

hey, voir log/test.log pour toute erreur .. –

+0

bien, quand je cours de concombre je n'ai rien dans mes fichiers journaux (dev ou test) – denisjacquemin

Questions connexes