【发布时间】:2017-09-04 15:28:44
【问题描述】:
我有一个使用 remote=>true 提交的表单
<%= form_tag fetch_data_path, :remote => true do %>
Date: <%= text_field_tag :date %>
Amount:<%= text_field_tag :amount %>
From:<%= text_field_tag :from %>
To:<%= text_field_tag :to %>
<%= submit_tag "Convert"%>
<% end %>
<span style="font-weight: bold;">Converted Amount:</span>
<div id="converted_amount"></div>
在提交表单时,转换后的值会显示在带有 id 的 div 中
#converted_amount
这是我的 rspec:
RSpec.feature "User performs exchange", :type => :feature do
scenario "with valid input" do
visit exchanges_path
fill_in 'date', :with => "2017-08-24"
fill_in 'amount', :with => "100"
fill_in 'from', :with => "pound"
fill_in 'to', :with => "dollar"
click_button('Convert')
expect(page).to have_text("Converted Amount:")
end
end
问题是当我运行它时,我得到了
Capybara::ElementNotFound: Unable to find xpath "/html" 但是当我注释掉 click_button 时,它可以工作。
我做错了什么?
【问题讨论】:
-
您在 Capybara 上使用什么驱动程序?另外,您使用的是什么版本的 Capybara 和具体的驱动程序?
-
水豚 (2.15),水豚 webkit (1.14.0)
-
我应该提到我正在使用 Ruby on Rails 3.2
标签: ruby-on-rails rspec capybara