Photo by Dieter de Vroomen on Unsplash
Here is a Python script that will export out test cases in a folder from Quality Center into a CSV file.
The following script will not handle Attachments. Will work on that later when I have time.
1import win32com, win32com.client23import HTMLParser4class MLStripper(HTMLParser.HTMLParser):5 def __init__(self):6 self.reset()7 self.fed = []8910 def handle_data(self, d):11 self.fed.append(d)121314 def get_fed_data(self):15 return ''.join(self.fed)161718def sanitize(data):19 s = MLStripper()20 s.feed(data)21 return s.get_fed_data()222324def recursiveExport(f, qc, node):25 if not node:26 return27 f.write('%s, %s\n' %(node.Name,sanitize(node.Description)))28 print node.Name2930 if node.Count <= 0:31 # Node has only test cases32 tests = node.FindTests('')33 if not tests:34 # FindTests returns None if there are no test cases35 tests = []3637 for test in tests:38 designStepFactory = test.DesignStepFactory39 f.write(',%s,%s\n' %(test.ID, test.Name))40 print test.ID, test.Name4142 # print out the "Design Step" for each test case43 for ds in designStepFactory.NewList(''):44 StepDescription = sanitize(ds.StepDescription)45 StepName = sanitize(ds.StepName)46 StepExpectedResult = sanitize(ds.StepExpectedResult)47 f.write(',,,,%s,%s,%s\n' %(StepName, StepDescription, StepExpectedResult))48 f.flush()4950 # current node has more children51 elif node.Count > 0:52 for child in node.NewList():5354 if child:55 recursiveExport(f, qc, child)56 f.write('\n')575859def exportTests(qc, nodePath):60 f = open(r'export.csv','w')61 f.write(',ID, TEST NAME, ,,Step, Description, Expected Result\n')6263 mg = qc.TreeManager64 node = mg.NodeByPath(nodePath)65 recursiveExport(f, qc, node)66 f.close()676869if __name__ == "__main__":70 print 'Logging in...'71 qc = win32com.client.Dispatch("TDApiOle80.TDConnection")72 qc.InitConnection("http://qc:8080/qcbin")73 qc.Login("<username>", "<password>")74 qc.Connect("<domain>", "<project?")7576 """77 Change nodePath to another "folder" in the Test Plan section of QC and run script78 """79 exportTests(qc, nodePath='Subject\\Some Folder')