1
我有以下規格:RSpec的/水豚:奇怪的行爲沒有找到<INPUT TYPE = 「隱藏」>,但它肯定是有
within dom_id_selector(@boilerplate_copy) do
within '.copied_attributes_differing_from_original' do
within 'form.title[action="http://www.textdiff.com/"]' do
expect(page).to have_css 'button', text: 'Title'
expect(page).to have_css 'input[name="string1"]'
expect(page).to have_css 'input[name="string2"]'
end
end
end
這裏是有問題的HTML:
<div class="copied_attributes_differing_from_original">
<form action="http://www.textdiff.com/" class="title" method="post" target="_blank">
<input name="string1" type="hidden" value="Boilerplate Original test title">
<input name="string2" type="hidden" value="Boilerplate Copy test title">
<button type="submit">Title</button>
</form>
<form action="http://www.textdiff.com/" class="success_criterion_id" method="post" target="_blank">
<input name="string1" type="hidden">
<input name="string2" type="hidden" value="1">
<button type="submit">Success criterion</button>
</form>
// More of them...
<form action="http://www.textdiff.com/"...
</div>
雖然第一have_css
通行證(該按鈕被找到),第二have_css
失敗:
Failure/Error: expect(page).to have_css 'input[name="string1"]'
expected to find css "input[name=\"string1\"]" but there were no matches. Also found "", which matched the selector but not all filters.
但在我看來,這個元素絕對是在那裏!我也不明白輸出Also found "", which matched the selector but not all filters.
,這是什麼意思?
謝謝。
啊,謝謝!你是對的,功能測試應該是黑匣子,但是我測試了一個存在的表單將數據發送到外部資源(這超出了我的測試範圍),所以我唯一能做的就是確保數據可按預期獲得。 –
你有一個想法什麼'也找到了「,」匹配的選擇器,但不是所有的過濾器。「應該是什麼意思? –
@JoshuaMuheim唯一的發現可見行爲被實現爲水豚結果的過濾器,所以它告訴你它找到了一個匹配CSS選擇器但與可見性過濾器不匹配的元素 –