我得到這個錯誤:Rails的capybaraAmbiguous比賽,發現50個元素匹配CSS
Ambiguous match, found 50 elements matching css "input[value=\"delete\"]"
當我把下面的代碼:
find('input[value="delete"]').first.click
在HTML文件:
<div id="deletediv-38">
<form class="button_to" onsubmit="return confirm('Are you sure you want to delete?')" method="post" action="/del/38">
<input type="hidden" name="_method" value="delete" />
<input type="submit" name="delete-38" value="delete" />
</form>
</div>
<div id="deletediv-39">
<form class="button_to" onsubmit="return confirm('Are you sure you want to delete?')" method="post" action="/del/39">
<input type="hidden" name="_method" value="delete" />
<input type="submit" name="delete-39" value="delete" />
</form>
</div>
.
.
.
find('input[id="delete-38"]')
它不起作用,它說沒有找到元素。
而我無法算數。 當我做
find('input[value="delete"]').count.should_be > 0
我再次得到錯誤:
Ambiguous match, found 50 elements matching css "input[value=\"delete\"]"
感謝該訣竅! – user1735921