Sunday, July 31, 2011

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:\ahamad\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","ahamad",,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","ahamad",""
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 = "ahamad"
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

No comments:

Post a Comment