- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是来自 Michael Hartl 的 Ruby on Rails 教程第 2 版。第三版(目前是最新版)没有使用 RSpec 进行测试,所以我决定使用这本书。
我已经阅读了用户的解决方法,并且知道有不同的方法可以编写测试以使其工作,但我想使用 have_selector 来保持代码一致。任何解释/建议都会非常有帮助。
我不明白为什么下面的测试通过 h1 元素而不是 title 元素:
规范.rb:
describe "Static pages" do
describe "Home page" do
it "should have the h1 'Sample App'" do
visit '/static_pages/home'
expect(page).to have_selector('h1', :text => 'Sample App')
end
it "should have the title 'Home'" do
visit '/static_pages/home'
expect(page).to have_selector('title',
:text => "Ruby on Rails Tutorial Sample App | Home")
end
end
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Ruby on Rails Tutorial Sample App | Home</title>
</head>
<body>
<h1>Sample App</h1>
</body>
</html>
最佳答案
尝试:
expect(page).to have_selector('title',
:text => "Ruby on Rails Tutorial Sample App | Home",
:visible => false)
<head>
元素,它被认为是隐藏的。指定
:visible => false
包括在 have_selector 匹配器中考虑的那些标签。
关于ruby-on-rails - RSpec/Capybara 测试 have_selector 难题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27694430/
我想将 JavaScript 函数移动到 来自输入标签的标签,但它不起作用。 这个有效: 这不是: function FieldOnKeyUp() { this.value=this.
我遇到了这个问题:说给定两个权重1和3,您可以权衡1,2(乘以3-1),3,4(乘以3 + 1)(使用平衡的两面)。现在找到最小的砝码数量,以便可以测量1到1000。 答案是1,3,9,27 ...
这是代码 war 的套路,我似乎无法弄明白。我以前从未使用过 JavaScript。 我知道答案可能很简单,但即使经过许多小时的搜索,我似乎也无法弄清楚他们在寻找什么。我知道 greet 函数中的 n
在完成一项学校作业时,我有一个抽象类 Person、一个扩展 Person 的抽象类 Student 和一个扩展学生的普通类 CollegeStudent。 CollegeStudent 从文件中读取
下面的代码让我很头疼 var somearr = [1, 2, 3]; function operations() { for (var i
我在 3 个文件中有以下代码: Defines.h #ifndef Defines_h extern const unsigned int SIZE; #endif Defines.cpp #incl
我的任务是尝试创建一个从文本文档中删除个人信息的自动化系统。 电子邮件、电话号码相对容易删除。名字不是。这个问题很难,因为文档中有需要保留的名称(例如,引用资料、名人、人物等)。需要从内容中删除作者姓
我卡在这里了... #include #define DBG_LVL(lvl, stmt) \ do{ \ if(lvl>1) printf stmt; \ }while(0) #defi
我正在尝试使用动态编程解决类似桥梁和 torch 的问题。有关此问题的更多信息,请参见维基百科 (http://en.wikipedia.org/wiki/Bridge_and_torch_probl
我有数组 A[0...N]的 double和数组 B[0...N]的 int .每B[i]变化在 [0...P] .我只需要计算数组 C[0...P] : C[j] = SUM( A[i] : B[i
我目前在使用 jQuery 中的scrollTop() 函数时遇到困难。目前,平滑滚动功能正在滚动经过预期部分,然后在功能完成运行后弹回该部分。我在本文末尾添加了一个 jsFiddle,但这是我目前的
PHP代码 $t = strtotime( '2012-09-21T03:00:00+00:00 America/Chicago' ); $t2 = date('c',$t); echo $t2;
我知道使用 .运算符将函数链接在一起,如下所示: isLessThanZero x | x a -> a -> a 还可以看到: subtract :: Num a => a -> (a ->
PHP代码 $t = strtotime( '2012-09-21T03:00:00+00:00 America/Chicago' ); $t2 = date('c',$t); echo $t2;
我创建了两个 jar 文件 my.common.jar,其中包含辅助类和方法(主要是静态方法)。我还创建了一个 jar 文件 test.jar,其中包含一个 main 方法,该方法调用 my.comm
已解决:@Desolator 已让我的代码在下面的评论中完全正常工作 好的,所以我创建了 3 个类,它们都相互链接: 启动画面 > 项目分配 > CompareSignature 我想谈论的类是闪屏类
我正在尝试使用 firestore 的 .where() 功能来检测某个字符串是否在数据库的数组中。我曾尝试通过添加方括号和其他东西来表示数组的一部分来操纵函数的第一个参数,但无济于事。 //in t
我有一个 PHP 系统,允许用户以 1 - 5 的范围对照片进行投票,我想要做的是突出显示两个人给彼此相同的投票/分数的地方。我目前无法弄清楚我的 PHP 函数的 SQL。 数据库看起来像这样 id,
我在使用 SQLAlchemy 处理 Unicode 时遇到了一个奇怪的问题。简而言之,当我将 Python unicode 字符串插入 Unicode 列时我的 MySQL 数据库,我可以毫不费力地
我正在尝试使用 Selenium 自动执行 Google 翻译网络界面(但无需了解 Selenium 即可理解此问题,只需要知道它会找到元素并单击它们即可)。我一直在选择要翻译的语言。 我无法打开下拉
我是一名优秀的程序员,十分优秀!