这篇文章给大家分享的是有关TestComplete中如何使用VBScript脚本实现对容器控件中子对象的遍历的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。
1、需求:实现在某个容器控件中只选择某一个指定的值
2、抓取目标容器:namemapping后赋值
Set DetailProdGroups=Aliases.dbcProductsDetailContainer.DetailProdGroup
容器布局如下(每一行有checkbox,p_w_picpath,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
感谢各位的阅读!关于“TestComplete中如何使用VBScript脚本实现对容器控件中子对象的遍历”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!