日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

VB 调用 QuickTestpro 脚本

發布時間:2025/3/19 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 VB 调用 QuickTestpro 脚本 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
今天幫一個加拿大的朋友解決VB調用QTP的問題,自己寫了一個Demo 。 下邊是源代碼 1.新建工程,引入QuickTest Professional 8.0 object library 2.編寫代碼如下: Private strScriptName As String
Private strRunScript As String
Private Sub cmdAddScript_Click()
?? strScriptName = InputBox("請輸入QuickTestPro腳本的路徑以及名字", "Select Script")
?? lstQtpScript.AddItem strScriptName
?? strScriptName = ""
End Sub Private Sub cmdRunScript_Click() If strRunScript = "" Then
?? MsgBox "please select you want to a running script in listbox"
Else
??? 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.CaptureForTestResults = "OnError"
??? qtApp.Options.Run.RunMode = "Fast"
??? qtApp.Options.Run.ViewResults = False
????
??? qtApp.Open strRunScript, 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 = strRunScript + "\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
??? qtApp.Quit? 'Close QuickTestPro
????
??? Set qtResultsOpt = Nothing ' Release the Run Results Options object
??? Set qtTest = Nothing ' Release the Test object
??? Set qtApp = Nothing ' Release the Application object strRunScript = ""
?End If End Sub Private Sub Form_Load()
? strScriptName = ""
? strRunScript = ""
End Sub Private Sub lstQtpScript_Click()
? strRunScript = lstQtpScript.Text
End Sub
由于不是具體講vb的使用所以里面如何新建工程等都省略掉了,如果大家有興趣可以自己找相關書籍學習。 以上代碼在vb6.0 winxp sp2調試通過。



本文轉自 fish_yy 51CTO博客,原文鏈接:http://blog.51cto.com/tester2test/139362,如需轉載請自行聯系原作者

總結

以上是生活随笔為你收集整理的VB 调用 QuickTestpro 脚本的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。