水豚断言元素的属性 [英] capybara assert attributes of an element
本文介绍了水豚断言元素的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用RSpec2和Capybara进行验收测试。
I'm using RSpec2 and Capybara for acceptance testing.
我想断言在Capybara中是否禁用了链接。我该怎么办?
I would like to assert that link is disabled or not in Capybara. How can I do this?
推荐答案
如何禁用链接?您要添加的课程吗?
How are you disabling the link? Is it a class you're adding? An attribute?
# Check for a link that has a "disabled" class:
page.should have_css("a.my_link.disabled")
page.should have_xpath("//a[@class='disabled']")
# Check for a link that has a "disabled" attribute:
page.should have_css("a.my_link[disabled]")
page.should have_xpath("//a[@class='disabled' and @disabled='disabled']")
# Check that the element is visible
find("a.my_link").should be_visible
find(:xpath, "//a[@class='disabled']").should be_visible
实际的xpath选择器可能不正确。我不经常使用xpath!
这篇关于水豚断言元素的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文