|
《QTP项目应用与进阶》有比较详细的介绍
我也附一段我的代码,楼主只需要修改代码加一层循环即可:
Set obj = CreateObject("QuickTest.Application") 'Creates an instance of the QTP
obj.Launch
obj.Visible = true
obj.WindowState = "Maximized" 'Maximizes the application window of the QTP
obj.open "c:\framework\frameworkcore\core data\test"
Set qtLibraries = obj.Test.Settings.Resources.Libraries ' Get the libraries collection object
If qtLibraries.Find("c:\framework\frameworkcore\"&app&"\core data\main.vbs") = -1 Then
qtLibraries.Add "c:\framework\frameworkcore\"&app&"\core data\main.vbs", 1
End If
'Set qtTestRecovery = obj.Test.Settings.Recovery
'qtTestRecovery.Add "C:\Framework\FrameworkCore\Core Data\Recovery.qrs", "pop-up", 1
'' Enable all scenarios
'For intIndex = 1 To qtTestRecovery.Count ' Iterate the scenarios
' qtTestRecovery.Item(intIndex).Enabled = True ' Enable each Recovery Scenario (Note: the 'Item' property is default and can be omitted)
'Next
'' Enable the recovery mechanism (with default, on errors, setting)
'qtTestRecovery.Enabled = True
''Ensure that the recovery mechanism is set to be activated only after errors
'qtTestRecovery.SetActivationMode "OnError"
''OnError is the default, the other option is "OnEveryStep".
WScript.Echo "Running Qtp in Silent Mode..."
obj.Test.Run 'Runs the script
wscript.sleep(7000)
WScript.Echo "QTP script execution completed..."
obj.Test.Close ' Close the test
WScript.Echo "Closing Qtp...."
obj.quit 'Close QTP |
|