Option Explicit
Dim sUserName,sPassword
sUserName = "YOUR_UID"
sPassword = "YOUR_PWD"
Const xlLeft = -4131
Const xlRight = -4152
Const xlCenter = -4108
Const xlGeneral = 1
Dim QCConnection
'Return the TDConnection object.
Set QCConnection = CreateObject("TDApiOle80.TDConnection")
QCConnection.InitConnectionEx "http://YOUR_URLOFQC:8080/qcbin/"
QCConnection.Login sUserName, sPassword
If (QCConnection.LoggedIn <> True) Then
MsgBox "QC User Authentication Failed"
WScript.Quit
End If
Dim sDomain, sProject
sDomain = "YOUR_Domain"
sProject = "YOUR_Project"
QCConnection.Connect sDomain, sProject
If (QCConnection.Connected <> True) Then
MsgBox "QC Project Failed to Connect to " & sProject
WScript.Quit
End If
Call ExportTestCases()
'Call ExportDefects()
QCConnection.Disconnect
QCConnection.Logout
QCConnection.ReleaseConnection
Function PrintFields(oObject)
Dim FieldsList, Field
Set FieldsList = oObject.Fields
For Each Field In FieldsList
WScript.Echo Field
Next
End Function
Function ExportTestCases()
Dim TestFactory, TestList
Set TestFactory = QCConnection.TestFactory
Set TestList = TestFactory.NewList("") 'Get a list of all tests.
Dim TestCase, 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 (Folder Name)"
Sheet.Cells(1, 2) = "Test Name (Manual Test Plan Name)"
Sheet.Cells(1, 3) = "Description"
'Sheet.Cells(1, 4) = "Designer (Owner)"
'Sheet.Cells(1, 5) = "Status"
Sheet.Cells(1, 6) = "Step Name"
Sheet.Cells(1, 7) = "Step Description(Action)"
Sheet.Cells(1, 8) = "Expected Result"
'Call PrintFields(TestFactory)
Dim Row
Dim countingSubject
Row = 2
'Iterate through all the tests.
For Each TestCase In TestList
Dim DesignStepFactory, DesignStep, DesignStepList
Set DesignStepFactory = TestCase.DesignStepFactory
Set DesignStepList = DesignStepFactory.NewList("")
countingSubject=0
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_DESCRIPTION")
'Sheet.Cells(Row, 4).Value = TestCase.Field("TS_RESPONSIBLE")
'Sheet.Cells(Row, 5).Value = TestCase.Field("TS_STATUS")
Row = Row + 1
Else
For Each DesignStep In DesignStepList
'Save a specified set of fields.
If countingSubject=0 then
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_DESCRIPTION")
'Sheet.Cells(Row, 4).Value = TestCase.Field("TS_RESPONSIBLE")
'Sheet.Cells(Row, 5).Value = TestCase.Field("TS_STATUS")
'Save the specified design steps.
Sheet.Cells(Row, 6).Value = DesignStep.StepName
Sheet.Cells(Row, 7).Value = DesignStep.StepDescription
Sheet.Cells(Row, 8).Value = DesignStep.StepExpectedResult
else
Sheet.Cells(Row, 6).Value = DesignStep.StepName
Sheet.Cells(Row, 7).Value = DesignStep.StepDescription
Sheet.Cells(Row, 8).Value = DesignStep.StepExpectedResult
end if
countingSubject=countingSubject+1
Row = Row + 1
Next
End If
'for max number of row delet this code if you want full export
If Row>500 Then
Exit For
End If
Next
'Call PrintFields(DesignStepFactory)
'Excel.Columns.AutoFit
'Save the newly created workbook and close Excel.
'Excel.ActiveWorkbook.SaveAs("C:\" & sProject & "_TESTCASE1.xls")
'Excel.Workbooks.Open("C:\Export_TESTCASE1.xlsx")
Dim objRange
Set objRange = Sheet.UsedRange
'Remove tag in the following lines
Excel.Cells.Replace "'tag_html>'"," "
Excel.Cells.Replace "tag_body>"," "
Excel.Cells.Replace "/tag_html>"," "
Excel.Cells.Replace "/tag_body>"," "
Excel.Cells.Replace "tag_br>"," "
Excel.ActiveWorkbook.SaveAs("C:\" & sProject & "_TESTCASE.xlsx")
Excel.Quit
End Function
No comments:
Post a Comment