views:

39

answers:

2

Hi,

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

Use this id of the field instead, which should be like

And I fill in "customer_email" with "[email protected]"

if the @customer is a object customer model

Rishav Rastogi
thanks Rishav for your answer, I already tried that and got the same error, is there a way to 'dump' the html of the page to see if capybara search in the right code?
denisjacquemin
hey, see log/test.log for any errors..
Rishav Rastogi
well, when I run cucumber i have nothing in my log files (dev or test)
denisjacquemin
A: 

I found my mistake!!!

When I go to the new customer page

before the step was

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

I forgot the visit...

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