QTP AOM Scripts

'Script To open QTP and run Test

Dim app
set app=CreateObject("QuickTest.Application")
app.launch
app.visible=True
app.open "E:\venkatgn\Test1"

''Script to connect to Quality Center From QTP
Set app=CreateObject("QuickTest.Application")
app.Launch
app.Visible = True
app.TDConnection.Connect "QCURL","DOMAIN","PROJECT","USERNAME","PASSWORD",False

''Example : app.TDConnection.Connect "http://192.168.1.1:8080/qcbin","Default","proj1","venkat",,false

'''Script to Connect to QC and Add a new Defect in QC from QTP
Dim qccon
Set qccon=CreateObject("TDApiOle.TDConnection")
qccon.InitConnection "http://qcserverurl:8080/qcbin"
qccon.ConnectProject "proj1","venkat",""
If qccon.Connected Then
    Msgbox "Connected to QC Server
Else
   MsgBox "Not Connected"
End If

Set BugFactory = qccon.BugFactory
Set Bug = BugFactory.AddItem(Nothing)
Bug.Status = "New"
Bug.Summary = "Error in login"
Bug.Priority = "4-Very High"
Bug.AssignedTo ="user1"
Bug.DetectedBy = "venkat"
Bug.Post

' Close QTP After execution of the Test
set wm=GetObject("winmgmts:\\.\root\CIMV2")
Set pros=wmi.ExecQuery("Select * from Win32_Process Where Name = 'QTPro.exe'")
For Each p in pros
   p.Terminate()
Next
Set wmi=Nothing
Set pros=Nothing

Comments