Connecting to HP/Mercury Quality Center from a client side script

Quality Center / Test Director has hooks for writing external scripts.  This is called the Open Test Architecture (OTA) These can run on the client using COM using the OTAClient.dll or from within Test Director as a VAPI-XP test case.

You can download OTAClient.dll by logging in to Test Director and going to Help->Add-in Page->HP Quality Center Client Side Setup. 

You are prompted to install this when you first log in to Test Director from a new computer, so you might already have OTAClient installed.   Alternately, you can just install HP Quality Center Connectivity with will install OTAClient.dll without all the client-side functionality.

Note that you need to disable Windows User Account Control (UAC) to use Quality Center.

The steps for disabling UAC are slightly different for Windows Vista.

You can create a Test Director connection with VBScript or JScript, using Ruby or Python COM, with a Java COM Bridge like JACOB.

In VBScript:

Dim qc

Dim qc
Set qc = CreateObject("TDApiOle80.TDConnection")

In JScript:

var qc = new ActiveXObject("TDApiOle80.TDConnection");

In Python:

import win32com
from win32com import client
td = win32com.client.Dispatch( "TDApiOle80.TDConnection" )

I’m using Windows 7 x64 so I can’t use the 64 bit WScript/Cscript executable.  By calling my script with the 32 bit version of CScript.exe it will work.  SysWOW64 will check to see if your COM object is 32 bit and use the correct interpreter.

C:\Windows\SysWOW64\cscript.exe qc_connect.js


Likewise, with Python, you need to make sure that you have a 32 bit version of python installed, as well as 32 bit pywin32.

The important thing to remember is that you need to use the 32 bit version of each with OTAClient.dll

This was a pretty big source of headaches for me.

