ruby on rails - Why is capybara not finding a form element? -


we're trying introduce capybara our rspec examples , aren't having luck yet. don't know if part of confusion between capybara , rails integration testing, but...

here's rspec example:

require 'spec_helper'  describe "planning trip", :type => :feature   before :each     factorygirl.create(:user)   end    "creates new trip"     visit '/trips/new'     save_and_open_page     within("#new_trip")       fill_in '#trip_from_place_nongeocoded_address', :with => '730 w peachtree st, atlanta, ga'       fill_in '#trip_to_place_nongeocoded_address', :with => 'georgia state capitol, atlanta, ga'     end     click_link 'plan it'     expect(page).to have_content 'success'   end end 

and here's relevant part of html, capybara's save_and_open_page:

  <form accept-charset="utf-8" action="/trips" class=   "simple_form form-horizontal" id="new_trip" method="post"   novalidate="novalidate">      <div class=     "control-group string required trip_from_place_nongeocoded_address">     <label class="string required control-label" for=     "trip_from_place_nongeocoded_address"><abbr title=     "required">*</abbr> from</label>        <div class="controls">         <input class="string required" id=         "trip_from_place_nongeocoded_address" name=         "trip[from_place][nongeocoded_address]" placeholder=         "enter address" size="50" type="text">       </div>     </div> [...etc...] 

but running rspec example fails with:

  1) planning trip creates new trip      failure/error: fill_in '#trip_from_place_nongeocoded_address', :with => '730 w peachtree st, atlanta, ga'      capybara::elementnotfound:        unable find field "#trip_from_place_nongeocoded_address"      # ./spec/features/plan_a_trip_spec.rb:12:in `block (3 levels) in <top (required)>'      # ./spec/features/plan_a_trip_spec.rb:11:in `block (2 levels) in <top (required)>' 

suggestions?

afaik, if input has:

id="trip_from_place_nongeocoded_address" 

then, need to:

fill_in 'trip_from_place_nongeocoded_address' 

... without #

capybara: how fill in input field id


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -