我正在尝试使用ruby的mechanize
验证下拉列表的值。我有这个漂亮的打印表格:
:
#<Mechanize::Form
...
[selectlist:0xefdae4 type: name: time_entry[activity_id] value: []]}
...
{buttons [submit:0xefe124 type: submit name: commit value: Save]}>
:后#<Mechanize::Form
...
[selectlist:0xefdae4 type: name: time_entry[activity_id] value: []]}
...
{buttons [submit:0xefe124 type: submit name: commit value: Save]}>
我正在运行的代码:
@form.field_with(:name => "time_entry[activity_id]").options[2].select
…对应第三个选项:"Testing"
和select HTML元素:
<select id="time_entry_activity_id" name="time_entry[activity_id]">
<option value="">--- Please select ---</option>
<option value="8">Design</option>
<option value="9">Development</option>
<option value="13">Testing</option>
<option value="14">Dingo</option>
<option value="15">ABPs</option>
</select>
我正在尝试获得从选择框中选择的项目的某种验证。
Just inspect:
@form.field_with(:name => "time_entry[activity_id]").value
或者更简单:
@form.values