VB調(diào)用QTP

今天幫一個加拿大的朋友解決VB調(diào)用QTP的問題,自己寫了一個Demo 。

創(chuàng)新互聯(lián)建站主要從事網(wǎng)站建設(shè)、成都做網(wǎng)站、網(wǎng)頁設(shè)計、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)靖江,10年網(wǎng)站建設(shè)經(jīng)驗,價格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):028-86922220

下邊是源代碼

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. ' 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的使用所以里面如何新建工程等都省略掉了,如果大家有興趣可以自己找相關(guān)書籍學(xué)習(xí)。

以上代碼在vb6.0 winxp sp2調(diào)試通過。

網(wǎng)頁名稱:VB調(diào)用QTP
本文路徑:http://www.muchs.cn/article8/piejip.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供自適應(yīng)網(wǎng)站、網(wǎng)站策劃、網(wǎng)頁設(shè)計公司、網(wǎng)站排名、服務(wù)器托管、靜態(tài)網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)