35 thoughts on “Connecting to HP/Mercury Quality Center from a client side script

  1. Hey Aaron,

    Thanks for the post on integrating Selenium and QC.
    Can you please give a detailed explanation of how to connect QC and selenium using OTA API and how to run selenium tests from QC?

    Thank you,

    1. I think I detailed pretty well the steps for integrating using the OTA API. Let me know if you have specific questions. You could run selenium scripts from QC by creating a VAPI_XP_TEST but I don’t know the details of that. My goal is to do as much work as I can outside of Quality Center. ;)

  2. Okay. I am not aware of how to run selenium scripts using VAPI_XP_TEST from QC. So, asked you the explanation. Anyways, no problem. Thanks. :)

  3. Hi Aaron,
    Thanks a lot for sharing this great article to explain how to connect QC via OTA API.

    “TDApiOle80” is not existed (unable to find it) on my Win7 64bits platform, but I could still connect to my QC server follow your python tutorial.

    I am able to see all the sub-folders under my “test-plan”, but I cannot check any test items under “test lab”.

    Please give me more hints on how to find the correct Root or use tree manager correctly.

    Happy New Year!

    Thanks a lot,

    1. If it’s working, you must have it installed. The file is called OTAClient.DLL and it should be downloaded when you first use Quality Center (or Test Director). TDApiOle80 is the name of the assembly — which can be confusing.

      The correct path to a testset is the word “Root” followed by the list of folders as if it were a directory


  4. Hey Aaron,

    Thanks for the info!
    I tried to connect to the QC COM object using python. I get error

    File “C:\Python33\lib\site-packages\win32com\client\”, line 89, in _GetGoodDispatch
    IDispatch = pythoncom.connect(IDispatch)
    pywintypes.com_error: (-2147221021, ‘Operation unavailable’, None, None)

    at the

    td = win32com.client.Dispatch( “TDApiOle80.TDConnection” )

    I am using the 32 bit python version on a 64bit PC
    It works fine connecting to the “Excel.Application” COM object
    It works fine connecting to the QC COM object from vba

    Any idea ?

      1. Hoi Aaron,

        Dont look for a second guess :-). I removed 3.3 and installed 2.7 and it works fine!
        Thanks for your hint!

      2. Glad it’s working for you, Marc.
        If you still need to use Python 3 you can have it installed alongside and just mess with the path. What I do I create an alias so “python” runs 2.7 and “python3” runs 3.3

  5. Is there a similar workaround that will work with Excel 2010 (64-bit) VBA (i.e. not VBScript)?

    Set tdc = New TDConnection fails with Err.Number 429 “ActiveX component can’t create object” when executing in Excel 2010 (64-bit) VBA.

      1. Hi fijiaaron : I want to connect to QC via perl script. I am using 32 bit computer, OTACLIENT.dll already installed. I am using below code, but not able to setup any connection, Could you please help me #!C:\wamp\bin\perl\bin\perl -w


        use warnings;

        use Win32::OLE;
        use strict ;

        use CGI qw(:standard);

        use Data::Dumper;

        # HTTP HEADER
        print header;

        # Instantiate counter vars.
        my ($i, $j, $k);

        my $tdc = Win32::OLE->new(“TDApiOle80.TDConnection”);

    1. first login to HP QC with valid credentials, project and domain, click–> help –> add-in –> click Register and wait for the process to complete

  6. I ran VBS script with following command
    C:\Windows\SysWOW64\wscript c:\test\sample.vbs
    In my VBS file having following code

    Set tdc = CreateObject(“TDApiOle80.TDConnection”)
    tdc.InitConnectionEx “URL”
    tdc.Login “Username”, “PWD”
    tdc.Connect “DEFAULT”, “QC_****”

    I am using windows 7 and QC 9.1

    I am getting following error message
    “Invalid access to memory location.”

    Please help me how to solve this.

  7. from win32com.client import Dispatch
    def get_QCConnection():
    QCConnection = Dispatch(“TDApiOle80.TDConnection”)
    url = “”
    QCConnection.Login(“xianjche”, “#EDCvfr4”)
    QCConnection.Connect(“MBB_BTS”, “RP_BTS_IV”)
    return QCConnection

    conn = get_QCConnection()

    but when I run it. error raise up:
    raceback (most recent call last):
    File “C:\Users\chenrxia\Desktop\Workspaces\PYTHON\Scripts\”, line 80, in
    conn = get_QCConnection()
    File “C:\Users\chenrxia\Desktop\Workspaces\PYTHON\Scripts\”, line 52, in get_QCConnection
    QCConnection.Login(“xianjche”, “#EDCvfr4”)
    File “”, line 3, in Login
    pywintypes.com_error: (-2147352567, ‘Exception occurred.’, (0, None, u’Invalid server response’, u’Apache Tomcat/5.5.9 – Error report HTTP Status 404 – /qcbin/start_a.htm/servlet/tdservlet/TDAPI_GeneralWebTreatmenttype Status reportmessage /qcbin/start_a.htm/servlet/tdservlet/TDAPI_GeneralWebTreatmentdescription The requested resource (/qcbin/start_a.htm/servlet/tdservlet/TDAPI_GeneralWebTreatment) is not available.Apache Tomcat/5.5.9′, 0, -2147482494), None)

    Could you tell me how to solve it?

      1. Carl-

        It looks like it’s not connecting to the QC server — it’s probably getting a generic error from Tomcat (such as a 404 (Not Found), 403 (Forbidden), or 500 (Internal Server Error). First check that your URL works by entering it in the browser. If you are able to login in manually, maybe next try a URL

  8. Hi,

    Trying to use the connection below as described using Python 3.3 (32bit)
    import win32com
    from win32com import client
    td = win32com.client.Dispatch( “TDApiOle80.TDConnection” )

    But getting this error, all the time..
    Traceback (most recent call last):
    File “c:\Python33\lib\site-packages\win32com\client\”, line 89, in _
    IDispatch = pythoncom.connect(IDispatch)
    pywintypes.com_error: (-2147221005, ‘Invalid class string’, None, None)

    During handling of the above exception, another exception occurred:
    Traceback (most recent call last):
    File “”, line 49, in
    File “”, line 48, in main
    File “”, line 16, in retrieveALMXMLData
    t = Dispatch(“TDApiOle80.TDConnection.1”)
    File “c:\Python33\lib\site-packages\win32com\client\”, line 95, in
    dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,c
    File “c:\Python33\lib\site-packages\win32com\client\”, line 114, in
    return (_GetGoodDispatch(IDispatch, clsctx), userName)
    File “c:\Python33\lib\site-packages\win32com\client\”, line 91, in _
    IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.II
    pywintypes.com_error: (-2147221005, ‘Invalid class string’, None, None)

    Not sure what causes this error.
    Any advice to get around this?

  9. hi ,

    Could you please help me with updating the QC test results if the corresponding selenium Automated tests have passed.

    My tests are running through Bamboo and now , i need to update the corresponding manual test case, Pass/Fail

    Please advise

    Vineeth Varghese

  10. Hi Aaron,

    First of all thanks for sharing the good knowledge.
    Am able to execute the scripts using OTA API but now I want to use latest REST API.
    Could you please explain how can I implement it.

    Thanks In Advance.

      1. I haven’t used the new REST API in QC 11 / ALM but would be happy to implement a solution. Contact me for my consulting rates.

  11. When I try to Run a Test from ALM it is showing “invalid class string error” can you please help me.

    Thanks in advance.

  12. In Python your either use the full name of the import or a short name.
    So the example can be shorter, this should work fine:
    import win32com
    td = win32com.client.Dispatch( “TDApiOle80.TDConnection” )

  13. I have registerred OTAClient.dll…say the pop up message DLL was registered. Still if i run test case from Eclipse it in Console it shows OTAClient dll has to be registered.

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 )

Connecting to %s