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

see http://www.sqaforums.com/showflat.php?Number=479531

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.

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

  1. Pingback: A Smattering of Selenium #25 « Official Selenium Blog

  2. Pingback: Upload Selenium/JUnit test results to Quality Center « Fiji Ecuador Seattle Greece Montana

  3. 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,
    Ratsy

    • 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. ;)

  4. 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. :)

  5. 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,
    Webber

    • 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

      Root/Folder/TestSet

  6. Pingback: Selenium QC integration summary « Fiji Ecuador Seattle Greece Montana

  7. Pingback: Selenium QC integration update « Fiji Ecuador Seattle Greece Montana

  8. 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\dynamic.py”, line 89, in _GetGoodDispatch
    IDispatch = pythoncom.connect(IDispatch)
    pywintypes.com_error: (-2147221021, ‘Operation unavailable’, None, None)

    at the

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

    command.
    Info:
    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 ?

  9. 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.

  10. 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.

  11. from win32com.client import Dispatch
    def get_QCConnection():
    QCConnection = Dispatch(“TDApiOle80.TDConnection”)
    url = “https://10.135.55.13/qcbin/start_a.htm”
    QCConnection.InitConnectionEx(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\test.py”, line 80, in
    conn = get_QCConnection()
    File “C:\Users\chenrxia\Desktop\Workspaces\PYTHON\Scripts\test.py”, 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?

      • 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 https://10.135.55.13/qcbin

  12. 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\dynamic.py”, line 89, in _
    GetGoodDispatch
    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 “alm_jira_sync.py”, line 49, in
    main()
    File “alm_jira_sync.py”, line 48, in main
    retrieveALMXMLData()
    File “alm_jira_sync.py”, line 16, in retrieveALMXMLData
    t = Dispatch(“TDApiOle80.TDConnection.1″)
    File “c:\Python33\lib\site-packages\win32com\client\__init__.py”, line 95, in
    Dispatch
    dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,c
    lsctx)
    File “c:\Python33\lib\site-packages\win32com\client\dynamic.py”, line 114, in
    _GetGoodDispatchAndUserName
    return (_GetGoodDispatch(IDispatch, clsctx), userName)
    File “c:\Python33\lib\site-packages\win32com\client\dynamic.py”, line 91, in _
    GetGoodDispatch
    IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.II
    D_IDispatch)
    pywintypes.com_error: (-2147221005, ‘Invalid class string’, None, None)
    ——

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

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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