Capybara 和 Rails,为什么是 has_link?总是返回 false?
我正在尝试使用 has_link 进行测试?在我的规范测试中,这是我的测试:
page.has_link?('next_page', {}).should == true
但是,测试总是失败,尽管 id 为“next_page”的链接存在! 奇怪的是,have_content 总是工作正常,这是我实现它的方法:
page.should have_content("some text")
你能帮我吗?我在这里缺少什么?
编辑
这是页面中生成的链接:
<a id="next_page" href="javascript: void(0)" onclick="javascript: void(0)" style="color: #888888">Next</a>
I am trying to test with has_link? in my spec test, here is my test:
page.has_link?('next_page', {}).should == true
but, the test always fail, although the link with id 'next_page' dose exist!
the strange thing is that have_content always works fine, here is how I implement it:
page.should have_content("some text")
Can you help me please ? what I am missing here ?
EDIT
Here is the resulted link in the page:
<a id="next_page" href="javascript: void(0)" onclick="javascript: void(0)" style="color: #888888">Next</a>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为你应该这样做:
page.has_link? “next_page”
还是
page.has_link? “下一页”,url_path
I think you should do :
page.has_link? "next_page"
or
page.has_link? "next_page", url_path
您可以尝试下面的示例 -
You can try below sample -
我这样做是:
I do this with: