Stop Qtp (Quick Test Professional) at the End of the Testcase

Quick Test Professional (Test Automation)

Paresh
If you are starting QTP using VB Script, then it is easy to Close the QTP again.

Below Code will help you to Start/Stop QTP

'*****************************

Dim App
StartQTP
StopQTP

' Start QTP
Function StartQTP ()
' Launch QuickTest Professional and make it visible.
Set App = CreateObject("QuickTest.Application")
App.Launch
App.Visible = True
End Function

' Stop QTP
Function StopQTP ()
App.Quit
End Function

'*****************************

Make a Note that, You can be able to Close QTP using VB Script if you have started QTP using the same Script so you can use the same Object to Close it.

If you are starting QTP outside of any other Script then you have to Kill QTP Process.

To KILL QTP Process, you can use below CODE.

'*****************************
Call KillProcessByName("QTPro")

' Kill Process By Name
Public SubKillProcessByName (ByVal psProcessName As String)

'* Iterate through all running processes to locate the specified process and kill it.

For Each pProcess As Process In Process.GetProcessesByName(psProcessName)

'* Kill the process
If Not pProcess.HasExited Then Call pProcess.Kill()
'* Wait while the process completes it's exit.
Do While Not pProcess.HasExited
Call System.Windows.Forms.Application.DoEvents()
Loop

Next 'pProcess

End Sub
'*****************************

Enjoy Automated Testing!!

Published by Paresh

I love to do Painting, Sketching, Photography and many more things. I started writing on things which interests me. I am not an expert in writing but I am trying to be a good writer :) Most of the time yo...   View profile

1 Comments

Post a Comment
  • samaira 12/4/2009

    Good job..

To comment, please sign in to your Yahoo! account, or sign up for a new account.