我想使用机械化与红宝石设置选择列表的值。我可以使用选择列表导航到页面,使用.form方法获取表单,并找到选择列表。SelectList与红宝石机械化
report_form =page.form('form1')
pp report_form.field_with(:name => "report_type")
正确返回正确的对象。
但是,我仍然无法设置此字段的值!我已经试过:
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"
但是当我然后执行:
pp report_form.field_with(:name => "report_type")
值字段仍然是空的。
有什么我失踪了吗?提示?窍门?更好的机械化文档比生活在http://mechanize.rubyforge.org?
谢谢!
编辑:相关的HTML是: 相关的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>
'report_form.field_with(:name =>“report_type”)。value =“Foo”'应该为我的理解而工作。唯一要检查的是看到实际的网页。 – 2012-03-26 18:48:44
我也无法在HTML中选择任何