自己重新实现QTP封装的一些常用的方法


Function Check_ComboBox_ItemValue(objVbComboBox,strItemValue,intItemValueLength)
   Dim i
   Dim Cnt
   Cnt = objVbComboBox.GetItemsCount
   For i = 0 to Cnt -1 
           If  Trim(Left(objVbComboBox.getItem(i),intItemValueLength))= strItemValue Then
                   Reporter.ReportEvent micPass,"检查ComboBox下拉项目","下拉项目包含“" & strItemValue & "”,测试通过"
                   Exit Function
           End If
   Next
   Reporter.ReportEvent micFail,"检查ComboBox下拉项目","下拉项目不包含“" & strItemValue & "”,测试失败"
End Function 

Function Check_Objects_ItemValue(obj,arrItemValue,arrItemValueLength)
   Dim i 
   Dim Cnt
   Cnt = UBound(arrItemValue)
   strReport = obj.ToString()&"包含下列项:"
   For i = 0 to Cnt 
           If Trim(Left(obj.getItem(i),arrItemValueLength(i))) = arrItemValue(i) Then
                   strReport = strReport & vbNewLine & arrItemValue(i) 
                   Else 
                                Reporter.ReportEvent micFail,"检查控件包含项符合性","包含项不完全符合,"&arrItemValue(i)&"为第一个不符合项"
                                Exit Function
           End If
   Next
   Reporter.ReportEvent micPass,"检查控件包含项符合性",strReport
End Function

Function Check_Objects_Text(obj,strText)
   Dim i
   Dim Cnt
        txtArray = Split(obj.GetVisibleText(),vbCrLf,-1,1)
    Cnt = UBound(txtArray)  '取数组上限
        For i = 0 to Cnt
                If   Trim(txtArray(i)) = Trim(strText) Then
                        Reporter.ReportEvent micPass,"检查字符串是否一致","界面中包含字符串:"&strText
                        Exit Function           
                End If
        Next
                        Reporter.ReportEvent micFail,"检查字符串是否一致","界面中不包含字符串:"&strText
End Function 

Function Check_Object_SelectedText(obj,strText,intTextLength)
     Dim i
   Dim Cnt
        txtArray = Split(obj.GetVisibleText(),vbCrLf,-1,1)
    Cnt = UBound(txtArray)  '取数组上限
        For i = 0 to Cnt
                If   Left(Trim(txtArray(i)),intRequiredLength) = Left(Trim(strText),intRequiredLength) Then
                        Reporter.ReportEvent micPass,"检查字符串是否一致","界面中包含字符串:"&strText
                        Check_Object_SelectedText = True
                        Exit Function           
                End If
        Next
                        Reporter.ReportEvent micFail,"检查字符串是否一致","界面中不包含字符串:"&strText
                        Check_Object_SelectedText = False
End Function

Function Check_List_Selection(objVbList,Exist,strSltValue,intSltLength)
   Dim i
   Dim Cnt
   If Exist  Then
                   sltArray = Split(objVbList.GetRoProperty("Selection"),vblf,-1,1)
                    Cnt = UBound(sltArray)  '取数组上限
                For i = 0 to Cnt  
                        If Trim(Left(sltArray(i),intSltLength) = strSltValue) Then
                                        Reporter.ReportEvent micPass,"检查list选中项","选中项包含“" & strSltValue & "”,测试通过"
                                        Exit Function
                        End If
                Next
   Reporter.ReportEvent micFail,"检查list选中项","选中项不包含“" & strSltValue & "”,测试失败"
   End If
   If Not Exist Then
        If objVbList.GetRoProperty("Selection") = "" Then
                        Reporter.ReportEvent micPass,"检查list选中项","不包含任何选中项,测试通过"
                        Exit Function 
                Else
                        Reporter.ReportEvent micFail,"检查list选中项","包含某些选中项,测试失败"
        End If
        End If
End Function


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值