预期的CSS“标题”与水豚文本(expected css “title” with text in capybara)

编程入门 行业动态 更新时间:2024-10-28 20:30:46
预期的CSS“标题”与水豚文本(expected css “title” with text in capybara)

我正在使用水豚代替轨道中的网页。 我已经安装了水豚,并在Gemfile中使用gem'水豚'。 当我使用

page.should have_selector("title", :text => "anything title")

这是一个错误

Failure/Error: page.should have_selector("title", :text => "anything title") expected css "title" with text "anything title" to return something

测试文件如下:

require 'spec_helper' describe "Test pages" do describe "Home page" do it "should have the content 'Demo App'" do visit '/test_pages/home' page.should have_selector("title", :text => "anything title") end end end

I am using capybara in place of webrat in rails. I have installed capybara and use gem 'capybara' in Gemfile. when I use

page.should have_selector("title", :text => "anything title")

it's give an error

Failure/Error: page.should have_selector("title", :text => "anything title") expected css "title" with text "anything title" to return something

test file is as below:

require 'spec_helper' describe "Test pages" do describe "Home page" do it "should have the content 'Demo App'" do visit '/test_pages/home' page.should have_selector("title", :text => "anything title") end end end

最满意答案

不知道你使用的是哪个版本的宝石,但我遇到了类似的情况,使用:文本失败,但是当我使用:内容通过测试。 我在Ubuntu Lucid Lynx上使用rails 3.2.3,rspec-rails 2.9.0,capybara 1.1.2和therubyracer gems。

尝试更换

page.should have_selector("title", :text => "anything title")

page.should have_selector("title", :content => "anything title")

Not sure which version of gems you are using but I ran into a similar instance where using :text failed but when I used :content it passed the test. I'm using rails 3.2.3, rspec-rails 2.9.0, capybara 1.1.2 and therubyracer gems on Ubuntu Lucid Lynx.

Try replacing

page.should have_selector("title", :text => "anything title")

with

page.should have_selector("title", :content => "anything title")

更多推荐

本文发布于:2023-08-01 17:33:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1362803.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文本   标题   expected   CSS   text

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!