watir select元素交互方式

watir select元素交互方式

单选: 
<select id="selectId" name="selectme"> <option></option> <option>Web Testing</option> <option>in Ruby</option> <option>is fun</option> </select> 
1.ie.select_list(:id, "selectId").set("is fun")  
2.ie.select_list(:name, "selectme").set("is fun")  
3.ie.select_list(:id, "selectId").clearSelection  
4.contents = ie.select_list(:id, "selectId").getAllContents 
返回的contents是一个array
  
多选:
<select id="selectId" name="selectme" multiple="multiple"> <option></option> <option>Web Testing</option> <option>in Ruby</option> <option>is fun</option> </select> 
ie.select_list(:id, 'selectId').set('Web Testing') ie.select_list(:id, 'selectId').set('in Ruby') ie.select_list(:id, 'selectId').set('is fun') ie.select_list(:id, 'selectId').clearSelection 
同样可以采用name的方式获取元素

你可能感兴趣的:(Web,IE,Ruby)