Connecting ALM/QC using HP’s OTA (Open Test Architecture) API – Advanced


In this post, we will learn about how to create a connection to ALM using OTA API.

1. Introduction

Open Test Architecture is an API shipped with HP ALM/QC, for automating background tasks like modifying bulk field values or downloading all of the attachments from the defects module. We can also use this API for Generating bulk reports, custom graphs and have the functionality built which is not available otherwise using the ALM/QC front end application.

OTA API’s object will be downloaded and registered in the machine when we open ALM for the first time. Once the components are registered, you can use the OTA COM Type Library for connecting ALM using any programming language which supports COM objects.

we will use Excel 2010 for connecting and accessing ALM/QC using OTA API.

2. Connecting to ALM using OTA API

Below are the steps for using OTA API for ALM Connection

A) Open Excel and Click on Developer ribbon and Click Visual Basic.

B) Click on Tools-> References and Check “OTA COM Type Library”.



Once we have the reference for this library, we can use the following code for connecting to ALM/QC

Dim ErrorString As String

'Create Connection Object of OTA API
Dim OQCConnection As New TDAPIOLELib.TDConnection

Sub TestALMOTAConnection()
 If ConnectALM("http://yourQCServer/qcbin", "yourusername", "password", "yourdomainname", "yourprojectnane") = True Then
 MsgBox "Connected to ALM"

 If DisConnectALM = True Then
 MsgBox "Project Disconnected Successfuly"
 MsgBox ErrString
 End If

 MsgBox ErrorString
 End If
End Sub

Public Function ConnectALM(URL As String, UserName As String, Password As String, Domain As String, Project As String)

 On Error GoTo Err_Handler

 ErrorString = ""

 'Initiate connection with ALM Server
 OQCConnection.InitConnectionEx URL

 'Connect to User

 OQCConnection.Login UserName, Password

 'Connect to Domain and Project
 OQCConnection.Connect Domain, Project

 '"Successfully Connected to the project, Enjoy!!!"

 ConnectALM = True

 Exit Function


 'Check if the connection is successfull
 If OQCConnection.Connected = False Then
 ErrorString = "QC Server URL Initialization failed!!!"
 ConnectALM = False
 Exit Function
 End If

 'Check if Login is Successfull
 If OQCConnection.LoggedIn = False Then
 ErrorString = "Unable to Login to ALM using the provided Credentials"
 ConnectALM = False
 Exit Function
 End If

 'Check if project is connected
 If OQCConnection.ProjectConnected = False Then
 ErrorString = "Unable to Connect to the Domain or Project"
 ConnectALM = False
 End If

End Function

Public Function DisConnectALM()
 On Error GoTo Err_Handler

 ErrString = ""

 If OQCConnection.ProjectConnected Then
 End If

 If OQCConnection.LoggedIn Then
 End If

 If OQCConnection.Connected Then
 End If

 'Logged Out of QC

 DisConnectQC = True

 Exit Function

 If OQCConnection.Connected Then
 ErrString = "Error Occurred while Disconnecting the QC Connection Object"
 End If

 If OQCConnection.ProjectConnected Then
 ErrString = "Error Occurred while disconnecting project"
 End If

 If OQCConnection.LoggedIn Then
 ErrString = "Error Occurred while Loggin out the User"
 End If

 DisConnectQC = False
End Function

Once, you copy the above code, update the variables for a call to the function ConnectALM and execute TestOTAALMConnection function. If everything works fine then you should see a message ‘Connected to ALM’.

Now, let’s understand how the code works here,

Variables used

1) ALM URL: For connecting to ALM using OTA API, we must use the URL till qcbin instead of full ALM URL, e.g. ‘http://<YourServer>/qcbin&#8217;.

All other variables should be provided with the values, you are using for connecting to ALM/QC

Functions used

1) InitConnectionEx: This function is used for initializing the connection between ALM and your code. If ALM server is accepting connections.

2) Connected: This property will be false if the connection initialization is not completed.

2) Login: Login functions accepts ALM Username and password and used for login to the ALM/QC Server.

3) LoggedIn: This property is used for identifying, if user login was successful or not in the previous step. Login function will through error and we will have to use

4) Connect: This function will accept domain name and project name and will connect to ALM Project.

5) ProjectConnected: This function will provide details about if the Connection to the project was successful.

Now let’s see how to disconnect ALM connection, which will be similar to Logout functionality using the ALM GUI.

For Logging out of ALM we have to call the corresponding logout functions to InitConnectionEx, Login and Connect. These functions are used in the DisConnectALM function. Below is the description of the function used for disconnecting ALM


1) Disconnect: This function will disconnect the ALM Project.

2) Logout: This function will log out the user connected.

3) ReleaseConnection: This function will release the ALM connection object, after calling this function we will loose all of the references with ALM server.

Below is the table for showing the method property relationship of the functions and properties used above

       Method (Initial) Init-ConnectionEx Login Connect Disconnect Logout Release-Connection
ServerName Empty String Server Name Server Name Server Name Server Name Server Name Empty String
ProjectName Error Empty String Empty String Project Name Empty String Empty String Error
Project-Connected Error FALSE FALSE TRUE FALSE FALSE Error

We will discuss about accessing and changing specific ALM modules in the later posts.



23 responses to “Connecting ALM/QC using HP’s OTA (Open Test Architecture) API – Advanced

  1. Pingback: DOWNLOADING ATTACHMENTS FROM ALM/QC, Tests and Design Steps module | Automation Insights·

  2. Pingback: Filtering Test from Test Plan using Test ID (TS_TEST_ID) in ALM/QC | Automation Insights·

  3. Pingback: Filtering Defects using Defect ID (BG_BUG_ID) in ALM/QC | Automation Insights·

  4. Hi Sumeet,

    I want to run Single test case from ALM test set, can you help me in achieving through OTA, I want to create one single vbs to do this.



  5. Hi,

    I am looking for a sample to download the Results tab files using VBcode. Could you please advise.


  6. Hi,
    Following error thrown while creating connection object:
    “Retrieving the COM class factory for component with CLSID {C5CBD7B2-490C-45F5-8C40-B8C3D108E6D7} failed due to the following error: 800703e6 Invalid access to memory location. (Exception from HRESULT: 0x800703E6).”


  7. Hi Sumeeth,
    can we add values while passing test case in test set like domain name,test type,Environment and can we click on pass all and end run and can be capture run id as well?


    • Hi Orel

      What are the steps to replicate the error ? Which programming language you are using ?
      What is the version of ALM you are using ?

      I don’t see error code 429 in the list of error codes available for OTA API. Can you send me the description for the error ?

      Sumeet singh kushwah


  8. Hi Sumeet,

    The article is very informative, Thanks.

    Using the below code, I am not able to open the ALM. There is no error also. Could you please guide
    Dim QCConnection As Object;

    Set QCConnection= createObject (‘TDApiOle80.TDConnection’)

    Dim sUsername, sPassword

    Dim sProject, sDomain





    QCConnection.InitConnectionEx sheet1.Range(E1).Value

    QCConnection.login sUsername,sPassword

    QCConnection.connect sDomain,sProject


  9. Pingback: Executing Queries using OTA API | Automation Insights·

  10. Pingback: Renaming test plan folder using OTA API | Automation Insights·

  11. Pingback: Deleting ALM test plan folder using OTA API | Automation Insights·

  12. Pingback: Find tests under a test plan folder using OTA API | Automation Insights·

  13. Pingback: Find folders under test plan folder in ALM using OTA API | Automation Insights·

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s