如何在此下拉列表中选择第二个选项?
<select name="size" onchange="...js...">
<option value="OPTION_CHOOSE">Please Select an Option</option>
<option value="123">ABC</option>
<option value="456">DFG</option>
<option value="789">HIJ</option>
</select>
require 'rubygems'
require 'mechanize'
url = "http://...."
agent = Mechanize.new
page = agent.get(url)
form = agent.page.forms.first
*select drop down*
答案 0 :(得分:5)
form.field_with(:name => 'size').options[1].click