Dim qtApp 'As QuickTest.Application ' Declare the Application object variable
Dim qtTest 'As QuickTest.Test ' Declare a Test object variable
Dim qtResultsOpt 'As QuickTest.RunResultsOptions ' Declare a Run Results Options object variable
Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object
Dim fso, f
Dim myReg
Dim myString,myResult
myString = ".*\\([^\:]+)"
qtApp.Launch ' Start QuickTest
qtApp.Visible = True ' 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 = WScript.CreateObject("scripting.filesystemobject")
Set f=fso.OpenTextFile("D:\QTPScript\testcase.txt", 1, false)
For i = 1 To 5
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
qtTest.Settings.Run.OnError = "NextStep" ' Instruct QuickTest to perform next step when error occurs
Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions") ' Create the Run Results Options object
qtResultsOpt.ResultsLocation = "C:\QTPScript\result\" & myResult & "_" & i ' Set the results location
qtTest.Run qtResultsOpt 'Run the test
Loop
Next
'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作者: 风雪夜归人 时间: 2009-4-23 23:13
我发觉我的for循环写错位置了。。Next应该写在f。close后面,运行脚本5次作者: virgolong 时间: 2009-4-23 23:31
真的要非常感谢风雪夜归人,这么晚还在回帖,又学到东西了。
前些天看贴还奇怪把QTP当作个对象干什么用了,原来可以这样用的。可不可以把你的脚本给个我看看啊,好好学习下作者: virgolong 时间: 2009-4-23 23:35
另外,对于测试脚本加载vbs,我还有个问题
test1测试脚本有vbs文件,定义了变量s,赋值1;test2测试脚本有vbs文件,定义了变量s,赋值2
我在测试时新建一个脚本,调用test1的,再调用test2,发觉test1、test2定义的变量都没生效,值都是空的。
这种调用脚本时,vbs文件怎么处理啊