I am trying to set the value of a select list using Mechanize with Ruby. I can go to the page using a selection list, grab the form using the .form method and find the selection list.
report_form =page.form('form1') pp report_form.field_with(:name => "report_type")
Returns the correct object correctly.
However, I still cannot set the value of this field! I tried:
report_form.field_with(:name => "report_type").options.first.select report_form.field_with(:name => "report_type").options[1].select report_form.field_with(:name => "report_type").value = "Foo"
But when I do then:
pp report_form.field_with(:name => "report_type")
The value field is left blank.
Is there something I am missing? Advice? Tricks? Better Mechanize Documents than Live at http://mechanize.rubyforge.org ?
Thanks!
Edit: Corresponding HTML: Corresponding HTML:
<TD> <select id="report_type" name="report_type"> <option value="Foo1">Opt 1</option> <option value="Foo2">Opt 2</option> <option value="Foo3">Opt 3</option> </select></TD>
source share