QC API and QTP AOM Scripts

Connect to QC and Add a New Defect
----------------------------------------------------
Dim qccon
Set qccon=CreateObject("TDApiOle80.TDConnection")
qccon.InitConnectionEx "http://qcserverurl:8080/qcbin"
qccon.login "username","password"
qccon.Connect "DEFAULT","QualityCenter_Demo"

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
------------------------------------------------
Connect to QC and Read all the Defects and Write in Excel
-------------------------------------------------
Dim qc,bgf,bglist,xl,ws,b,r
Set qc=CreateObject("TDApiOle80.TDConnection")
qc.InitConnectionEx "http://localhost:8080/qcbin"
qc.login "admin", "mindq"
qc.Connect "DEFAULT","QualityCenter_Demo"


Set bgf = qc.BugFactory
Set bglist = bgf.NewList("")


Set xl=CreateObject("Excel.Application")
xl.WorkBooks.Add()
Set ws=xl.ActiveSheet
r=1
For Each b In bglist
ws.Cells(r, 1).Value =b.Field("BG_BUG_ID")
ws.Cells(r, 2).Value = b.Summary
ws.Cells(r, 3).Value = b.DetectedBy
ws.Cells(r, 4).Value = b.Priority
ws.Cells(r, 5).Value = b.Status
ws.Cells(r, 6).Value = b.AssignedTo
r=r+1
Next
xl.ActiveWorkbook.SaveAs("C:\QC_Demo_defects.xls")
xl.Quit
===========================================
 To open QTP Test and count the number of repositories associated
----------------------------------------------------------------
Dim app
set app=CreateObject("QuickTest.Application")
app.launch
app.visible=True
app.open "c:\test1",False
set r=app.Test.Actions("Action1").ObjectRepositories
msgbox "Total ORs :"&r.count
for i=1 to r.count
msgbox "Path of OR :"&r.item(i)
next
app.quit
set r=nothing
set app=nothing
------------------------------------------------------------------
To count the recovery scenarios associated to the test
-------------------------------------------------------------------
dim app
set app=CreateObject("QuickTest.Application")
app.launch
app.open "c:\test1",false
app.visible=True
set rs=app.Test.settings.Recovery
if rs.count>0 then
redim a(rs.count)
for i=0 to rs.count
a(i)=rs.item(i+1).name
i=i+1
next
end if
print "The recovery scenarios associated to the test are"
for i=0 to ubound(a)
print a(i)
next
----------------------------------------------------------
script to display the list of actions and their details
----------------------------------------------------------
Dim app
set app=CreateObject("QuickTest.Application")
app.launch
app.visible=True
app.open "c:\test1"
redim a(app.Test.Actions.count)
for i=1 to app.Test.Actions.count
a(i-1)=app.Test.Actions.item(i).name&" "&app.Test.Actions.item(i).type&" "&app.Test.Actions.item(i).location
next
for i=0 to ubount(a)
print a(i)
next
=========================================

Comments