我正在使用水豚測試我正在寫一個小的Web應用程序。它拒絕從選擇中選擇正確的項目。代碼如下:水豚不會選擇項目從選擇
before do
fill_in 'Assignment', with: "blah blah blah"
select student.name, from: "assignment[student_id]"
end
我試過「from」字段中的所有支持的格式。我使用了id,名稱和標籤文本來嘗試選擇正確的元素。我甚至在測試中啓動了Rails服務器,並在控制檯中手動執行測試中的步驟。無論我做什麼,水豚踢回:
cannot select option, no option with text 'John Doe' in select box 'assignment[student_id]'
如前所述,我已經踢了在測試環境中軌服務器,然後手動將用戶添加到數據庫中以同樣的方式我已經在我的測試完成。我對選擇框'作業[學生]'中的文字「John Doe」確實有一個選項的100%信心。這導致我相信我必須錯誤地使用select方法。有人能夠啓發我嗎?
您可以添加選擇框的代碼,只是要加倍確定。 – Matt
嘗試運行'all('#assignment [student_id]>選項')。each {| el |放入el.text(:all)}'來檢查這個選項是否存在。 –