我有下一个
HTML代码:
- <ul class="nav">
- <li class="active">
- <a href="/users/page">Page</a>
- </li>
- ...
- </ul>
我想确保我的li标签有“active”类并且在该文本中.
所以,我尝试过:
- response.should have_selector( "li",:class => "active",:content => "Page")
它不起作用,我得到这样的错误:
- Failure/Error: response.should have_selector( "li",:content => "Page")
- expected following output to contain a <li class='active'>Page</li> tag:
我怎样才能解决我的问题?
解决方法
我认为你可以将类添加到css选择器.就像是:
- response.body.should have_selector( "li.active",:content => 'Page')