how to select dropdown on value option in ruby watir?

unknownbits picture unknownbits · Jun 18, 2013 · Viewed 19.2k times · Source

This is my drop down and i want to select it on its value option

<select id ="">
<option value="01" title="  01 - Live animals">  01 - Live animals</option>
</select>

I know that how to select drop down on its content i.e.

ie.select_list(:id, "DropDownList_Product").select("01 - Live animals")

actually I want to select drop down on its value 01,what should i have to do for that ?

Answer

Željko Filipin picture Željko Filipin · Jun 18, 2013

Something like this should work:

ie.select_list(:id, "DropDownList_Product").select_value("01")

More information at http://rdoc.info/gems/watir-webdriver/Watir/Select#select_value-instance_method