我想使用機械化與紅寶石設置選擇列表的值。我可以使用選擇列表導航到頁面,使用.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中選擇任何