声明:本空间大部分博客信息为寻找问题时在网上拷贝或转载,在此博客中做个记录,方便自己也方便有类似问题的朋友,因原出处已不好查询,如有侵权,请发邮件表明文章和原出处地址,本人一定会在文章中注明。谢谢。

如何在VBScript中调用QTP脚本

上一篇 / 下一篇  2012-10-11 10:34:05 / 个人分类:QTP自动化测试

现在有一个用QTP录制好的脚本,但是想用VBS来调用,如何调用?

 

 

 

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

 

' Set QuickTest run options

qtApp.Options.Run.ImageCaptureForTestResults = "OnError"

 

qtApp.Options.Run.RunMode = "Fast"

qtApp.Options.Run.ViewResults = False

 

qtApp.Open "C:\Tests\Test1", 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 = 2

qtTest.Settings.Run.EndIteration = 4

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:\Tests\Test1\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
 

TAG:

 

评分:0

我来说两句

日历

« 2024-05-22  
   1234
567891011
12131415161718
19202122232425
262728293031 

数据统计

  • 访问量: 30052
  • 日志数: 54
  • 建立时间: 2012-02-29
  • 更新时间: 2012-10-17

RSS订阅

Open Toolbar