0
<div id="look_here">
<a href="stackoverflow.com"><img src="xxxxxxxxxx.xxx"></a>
</div>
如何测试水豚(和RSpec)中的此链接?如何测试与水豚链接的http ref
该图像是动态生成的,所以我只想测试href
。
<div id="look_here">
<a href="stackoverflow.com"><img src="xxxxxxxxxx.xxx"></a>
</div>
如何测试水豚(和RSpec)中的此链接?如何测试与水豚链接的http ref
该图像是动态生成的,所以我只想测试href
。
page.should have_selector "a[href='stackoverflow.com']"
参见5.8.1节匹配属性和http://www.w3.org/TR/CSS2/selector.html
属性值这应该工作:
page.should have_xpath("//a[@href='stackoverflow.com']")