Ruby on rails Can';使用水豚无法找到链接
我正在用黄瓜和水豚来测试我的应用程序。然而,我似乎无法在我的页面中找到锚链接。我使用了Ruby on rails Can';使用水豚无法找到链接,ruby-on-rails,rspec,cucumber,capybara,Ruby On Rails,Rspec,Cucumber,Capybara,我正在用黄瓜和水豚来测试我的应用程序。然而,我似乎无法在我的页面中找到锚链接。我使用了save_和\u open_page调试特定步骤,这是输出页面的相关框架: <ul class='nav navbar-nav navbar-right'> <li><a href="http://www.example.com/en/accounts/login">Login</a></li> <li><a href="ht
save_和\u open_page
调试特定步骤,这是输出页面的相关框架:
<ul class='nav navbar-nav navbar-right'>
<li><a href="http://www.example.com/en/accounts/login">Login</a></li>
<li><a href="http://www.example.com/en/accounts/register">Register</a></li>
</ul>
我从水豚身上得到的失败信息是:
Capybara::ExpectationNotMet: expected to find link "Login" but there were no matches. Also found "", which matched the selector but not all filters.
我试着用一个id、名字等来代替我的期望,但运气不好
有没有人知道我该如何让它工作
编辑:
可能证明有用的一条信息:
前面提到的两个链接位于一个分部中,该分部包含在我在测试中访问的页面布局中:
:包括如上所示的登录和注册链接\u title\u bar.html.haml
:包括_partial.html.haml partiallayout.html.haml
:使用layout.html.haml作为模板呈现login.html.haml
我注意到,当我直接将链接放到login.html.haml中时,我的测试通过了。但是,当我将它们包含在layout.html.haml或_title_bar.html.haml中时,水豚无法解决这些问题。从提供的信息很难判断,但这里有几点需要注意:
expect(第页)来覆盖它。要使链接(“Login”,可见:false)
layout.html.haml
或\u title\u bar.html.haml
时,它是否可能最终位于嵌套不正确的元素内部在这个街区做其他匹配者的工作吗?请发布完整的规范文件或至少包含这两行
expect
的示例。我发布了失败的完整步骤定义。请查看“调试水豚”下的调试技术。您能否发布模板和部分的源代码?由于答案的第二部分,已接受。我已经检查了我的部分,实际上是链接没有放在预期的地方。谢谢。
Capybara::ExpectationNotMet: expected to find link "Login" but there were no matches. Also found "", which matched the selector but not all filters.