How to click first link in that case:
<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
and I get this error:
Capybara::Ambiguous:
Ambiguous match, found 2 elements matching css ".item"
And without the within
I get this error:
Failure/Error: first(:link, "Agree").click
NoMethodError:
undefined method `click' for nil:NilClass
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…