qtp多循环执行用例,出现can'open the test
qtp多循环执行用例,出现can'open the testDo While CStr(timeing)<>mid(CStr(time()),1,5)'到指定执行时间
wscript.sleep 500
Loop
myString = ".*\\([^\:]+)"
err_flag = 0
qtApp.Launch ' Start QuickTest
WriteToFile(Time&"----QTP is running test! Ant's request stop the current test. The newset vesion test start!----") ’写日志到指定txt文本中
qtApp.Visible = false ' Make the QuickTest application visible
' Set QuickTest run options
qtApp.Options.Run.ImageCaptureForTestResults = "OnError"
qtApp.Options.Run.RunMode = "Fast"
qtApp.Options.Run.ViewResults = False
qtApp.Options.Run.CaptureForTestResults = "OnWarning"
set fso = CreateObject("scripting.filesystemobject")
looktype = "0"
For i = 1 To run_times
Set f=fso.OpenTextFile("F:\test.txt", 1, false) 'test.txt中存储需要执行的用例的执行路径
Do While f.AtEndOfStream <> True
retstring = f.ReadLine
Set myReg = New RegExp
myReg.Pattern = myString
myReg.IgnoreCase = True
myResult = myReg.Replace(retstring,"$1")
qtApp.Open retstring, True ' Open the test in read-only mode
' set run settings for the test
Set qtTest = qtApp.Test
Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions") ' Create the Run Results Options object
qtResultsOpt.ResultsLocation =retstring&"\Res"&i
wrongresult = retstring&"\Res"&i
'判断是否有Resi或者本次循环的报告结果文件夹,如果有,将其删除
Set fso=createobject("scripting.filesystemobject")
If(fso.FolderExists(wrongresult)) Then
fso.deleteFolder wrongresult
If(fso.FileExists(wrongresult&".zip")) Then
fso.DeleteFile wrongresult&".zip"
End If
End If
Set pDefColl = qtApp.test.ParameterDefinitions
Set rtParams = pDefColl.GetParameters()
'------------------------------------------------------
'启动一个监控进程
'Set shell1 = CreateObject("wscript.shell")
'shell1.Run "wscript.exe F:\shutdownqtp.vbs"
qtApp.test.Run,True,rtParams 'Run the test
'如果正常执行完成,kill掉监控进程
'Set shell = createobject("wscript.shell")
'shell.run "taskkill /f /im WScript.exe",0
looktype = "0"
'-------------------------------------------------------
WriteToFile(" ")
WriteToFile(Time&wrongresult&" is running")
If rtParams.Item("OutParam1").Value = False Then
tmp = filezipsendmail(i,wrongresult,smstomail)
tmp = send_mobile(smstomobile,wrongresult)
If tmp="1" Then
WriteToFile(Time&wrongresult&" 短信发送成功") ‘发送短信通知,如果执行用例失败
Else
WriteToFile(Time&wrongresult&" 短信发送失败") ‘发送报告到邮件,如果执行用例失败
End If
WriteToFile(Time&wrongresult&" is failed")
Else
WriteToFile(Time&wrongresult&" is succ")
End If
tmp = closeie()
WriteToFile(" ")
If(fso.FolderExists(wrongresult)) Then
fso.deleteFolder wrongresult
End If
wscript.sleep 5000
Loop
f.close
Next
qtTest.Close
'qtTest.Close ' Close the test
Set qtResultsOpt = Nothing ' Release the Run Results Options object
Set qtTest = Nothing ' Release the Test object
Set qtApp = Nothing ' Release the Application object 其中
'启动一个监控进程
'Set shell1 = CreateObject("wscript.shell")
'shell1.Run "wscript.exe F:\shutdownqtp.vbs"
qtApp.test.Run,True,rtParams 'Run the test
'如果正常执行完成,kill掉监控进程
'Set shell = createobject("wscript.shell")
'shell.run "taskkill /f /im WScript.exe",0
这段代码本意是想要启动另一进程A,对qtp进行监控,如果qtp的执行超过半个小时,则杀掉qtp进程,并且重起qtp,如果没有超过半小时,还有一条进程B将A进程杀掉
执行的时候,发现qtp被杀掉后再重起是不能重起的,猜测其原因,可能是杀掉qtp进程后,它的某些东西没有来得及写道内存中,导致再次重起qtp时出现问题。
此问题也请教高人指教,或者有没有其它办法对qtp进行监控,如果qtp本身程序crash掉了。 循环执行用例,执行到3次或4次的时候就会出现这个错误can't open test,:Q
请各位指导下,有任何意见都欢迎给出,集思广益哈~~~~
页:
[1]