|
强烈呼吁大家发点有质量对大家有用的贴,又不是宝贝,在下先拍个砖引个玉
'********************************************************************************
'Function Name: Check_ComboBox_ItemValue
'Description:检查ComboBox的Item值是否一直
'Input : objVbComboBox :VbComboBox的对象实例, strItemValue: itemvalue的期望值, intItemValueLength: 截取ItemValue的值,传递给Left函数
'对于汉字的长度,一般一个汉字为2位
'Output:输出到Report, Pass Or Fail
'Developed by : xixihahahu
'Create Date:2008-08-26
'********************************************************************************
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 Name: Check_Objects_ItemValue
'Description:检查obj的Item值是否和期望值相同
'Input : obj :控件对象实例, arrItemValue: 数组类型,存放待检查的包含项的期望值, arrItemValueLength: 截取ItemValue的值,传递给Left函数
'Output:输出到Report, Pass Or Fail
'Developed by : xixihahahu
'Create Date:2008-08-26
'********************************************************************************
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 Name: Check_Objects_Text
'Description:检查控件如Dialog的字符串是否如期望值,适用于dialog类的对话框
'Input : obj :对象实例, strText:待验证的字符串期望值,
'Output:输出到Report, Pass Or Fail
'Developed by : xixihahahu
'Create Date:2008-08-27
'********************************************************************************
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 Name: Check_Object_SelectedText
'Description:检查控件如Dialog的字符串是否如期望值,适用于dialog类的对话框,是Check_Objects_Text改进
'Input : obj :对象实例, strText:待验证的字符串期望值, intTextLength:价差字符串的长度
'Output:输出到Report, Pass Or Fail
'Developed by : qcc
'Create Date:2008-08-27
'********************************************************************************
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 Name: Check_List_Selection
'Description:检查list的Selection值是否一致
'Input : objVbList :VbList的对象实例, Exist:选择检查包含哪些项还是不包含任何项,如为True则表示检查包含哪些项,如为false,表示检查不包含任何项
'strSltValue:表示List中被选择项的期望值,intSltLength: 截取所选择项的值,传递给Left函数
'Output:输出到Report, Pass Or Fail
'Developed by : xixihahahu
'Create Date:2008-08-26
'********************************************************************************
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
发错地方了,哎
[ 本帖最后由 xixihahahu 于 2009-6-9 17:38 编辑 ] |
|