相关疑难解决方法(0)

Capybara :: ElementNotFound:无法找到xpath"/ html"

我正在http://ruby.railstutorial.org/chapters/static-pages上关注Ruby on Rails教程并遇到以下错误

 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)'
Run Code Online (Sandbox Code Playgroud)

我的Gem文件如下

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
Run Code Online (Sandbox Code Playgroud)

如何摆脱这个错误并通过rspec?源文件

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 …
Run Code Online (Sandbox Code Playgroud)

ruby rspec ruby-on-rails capybara gemfile

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

capybara ×1

gemfile ×1

rspec ×1

ruby ×1

ruby-on-rails ×1