执行很慢,怎么解决
需要测试的软件中,有一个步骤是输出了一个表,由于QTP不能识别软件中的表插件,所以我就把结果到处到Excel表中,然后写了一个函数来对Excel表中的数据遍历,检查。我单独使用函数来check表的时候,要比在QTP上快很多,这个该如何解决?? 估计是QTP没配置好。Tools->Options->Run,里面确保选中的是"Fast"选项 估计是QTP没配置好。Tools->Options->Run,里面确保选中的是"Fast"选项,是单步骤的执行速度,而且,建议不要使用.会有很多的错误出现.你的问题,我不理解.你是说,输出excel的时候输出慢,还是比较慢.你如何比较的?代码拿出来.看看
回复 3# 的帖子
Function check(FilePatch)Dim xlsDoc,chk_colnum,chk_rownum,chk_tmpStr,numFlag,charFlag,emptFlag,flag
Set xlsDoc = CreateObject("Excel.Application")
xlsDoc.Workbooks.Open(FilePatch)
xlsDoc.Worksheets(1).Activate
'检查列数
chk_colnum = 1
chk_tmpStr = xlsDoc.Cells(2,chk_colnum).value
While not IsEmpty(chk_tmpStr)
chk_colnum = chk_colnum+1
chk_tmpStr = xlsDoc.Cells(2,chk_colnum).value
Wend
'检查行数
chk_rownum = 1
chk_tmpStr = xlsDoc.Cells(chk_rownum,1).value
While not IsEmpty(chk_tmpStr)
chk_rownum = chk_rownum+1
chk_tmpStr = xlsDoc.Cells(chk_rownum,1).value
Wend
chk_rownum = chk_rownum -1
chk_colnum = chk_colnum-1
For chk_i=2 To chk_colnum
chk_j = 3
emptFlag = False
numFlag = False
numcombFlag = False
chinaflag = False
flag =False
While (numFlag And chinaflag)<>True And (numFlag And numcombFlag)<>True And (numcombFlag And chinaflag)<>True Andchk_j<chk_rownum
chk_tmpStr = xlsDoc.Cells(chk_j,chk_i).Value
If StrComp(chk_tmpStr,"") Then
emptFlag = True
If IsNumeric(chk_tmpStr) Then
numFlag = True
ElseIf isNumComb(chk_tmpStr) Then
numCombFlag = True
ElseIf ischina(chk_tmpStr) Then
chinaflag = True
ElseIf not StrComp(chk_tmpStr,"-") Then
flag = True
End If
End If
chk_j = chk_j+1
Wend
If numFlag And chinaflag Then
'MsgBox "1数据异常"&xlsDoc.Cells(1,1)&"---"&xlsDoc.Cells(2,chk_i)&"---该字段数据异常,可能存在没有翻译的值,请确认",,""
Reporter.ReportEvent micFail,"数据异常",xlsDoc.Cells(1,1)&"---"&xlsDoc.Cells(2,chk_i)&"---该字段数据异常,可能存在没有翻译的值,请确认"
ElseIf numFlag And numcombFlag Then
'MsgBox "2数据异常"&xlsDoc.Cells(1,1)&"---"&xlsDoc.Cells(2,chk_i)&"---该字段数据异常,可能存在没有翻译的值,请确认",,""
Reporter.ReportEvent micFail,"数据异常",xlsDoc.Cells(1,1)&"---"&xlsDoc.Cells(2,chk_i)&"---该字段数据异常,可能存在取值错误,请确认"
ElseIf Not emptFlagThen
Reporter.ReportEvent micFail,"数据异常",xlsDoc.Cells(1,1)&"---"&xlsDoc.Cells(2,chk_i)&"---该字段数据全部为空,请确认"
'MsgBox "3数据异常"&xlsDoc.Cells(1,1)&"---"&xlsDoc.Cells(2,chk_i)&"---该字段数据异常,可能存在没有翻译的值,请确认",,""
ElseIf (Not numFlag) And (Not numcombFlag) And (Not chinaflag) And flag Then
Reporter.ReportEvent micFail,"数据异常",xlsDoc.Cells(1,1)&"---"&xlsDoc.Cells(2,chk_i)&"---该字段的值都为-,请确认"
'MsgBox "5数据异常"&xlsDoc.Cells(1,1)&"---"&xlsDoc.Cells(2,chk_i)&"---该字段数据异常,可能存在没有翻译的值,请确认",,""
ElseIf numcombFlag And chinaflag Then
Reporter.ReportEvent micFail,"数据异常",xlsDoc.Cells(1,1)&"---"&xlsDoc.Cells(2,chk_i)&"---该字段数据异常,可能存在没有翻译的值,请确认"
End If
Next
xlsDoc.Quit
Set xlsDoc = Nothing
End Function
Function isNumComb(str)
Dim regEx,tmpflag
tmpflag = False
Set regEx = New RegExp
regEx.IgnoreCase = True
regEx.Pattern = "^{0,2}-{0,2}-{0,2}$"
tmpflag = regEx.Test(str)
If Not tmpflag Then
regEx.Pattern = "^{1,3}.{1,3}.{1,3}.{1,3}$"
tmpflag = regEx.Test(str)
End If
isNumComb = tmpflag
End Function
Function ischina(str)
Dim regEx,tmpflag,regEx1
tmpflag = False
Set regEx = New RegExp
regEx.IgnoreCase = True
Set regEx1 =New RegExp
regEx1.Pattern ="[\u3400-\u9FFF]"
regEx.Pattern = ""
china_k=1
char = Mid(str,china_k,1)
While regEx.Test(char)<>TrueAndregEx1.Test(char)<>True And china_k<Len(str)
china_k = china_k+1
Wend
If regEx.Test(char)<>True And regEx1.Test(char)<>True Then
ischina = False
Else
ischina = True
End If
End Function
Function splitSpace(strMen)
strMen = Trim(strMen)
loca = InStrRev(strMen," ")
While loca<>0
strMen = Left(strMen,loca-1)&Right(strMen,Len(strMen)-loca)
loca = InStrRev(strMen," ")
Wend
splitSpace = strMen
End Function
页:
[1]