我有一个我正在尝试测试的主/详细页。这里有一个things列表,当您单击它时,它将呈现thing的路由。
下面的测试找到要单击的thing,但似乎没有单击它。
@exists = (selector) ->
!!find(selector).length
...
test "things expand to show a detail view", 1, ->
visit("/").then(->
click(".things li:contains('Example Thing')")
).then ->
ok(@exists("h2")) # a tag in the detail view
...
<ul class='things'>
{{#each controller}}
<li>{{#linkTo 'thing' this}}{{title}}{{/linkTo}}</li>
{{/each}}
</ul>
{{outlet}}
...
<div class='thing'>
<h2>{{title}}</h2>
</div>这引发了这样的问题:Failure/Error: Element h2 not found.,有人知道我错过了什么吗/如何让这个测试通过?
我在浏览器中使用teaspoon (以前称为teabag)作为测试跑步器,如果这有什么不同的话。当测试点击时,我应该能够看到交互的发生吗?
发布于 2013-08-07 15:33:32
您不应该单击<li>元素,而应该单击<a>元素。handlebars中的linkTo帮助器在DOM中生成<a>标记。
像click(".things li:contains('Example Thing') a ")这样的东西应该可以工作。
https://stackoverflow.com/questions/17216541
复制相似问题