1.实现思路:先随机获取选中一行,接着选择这一行以下的所有行。
Function Select_weblist(obj)
Dim item_count
item_count=obj.GetROProperty ("items count")
If item_count > 0 Then
Randomize
Get_Ran=RandomNumber (1,item_count-1)
obj.Select "#"&Get_Ran
For i=Get_Ran to item_count-1
obj.ExtendSelect i
Next
End If
End Function
Select_weblist(Browser("Browser").Page("test").WebList("A"))
2.总结下Weblist对象提供的函数:
ExtendSelect方法
向多项选择列表添加选定项 相当于按住ctrl再选择其他项
Browser("Browser").Page("Page").WebList("A").ExtendSelect "aa"
Deselect方法
取消选择列表中的指定项 相当于按住ctrl再取消aa
Browser("Browser").Page("Page").WebList("A").Deselect "aa"
select type属性: select的类型
strType返回为:Extended Selection
strType=Browser("Browser").Page("Page").WebList("A").GetROProperty("select type")
注:GetRoProperty与GetToProperty函数非常重要。
selected item index属性 已选列表的索引
strindex 返回为B,C
strindex=Browser("Browser").Page("Page").WebList("A").GetROProperty("selected item index")
selected items count属性 已选的项目数量
intcount返回为2
intCount=Browser("Browser").Page("Page").WebList("A").GetROProperty("selected items count")
selection属性 选定项目列表
strlist返回为B,C
strlist=Browser("Browser").Page("Page").WebList("A").GetROProperty("selection")
selectindex dom属性,这里返回为1,即B的索引
strDomIndex=Browser("Browser").Page("Page").WebList("A").Object.selectedIndex