您的位置:首页 > 编程语言 > VB

TestComplete中使用VBScript脚本实现对容器控件中子对象的遍历

2014-10-31 15:39 375 查看
1、需求:实现在某个容器控件中只选择某一个指定的值
2、抓取目标容器:namemapping后赋值
Set DetailProdGroups=Aliases.dbcProductsDetailContainer.DetailProdGroup
容器布局如下(每一行有checkbox,image,textview,label等):



3、实现思路:只抓取到容器这一层即可,然后根据child方法或者item方法(控件不同方法不一样)获取子对象,再在循环中匹配子对象的名称即可实现。
4、代码贴上:
For i =0 To DetailProdGroups.BandCount-1
'get the name of child controls
strProductName=DetailProdGroups.Child(i).ComponentTitle
'set the status of checked all false
DetailProdGroups.Child(i).BandCheckbox.Checked=false
If productname <>"" Then
'only select product "productname"
If Instr(strProductName,productname)>0 Then
DetailProdGroups.Child(i).BandCheckbox.Checked=true
End If
Else
Log.Error("The product name"& productname &" is invalid.")
Exit Sub
End If
Next
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息