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.
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. ;)
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. :)
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
Hi Aaron: Thank you for the great knowledge. I recently wrote a Selenium Tutorial for Beginners and mentioned your blog at http://www.pushtotest.com/selenium-tutorial-for-beginners-tutorial-12
Would you consider Tweeting and Blogging about this mention?
-Frank
Hey Aaron,
how to create a Test Director connection with java
thanks
suriya ganesh
It is similar but you need to use a Java/COM bridge.
Jacob is an open source implementation.
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 ?
Sorry Marc, I don’t have an answer. My first guess would be try Python 2.7
Hoi Aaron,
Dont look for a second guess :-). I removed 3.3 and installed 2.7 and it works fine!
Thanks for your hint!
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
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.
Looks like it might be an interminable problem. Here’s a link that *might* be able to get a 32 bit DLL to work from 64 bit — but I have no idea. http://www.gfi.com/blog/32bit-object-64bit-environment/
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
# PERL MODULES WE WILL BE USING
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”);
I haven’t tried using Perl with OTACLIENT before, but that looks about right.
I found this script with a google search, http://h30499.www3.hp.com/t5/Quality-Center-Support-and-News/Perl-script-to-add-items-to-a-QC-Project-List-using-OTA-API/td-p/4605181#.UcnYn_l0Wf4
I’d be happy to work with you to try to get it working. Email me back and we can set up a time to work together on this.
first login to HP QC with valid credentials, project and domain, click–> help –> add-in –> click Register and wait for the process to complete
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.
That’s a puzzler. Sounds like a buffer overrun. A corrupted DLL or a bug? Did you try to convert the DLL to 64 bit or something?
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?
and my python version is 2.7, also have 3.3, but in the PATH only 2.7
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
hi, Thank you very much
as you said, I retry it use the URL:https://10.135.55.13/qcbin, it works.
thank you again, as a freshman, I’m glad you can help me.
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?
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
Thanks
Vineeth Varghese
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.
How can I integrate REST API with my selenium TestNG scripts uploading the results.
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.
When I try to Run a Test from ALM it is showing “invalid class string error” can you please help me.
Thanks in advance.
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” )
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.