As promised, check the code below will let you connect to QC
the below walks you through the test tree and updates the status of test cases.
you can use this as a function can call it in python script to update.
this was pretty useful to me , hops is the same case with you.
import win32com
from win32com.client import Dispatch
qcServer = "http://xxxxxxxxx/qcbin/"
qcUser = "xxxxx"
qcPassword = "xxxxx"
qcDomain = "xxxx"
qcProject = "xxxx"
t = win32com.client.Dispatch("TDApiOle80.TDConnection.1")
t.InitConnectionEx(qcServer)
t.Login(qcUser,qcPassword)
t.Connect(qcDomain,qcProject)
print "Logged in"
mg=t.TreeManager
npath="Root\xxxxxx"
tsFolder = t.TestSetTreeManager.NodeByPath(npath)
print tsFolder
tfactory=tsFolder.TestSetFactory
td_tsff=tfactory.Filter
td_testset=td_tsff.NewList()
for otest in td_testset:
print otest.Name
td_TSTestSetFactory = otest.TSTestFactory
td_tstsff = td_TSTestSetFactory.NewList("")
for otestitem in td_tstsff:
print otestitem.Name
td_RunFactory = otestitem.RunFactory
obj_theRun = td_RunFactory.AddItem("testrun")
obj_theRun.Status = "Passed"
otestitem.Status= "Passed"
obj_theRun.Post()
print otestitem.Status
next
next
tsFolder = None
tfactory = None
td_testset = None
td_TSTestSetFactory = None
td_RunFactory = None
obj_theRun = None
t.logout
t = None
print "done"
If you have doubts about this , leave me a comment , I can get back to you with details.
ReplyDeleteHow can I do this in Linux/Unix environment instead of windows?
DeleteHi I am getting error while executing this step
ReplyDeleteobj_theRun = td_RunFactory.AddItem("testrun")
File ">", line 2, in AddItem
Please help
This comment has been removed by the author.
ReplyDeleteHi thanks for your script it solved my requirement. but I have one more requirement, how can I read only one testcase with given nodepath for the same.
ReplyDeleteHi. Thank you for posting this code. It has been very helpful. However could you please explain what was your reference for QC side functions? For example how can I access bugs list rather than tests? Thanks again.
ReplyDeleteHi,
ReplyDeleteWhen i execute the above script, i am gettign error in line
"t.InitConnectionEx(qcServer)"
Error i am getting is,
HTTP Status 404 - /qcbin/start_a.jsp/servlet/tdservlet/TDAPI_GeneralWebTreatment
Thank you.
Did you get the solution for this.
ReplyDeleteI am facing the same problem.
I am getting error at tfactory=tsFolder.TestSetFactory
ReplyDeleteCan U pls help me out. I m new to HPQC and Python
I am getting error at tfactory=tsFolder.TestSetFactory
ReplyDeleteCan U pls help me out. I m new to HPQC and Python
Great work, this helps lot for me. Thanks
ReplyDeleteHai,
ReplyDeleteAm getting a error:
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\win32com\client\dynamic.py", line 89, in _GetGoodDispatch
IDispatch = pythoncom.connect(IDispatch)
pywintypes.com_error: (-2147221021, 'Operation unavailable', None, None)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\work\Workspace\Test\src\ALM.py", line 11, in
t = Dispatch("TDApiOle80.TDConnection.1")
File "C:\Python34\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch
dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
File "C:\Python34\lib\site-packages\win32com\client\dynamic.py", line 114, in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "C:\Python34\lib\site-packages\win32com\client\dynamic.py", line 91, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
pywintypes.com_error: (-2147221164, 'Class not registered', None, None)
Can you please help me how to figure it out.
I am also faced the same , instead of storing https://10.135.55.24/qcbin/ in qcserver i have passed value straightaway like t.InitConnectionEx('https://10.135.55.24/qcbin/') its working fine. Hope it helps
ReplyDeleteCould you please let me know if there is a way to update the Step Name, Step Description, expected , actual and test status.
ReplyDeletehi iam getting below error-
ReplyDeleteTraceback (most recent call last):
File "C:\Users\Ajit_Mallick\PycharmProjects\Test\venv\lib\site-packages\win32com\client\dynamic.py", line 89, in _GetGoodDispatch
IDispatch = pythoncom.connect(IDispatch)
pywintypes.com_error: (-2147221021, 'Operation unavailable', None, None)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/Ajit_Mallick/PycharmProjects/Test/alm.py", line 46, in
d = number_of_steps("rd")
File "C:/Users/Ajit_Mallick/PycharmProjects/Test/alm.py", line 11, in number_of_steps
td = win32com.client.Dispatch("TDApiOle80.TDConnection")
File "C:\Users\Ajit_Mallick\PycharmProjects\Test\venv\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch
dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
File "C:\Users\Ajit_Mallick\PycharmProjects\Test\venv\lib\site-packages\win32com\client\dynamic.py", line 114, in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "C:\Users\Ajit_Mallick\PycharmProjects\Test\venv\lib\site-packages\win32com\client\dynamic.py", line 91, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
pywintypes.com_error: (-2147221164, 'Class not registered', None, None)
Nice work, so if anyone want to convert one file into another then use this converter;
ReplyDeleteSimple File Converter
That converter can easily convert one file into another like those;
ReplyDeleteOds to Pdf
Vob to Mp4
Mov to Flv
Mpg to Avi
Mxf to Mov