gpt4 book ai didi

ruby-on-rails - capybara ::ElementNotFound:无法找到 xpath "/html"

转载 作者:数据小太阳 更新时间:2023-10-29 07:12:59 33 4
gpt4 key购买 nike

我正在学习 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)'

我的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

如何摆脱此错误并通过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 App')
end
end
end

最佳答案

也许问题出在 webrat gem + capybara gem,尝试从您的 gemfile 中删除 webrat。

check this issue

关于ruby-on-rails - capybara ::ElementNotFound:无法找到 xpath "/html",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10606150/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com