2011-11-14 46 views
1

我想在黃瓜場景中編寫步驟,以從security_questions下拉列表中選擇選項「祖父的中間名」 。下拉列表的步驟定義

<td align="left"> 
     <select id="security_question" class="sign-up-security Signup_red_text" name="user_detail[secret_question]"> 
     <option value="Please Select"> Please Select</option> 
     <option value="grandfather middle name"> Grandfather's middle Name</option> 
     <option value="first date last name"> First Date's Last Name</option> 
     <option value="favorite place"> Favorite Place</option> 
     </select> 
     <br> 
     <div id="questionError" class="sign-up-ht"></div> 
     </td> 

請幫我爲此寫一個步驟。

我有一樣

When /^I select "(.*)" from "(.*)"$/ do |value, field| 
    select(value, :from => field) 
end 

步驟定義和我寫這爲

I select "grandfather middle name" from "user_detail[secret_question]" 

但它給我的錯誤,同時運行特點

Could not find field labeled "user_detail[secret_question]" (Webrat::NotFoundError) 

推薦任何方式。

回答

2

Webrat期待<label>標籤。你也應該這樣做。您還應該能夠通過使用id-屬性來引用<select>元素。

作爲一個方面:在你的黃瓜功能內使用HTML名稱沒有完成。請參閱Dan North's post