标题: qtp多循环执行用例,出现can'open the test [打印本页] 作者: guoxiaojun 时间: 2009-7-17 15:36 标题: qtp多循环执行用例,出现can'open the test qtp多循环执行用例,出现can'open the test
Do 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
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"
'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作者: guoxiaojun 时间: 2009-7-17 15:41
其中
'启动一个监控进程
'Set shell1 = CreateObject("wscript.shell")
'shell1.Run "wscript.exe F:\shutdownqtp.vbs"