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']")