本文介绍了Capybara :: ElementNotFound:无法找到xpath“ / html”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在,并遇到以下错误
I'm following the Ruby on Rails tutorial at http://ruby.railstutorial.org/chapters/static-pages and came across the following error
StaticPages Home page should have the content 'Sample App'
Failure/Error: page.should have_content('Sample App')
Capybara::ElementNotFound:
Unable to find xpath "/html"
# (eval):2:in `text'
# ./spec/requests/static_pages_spec.rb:7:in `(root)'
我的宝石文件如下
source 'http://rubygems.org'
gem 'rails', '3.0.10'
gem 'jruby-openssl'
gem 'activerecord-jdbcsqlite3-adapter'
group :development, :test do
gem 'webrat'
gem 'rspec-rails', ">= 2.10.0"
gem 'capybara', ">= 1.1.2"
end
如何摆脱这个错误并通过rspec?
源文件
How do I get rid of this error and pass the rspec?The source file
require 'spec_helper'
describe "StaticPages" do
describe "Home page" do
it "should have the content 'Sample App'" do
visit '/static_pages/home'
# puts page.html
page.should have_content('Sample App')
end
end
end
推荐答案
也许问题出在webrat gem + capybara gem,请尝试从您的gemfile中删除webrat。
Maybe the problem is with webrat gem + capybara gem, try and remove webrat from your gemfile.
这篇关于Capybara :: ElementNotFound:无法找到xpath“ / html”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!