QTP: Launching QTP through a VB script

Following VB script can be used to launch QTP.

   1: Dim QTPObj

   2: Dim QTPTest

   3: Set QTPObj=CreateObject("QuickTest.Application")

   4: If Not QTPObj.Launched then

   5:     QTPObj.Launch

   6: End if

   7: QTPObj.Visible=True

   8: QTPObj.Open "Path of QTP script"

   9: Set QTPTest=QTPObj.Test

  10: QTPTest.Run

  11: QTPTest.Close

  12: QTPObj.Quit

Line by line Explanation:-
Line 1: Declare object for QTP
Line 2: Declare object for QTP test
Line 3: Create QTP object
Line 4: If condition to verify if QTP is running or not
Line 5: If QTP is not running, launch QTP session
Line 6: End of if statement
Line 7: Make QTp Visible. If thi sproperty is set to False, QTP qould be launched (at backend), but would not be visible to user.
Line 8: Open the QTP test to run by specifying  the path
Line 9: Map the QTP test with object
Line 10: Run the QTP test
Line 11: Afterthe test is completed. close QTP
Line: Quitting the obect created.

1 thought on “QTP: Launching QTP through a VB script”

Comments are closed.