如何在这种情况下点击第一个链接:
<div class="item">
<a href="/agree/">Agree</a>
</div>
<div class="item">
<a href="/agree/">Agree</a>
</div>
within ".item" do
first(:link, "Agree").click
end
我得到了这个错误:
Capybara::Ambiguous:
Ambiguous match, found 2 elements matching css ".item"
如果没有 within
,我会得到这个错误:
Failure/Error: first(:link, "Agree").click
NoMethodError:
undefined method `click' for nil:NilClass