|
写了下面一个脚本,对输入和检查点都进行了参数化,但迭代次数不对;
假设有7行数据,本应该把脚本跑7编,每行一遍;
但现在是跑完这7行数据以后,还会重复跑上面的步骤6遍,一共跑42次。
i=DataTable.GetSheet(dtlocalsheet).GetCurrentRow
arrRange = ReadFile("E:\自动化测试学习\QTP\DataTable.xlsx","DataTable")
'Msgbox UBound (arrRange,1)
'Msgbox UBound (arrRange,2)
' 读取其中一个单元格的数据
'Msgbox arrRange(1,1)
' 输入:
' sFileName: Excel文件
' sSheetName:表单名称
' 返回:
' 包含Excel数据的数组
Function ReadFile(sFileName,sSheetName)
Dim oExcel
Dim oSheet
Dim oRange
Dim arrRange
On Error Resume Next
' 创建Excel应用程序对象
Set oExcel = CreateObject("Excel.Application")
If err.Number <> 0 Then
MsgBox "未能初始化Excel" & vbCrLf & _
"请确保Excel已安装", vbCritical
Exit Function
End If
On Error Goto 0
On Error Resume Next
' 打开Excel文件
oExcel.Workbooks.Open(sFileName)
If err.Number <> 0 Then
MsgBox "未能加载Excel文件" & vbCrLf & _
"请确保Excel文件路径正确或格式正确", vbCritical
Exit Function
End If
On Error Goto 0
' 获取表格的使用范围
Set oSheet = oExcel.Worksheets(sSheetName).UsedRange
' 获取从A列到Z列,从第1行到第1000行的范围i中的所有值
Set oRange = oSheet.Range("A1:G8")
'把Excel数据转换到数组
arrRange = oRange.Value
' 关闭工作簿
oExcel.WorkBooks.Item(1).Close
' 退出Excel
oExcel.Quit
Set oExcel = Nothing
' 返回包含Excel数据的数组
ReadFile = arrRange
End Function
DataTable("check",dtlocalsheet)=arrRange(i,7)
Dialog("QtpLearn").WinEdit("Edit").SetSelection 0,1
Dialog("QtpLearn").WinEdit("Edit").Set DataTable("multi1", dtLocalSheet)
Dialog("QtpLearn").WinEdit("Edit_2").SetSelection 0,1
Dialog("QtpLearn").WinEdit("Edit_2").Set DataTable("multi2", dtLocalSheet)
Dialog("QtpLearn").WinButton("乘号*").Click
Dialog("QtpLearn").WinEdit("Edit_3").SetSelection 0,3
Dialog("QtpLearn").WinEdit("Edit_3").Check CheckPoint("Edit_6") |
|