我有这个 HTML: select id="id_agents" style="" size="10" multiple="multiple" name="id_agents[]"option value="12"adama/optionoption value="15"artica/optionoption value="14"localhost/optionoption value="8"localhost.localdomain/optionopti
<select id="id_agents" style="" size="10" multiple="multiple" name="id_agents[]"> <option value="12">adama</option> <option value="15">artica</option> <option value="14">localhost</option> <option value="8">localhost.localdomain</option> <option value="13">test</option> </select>
我正在尝试使用黄瓜来选择所有值,但它没有运行.这些是我的尝试:
When /^I select all in "(.*)"/ do |select_id| options = all(:xpath, "//select[@id='" + select_id + "']/option").click options.each do |option| option.click end #~ find(:xpath, "//select[@id='" + select_id + "']/option").each do |element| #~ element.click #~ end sleep(10) end我能够做到以下几点:
select = page.find('select#select_id') select.select 'Option 1' select.select 'Option 2' select.select 'Option 3' select.unselect 'Option 1'