How to log a Bug in ALM using OTA?

Requirement: – Logging Bug in ALM/QC programmatically, without any manual intervention.

Solution: – We will utilize the capabilities of OTA (Open Test Architecture) of ALM to log a Bug.

Approach: – Key is “TDConnection object” which is the entry point for using OTA; with this object we can access most of the functionalities of QC/ALM.

Connect to the project, Like we use to connect to ALM manually, we will follow the same steps but this time we will be using OTA .For this we need the Login Name, Password, Domain and Project details and the TDConnection object.

ALM Login window
ALM Login window


Create BugFactory object to Log a new Bug. Fill all the Bug data as we use to fill it manually.
Note: – Pass the entire compulsory field to log a Bug; otherwise it will generate an error.
New Bug Window
New Bug Window

'Function call to log the Bug

'Function Name:- fn_LogBug
'Function Description:- Logging Bug in ALM using OTA
'Input Parameters:- UserName,Password,Domain,Project( ALM)
'Output Parameters:- None
'Created By :- uftHelp Team

Public Function fn_LogBug(sUName,sPwd,sDomain,sProject)
Dim QCconn
Dim BugFact,NewBug

Set QCconn = CreateObject("TDApiOle80.TDConnection")
'Intilizing the QC connection
QCconn.InitConnectionEx ""
'Verifying User is connected
If QCconn.Connected Then
Print "User Connected to ALM Server"
Print "User is not Connected to ALM Server"
Exit Function
End If
'Filling the UserName and Password for ALM
QCconn.Login sUName,sPwd
'Verifying User is Logged into ALM
If QCconn.LoggedIn Then
Print "User is Logged into ALM Server"
Print "User is not Logged into ALM Server"
Exit Function
End If
'Connects user to specified Domain and Project
QCconn.Connect sDomain,sProject

'Using BugFactory object to log a defect
Set BugFact = QCconn.BugFactory
Set NewBug = BugFact.AddItem(Null)
On Error Resume Next
'Adding the Bug data
With NewBug
.Summary = "Issue in the Application"
.DetectedBy = "TestUser1"
.Field("BG_DETECTION_DATE") = Date
.Status = "New"
.Field("BG_DESCRIPTION") = "Testing"
.Field("BG_DEV_COMMENTS") = "Ignore it is Test Bug"
.Field("BG_PRIORITY") = "2-Medium"
.AssignedTo = "TestUser2"
.Field("BG_SEVERITY") = "3-High"
.Field("BG_USER_02") = "Cycle 1"
.Field("BG_USER_03") = "Enhancement"
End With
'Adding the Bug to ALM
If Err.Number <> "0" Then
Print "Error in logging the Bug = "&Err.Description
Print "Successfully Logged the Bug"
End If
'Destroying the objects
Set NewBug = Nothing
Set BugFact = Nothing
Set QCconn = Nothing
End Function

Leave a Reply

Your email address will not be published. Required fields are marked *