博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
QTP测试.NET控件CheckedListBox
阅读量:4199 次
发布时间:2019-05-26

本文共 923 字,大约阅读时间需要 3 分钟。

 

对于.NETCheckedListBox控件,我们可以适当封装,让其可以支持设置CheckListBox中指定Index的某一项的勾选状态的功能,以及支持设置CheckListBox中指定内容的某一项的勾选状态的功能,具体的实现代码如下所示:

 

' 设置CheckListBox中指定Index的某一项的勾选状态

Function CheckItemByIndex(w_CheckListBox , ItemIndex ,CheckState)

  w_CheckListBox.Object.SetItemChecked ItemIndex , CheckState

End Function

RegisterUserFunc "SwfList","CheckItemByIndex","CheckItemByIndex"

 

' 设置CheckListBox中指定内容的某一项的勾选状态

Function CheckItemByText(w_CheckListBox , ItemText ,CheckState)

  For I =0 to w_CheckListBox.GetItemsCount -1

      If  w_CheckListBox.GetItem(I) = ItemText  Then

           w_CheckListBox.Object.SetItemChecked I,CheckState

                 CheckItemByText = True

                 Exit Function

         End If

  Next

   CheckItemByText = False

End Function

RegisterUserFunc "SwfList","CheckItemByText","CheckItemByText"

 

QTP中引用该VBS文件后,可以这样使用封装的功能:

SwfWindow("Form1").SwfList("checkedListBox1").CheckItemByIndex 0,False

Msgbox SwfWindow("Form1").SwfList("checkedListBox1").CheckItemByText ("鸡蛋",True)

 

 

转载地址:http://iunli.baihongyu.com/

你可能感兴趣的文章
【HTML5/CSS/JS】<br>与<p>标签区别(二)
查看>>
【HTML5/CSS/JS】开发跨平台应用工具的选择(三)
查看>>
【心灵鸡汤】Give it five minutes不要让一个好主意随风而去
查看>>
【React Native】Invariant Violation: Application AwesomeProject has not been registered
查看>>
【ReactNative】真机上无法调试 could not connect to development server
查看>>
【XCode 4.6】常用快捷键 特别是格式化代码ctrl+i
查看>>
【iOS游戏开发】icon那点事 之 实际应用(二)
查看>>
【iOS游戏开发】icon那点事 之 图标设计(三)
查看>>
【IOS游戏开发】之测试发布(Distribution)
查看>>
【IOS游戏开发】之IPA破解原理
查看>>
【一天一道LeetCode】#45. Jump Game II
查看>>
【一天一道LeetCode】#46. Permutations
查看>>
【一天一道LeetCode】#47. Permutations II
查看>>
【一天一道LeetCode】#48. Rotate Image
查看>>
【一天一道LeetCode】#56. Merge Intervals
查看>>
【一天一道LeetCode】#57. Insert Interval
查看>>
【一天一道LeetCode】#58. Length of Last Word
查看>>
【一天一道LeetCode】#59. Spiral Matrix II
查看>>
【一天一道LeetCode】#30. Substring with Concatenation of All Words
查看>>
【一天一道LeetCode】#60. Permutation Sequence.
查看>>