Consider the following Mechanize form object
#<Mechanize::Form
{name "f1"}
{method "POST"}
{action "f.php"}
{fields
[hidden:0x4db4b02 type: hidden name: opflag value: ]
[text:0x4db463e type: text name: lno value: 666]
[selectlist:0x4db84dc type: name: scode value: []]}
{radiobuttons}
{checkboxes}
{file_uploads}
{buttons [button:0x4db42ec type: button name: bt value: Show Result ]}>
Here, I am able to set value of text field using
result_form = page.form('f1')
result_form.lno = '666'
But I am facing difficulty in setting value for scode
selectlist. I have tried
result_form.field_with(name:"scode").option_with(value: "foo").click
it returns an ERROR as
undefined method
click' for nil:NilClass (NoMethodError)`
then, I tried
result_form.scode.value = 'foo'
But this returns NoMethodError
as well. Any idea how to set value for selectlist in Mechanize?
Try just:
result_form.scode = 'foo'