VBSCRIPT调用QTP脚本代码

上一篇 / 下一篇  2013-05-16 16:56:47 / 个人分类:VBscript


ExcQtpScript. "D:\Tests\Test4","D:\Tests\Test4\Res"

Function ExcQtpScript(TestsPath,ResPath)
KillProcess "QTPro.exe"

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

qtApp.Launch ' Start QuickTest
qtApp.Visible = True ' Make the QuickTest application visible


'settings
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Set QuickTest run options
qtApp.Options.Run.ImageCaptureForTestResults = "OnError"
qtApp.Options.Run.RunMode = "Fast"
qtApp.Options.Run.ViewResults = False
qtApp.Open  TestsPath, True ' Open the test in read-only mode
' set run settings for the test
Set qtTest = qtApp.Test
qtTest.Settings.Run.IterationMode = "rngIterations" ' Run only iterations 2 to 4
qtTest.Settings.Run.StartIteration = 1
qtTest.Settings.Run.EndIteration = 1
'qtTest.Settings.Run.OnError  'Instruct QuickTest to perform. next step when error occurs

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions") ' Create the Run Results Options object

qtResultsOpt.ResultsLocation =ResPath '"D:\Tests\Test4\Res1" ' Set the results location

qtTest.Run qtResultsOpt ' Run the test

'MsgBox qtTest.LastRunResults.Status ' Check the results of the test run

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

End Function

Function KillProcess(ByVal byName)

While FindProcess(byName)
CreateObject("WScript.Shell").Run "taskkill /f /im "&byName
Wend

End Function


Function FindProcess(ByVal ProcessName)    
  FindProcess= False    
  Set Shell = CreateObject("WScript.Shell")        
  Set ShellResult = Shell.Exec("TaskList")        
  While Not ShellResult.StdOut.AtEndOfStream          

    If Instr(UCASE(ShellResult.StdOut.ReadLine),UCASE(ProcessName)) Then
      FindProcess = True            
      Exit Function          
    End If       
        
  Wend    

End Function

TAG: QTP VBScript vbscript VBSCRIPT qtp

 

评分:0

我来说两句

我的栏目

日历

« 2024-04-22  
 123456
78910111213
14151617181920
21222324252627
282930    

我的存档

数据统计

  • 访问量: 1164
  • 日志数: 4
  • 建立时间: 2013-05-14
  • 更新时间: 2013-05-16

RSS订阅

Open Toolbar