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的方式获取元素
本文详细介绍了WatirSelect元素的单选和多选交互方式,包括如何使用id和name属性进行元素的选择和清空操作。
1357

被折叠的 条评论
为什么被折叠?



