를 찾을 수 없습니다 나는 다음과 같은 형식카피 바라가 필드
<%= form_for(@route, :html => {:class => "form-horizontal", :role => 'form'}) do |f| %>
<%= render 'shared/error_messages', object: f.object %>
<div class="form-group">
<input type="text" name="route_origin_input" id="route_origin_input" placeholder="From" onFocus="geolocate(); autocompleteLocation(this,route_origin)" class="form-control" />
<%= f.hidden_field :origin, class: "form-control" %>
</div>
<div class="form-group">
<input type="text" name="route_destination_input" id="route_destination_input" placeholder="Destination" onFocus="geolocate(); autocompleteLocation(this,route_destination)" class="form-control" />
<%= f.hidden_field :destination, class: "form-control" %>
</div>
<div class="form-group">
<% options = options_from_collection_for_select(@vehicleList, 'vehicle', 'vehicle') %>
<%= f.select :vehicle, options, class: "form-control" %>
</div>
<div class="form-group">
<%= f.date_field :departure_date, class: "form-control" %>
</div>
<%= f.submit "Post", class: "btn btn-large btn-primary", id: "route_post" %>
<% end %>
내가 HTML을 추가 한 두 개의 텍스트 필드에서 찾을 수없는 몇 가지 이유를 들어 다음과 같은 시험
require 'spec_helper'
describe "Route pages" do
subject { page }
let(:user) { FactoryGirl.create(:user) }
before { sign_in user }
describe "route creation" do
before {
visit terminal_path
}
describe "with invalid information" do
it "should not create a route" do
expect { click_button "route_post" }.not_to change(Route, :count)
end
describe "error messages" do
before { click_button "route_post" }
it { should have_danger_message('Not Submitted') }
end
end
describe "with valid information", :js => true do
before do
fill_in 'route_origin_input', with: "Kimmage, Dublin, Ireland"
fill_in 'route_destination_input', with: "Kimmage, Dublin, Ireland"
fill_in 'route_departure_date', with: Time.now
select 'Car', :from => "route_vehicle"
end
it "should create a route" do
expect { click_button "route_post" }.to change(Route, :count).by(1)
end
end
end
end
에게 있습니다 카피 바라
I 나타나는 오류는
입니다Failure/Error: fill_in 'route_origin_input', with: "Kimmage, Dublin, Ireland" Capybara::ElementNotFound: Unable to find field "route_origin_input" # /Users/jeff/.rvm/gems/ruby-2.0.0-p594/gems/capybara-2.4.4/lib/capybara/node/finders.rb:41:in
block in find' # /Users/jeff/.rvm/gems/ruby-2.0.0-p594/gems/capybara-2.4.4/lib/capybara/node/base.rb:84:in
synchronize' # /Users/jeff/.rvm/gems/ruby-2.0.0-p594/gems/capybara-2.4.4/lib/capybara/node/finders.rb:30:infind' # /Users/jeff/.rvm/gems/ruby-2.0.0-p594/gems/capybara-2.4.4/lib/capybara/node/actions.rb:56:in
fill_in' # /Users/jeff/.rvm/gems/ruby-2.0.0-p594/gems/capybara-2.4.4/lib/capybara/session.rb:676:inblock (2 levels) in <class:Session>' # /Users/jeff/.rvm/gems/ruby-2.0.0-p594/gems/capybara-2.4.4/lib/capybara/dsl.rb:51:in
block (2 levels) in ' # ./spec/requests/route_pages_spec.rb:30:in `block (4 levels) in '
다른 테스트에서는 fill_in을 사용했지만 폼에서 표준 html 코드를 사용한다는 점만 볼 수 있습니다. 이 필드는 사용자가 입력 한 정보를 처리 한 다음 내 모델의 일부인 숨겨진 필드에 결과를 추가하는 데 사용되며 기본적으로 Google지도 api에서 결과를 얻습니다.
편집 : 여기 는
<div class="form-group">
<input type="text" name="route_origin_input" id="route_origin_input" placeholder="From" onFocus="geolocate(); autocompleteLocation(this,route_origin)" class="form-control" />
<input class="form-control" id="route_origin" name="route[origin]" type="hidden" />
</div>
try page.find (: fillable_field, 'route_origin_date'). 설정 "Kimmage, Dublin, Ireland" –
... 또는 '페이지'가 필요하지 않을 수 있습니다. 그 줄에 접두어를 붙이세요. 나는 확실히 기억할 수 없다. –
렌더링 된 HTML을 표시 할 수 있습니까? –