|
Re: Export defects from MQC to Excel with full Comments
Const xlleft = -4131 const xlright = -4152 const xlcenter = -4108 const xlgeneral = 1 dim qcconnection 'return the tdconnection object. Set qcconnection = createobject("tdapiole80.tdconnection") dim susername, spassword susername = "uname" spassword = "password" qcconnection.initconnectionex "http://servername:8080/qcbin" '<-- change me. Qcconnection.login susername, spassword if (qcconnection.loggedin <> true) then msgbox "qc user authentication failed" wscript.quit end if dim sdomain, sproject sdomain = "domain" sproject = "project" qcconnection.connect sdomain, sproject if (qcconnection.connected <> true) then msgbox "qc project failed to connect to " & sproject wscript.quit end if call exporttestcases("subject\manual scripts_copy_1") '<-- change me. Qcconnection.disconnect qcconnection.logout qcconnection.releaseconnection '------------------------------------------------------ function exporttestcases(strnodebypath) dim excel, sheet set excel = createobject("excel.application") 'open excel excel.workbooks.add() 'add a new workbook 'get the first worksheet. Set sheet = excel.activesheet sheet.name = "tests" with sheet.range("a1:h1") .font.name = "arial" .font.fontstyle = "bold" .font.size = 10 .font.bold = true .horizontalalignment = xlcenter .verticalalignment = xlcenter .interior.colorindex = 15 'light grey end with sheet.cells(1, 1) = "subject" sheet.cells(1, 2) = "test name" sheet.cells(1, 3) = "designer" sheet.cells(1, 4) = "status" sheet.cells(1, 5) = "step name" sheet.cells(1, 6) = "transaction code" sheet.cells(1, 7) = "step description(action)" sheet.cells(1, 8) = "expected result" sheet.cells(1, 9) = "test data" qcconnection.ignorehtmlformat = true dim treemgr, testtree, testfactory, testlist set treemgr = qcconnection.treemanager 'specify the folder path in testplan, all the tests under that folder will be exported. Set testtree = treemgr.nodebypath(strnodebypath) set testfactory = testtree.testfactory set testlist = testfactory.newlist("") 'get a list of all from node. 'specify array to contain all nodes of subject tree. Dim nodeslist() redim preserve nodeslist(0) 'assign root node of subject tree as nodebypath node. Nodeslist(0) = testtree.path 'gets subnodes and return list in array nodeslist dim row, node, testcase row = 2 for each node in nodeslist set testtree = treemgr.nodebypath(node) set testfactory = testtree.testfactory set testlist = testfactory.newlist("") 'get a list of all from node. 'iterate through all the tests. For each testcase in testlist dim designstepfactory, designstep, designsteplist set designstepfactory = testcase.designstepfactory set designsteplist = designstepfactory.newlist("") if designsteplist.count = 0 then 'save a specified set of fields. Sheet.cells(row, 1).value = testcase.field("ts_subject").path sheet.cells(row, 2).value = testcase.field("ts_name") sheet.cells(row, 3).value = testcase.field("ts_responsible") sheet.cells(row, 4).value = testcase.field("ts_status") row = row + 1 else for each designstep in designsteplist 'save a specified set of fields. 'sheet.cells(row, 1).value = testcase.field("ts_subject").path sheet.cells(row, 2).value = testcase.field("ts_name") sheet.cells(row, 3).value = testcase.field("ts_responsible") sheet.cells(row, 4).value = testcase.field("ts_status") 'save the specified design steps. Sheet.cells(row, 5).value = designstep.field("ds_step_name") sheet.cells(row, 6).value = designstep.field("ds_user_04") sheet.cells(row, 7).value = designstep.field("ds_description") sheet.cells(row, 8).value = designstep.field("ds_expected") sheet.cells(row, 9).value = designstep.field("ds_user_01") 'replace all line breaks with vb line breaks stroutput = replace(strhtml, " ", vblf) 'remove the vbcrlf characters that show up in excel stroutput = replace(stroutput, vbcrlf, vblf) row = row + 1 next end if next next excel.columns.autofit 'set the column width for the following columns. Excel.columns("g").columnwidth = 80 'description excel.columns("h").columnwidth = 80 'step description(action) excel.columns("i").columnwidth = 80 'expected result 'set auto filter mode. If not sheet.autofiltermode then sheet.range("a1").autofilter end if 'freeze first row. Sheet.range("a2").select excel.activewindow.freezepanes = true 'save the newly created workbook and close excel. Excel.activeworkbook.saveas("c:\documents and settings\ramakrishnag\desktop\test\" & sproject & "_testcases.xls") excel.quit set excel = nothing set designsteplist = nothing set designstepfactory = nothing set testlist = nothing set testfactory = nothing set testtree = nothing set treemgr = nothing end function preetham,
|