Highlighted
KulwinderSingh Absent Member.
Absent Member.
3670 views

Get Test Instance details/test execution details of specific test sets from QC through a VBScript

 I use the following Query in Excel Report to get test instance details within QC

 

SELECT CF_FATHER_ID AS FOLDER_Father,
CF_ITEM_NAME AS TEST_SET_FOLDER, CY_CYCLE AS TEST_SET,  TESTCYCL.TC_TEST_ID AS TEST_ID,   TS_NAME AS TEST_SCRIPT, TC_STATUS AS TEST_SET_EXECUTION_STATUS    ,    TC_ACTUAL_TESTER as TESTER,  TESTCYCL.TC_PLAN_SCHEDULING_DATE as PLANNED_EXECUTION_DATE , TC_EXEC_DATE as ACTUAL_EXECUTION_DATE , TESTCYCL.TC_EXEC_TIME AS TEST_EXECUTION_TIME
FROM
TESTCYCL,TEST,CYCLE,CYCL_FOLD
WHERE
TS_TEST_ID = TC_TEST_ID
AND
TC_CYCLE_ID = CY_CYCLE_ID
AND
CY_FOLDER_ID = CF_ITEM_ID
AND
CF_FATHER_ID IN ( '1170','1171','1172','1173')
ORDER BY
CF_ITEM_NAME  , TESTCYCL.TC_TEST_ID

 

But i need to get the same information without using excel report and instead use VBScript. I am able to connect to QC through VBScript but i do not know the Syntax to get test instance related information. I am pasting below the script i could come up with, please help me fill in the Gaps in script and correct it as needed. this is very urgent so please help.

 

Option Explicit
Dim QCConnection
Dim UserN, QCUserN, UserP, QCDomain, QCProj, QCAddr,Row,a,b
Dim WSHNetwork
QCUserN  = "User Name"
UserP    = "Password"
QCDomain = "Domain name"
QCProj   = "project name"
QCAddr   = "URL/qcbin"
Row    = "1"
a = Replace(date,"/","")
b = replace(Time,":","")
WScript.Echo "Initialising...."
Set QCConnection = CreateObject("TDApiOle80.TDConnection")
QCConnection.InitConnectionEx QCAddr
QCConnection.login QCUserN, UserP
QCConnection.Connect QCDomain, QCProj
If (QCConnection.Connected <> True) Then
    WScript.Echo "QC Project Failed to Connect"
    WScript.Quit
End If
On Error Resume Next
WScript.Echo "Extract from QC here and format it out"

Dim  TestSet,TestCase,TestSetFact,TestFact,TestSetFilter,TestFilter,TestSetList,TestList

Set TestSetFact = QCConnection.TestSetFactory
Set TestSetFilter = TestSetFact.Filter
TestSetFilter("CF_FATHER_ID") = "1170" or "1171" or "1172" or "1173"
Set TestSetList = TestSetFilter.NewList

'---------------------------
'I Need to know if the Filter set in above lines is correct.
'I NEED Help to Continue with the script from here and get the Details of Test Instance so that i can populate the columns in excel as listed below.

'-------------------------

Set Excel = CreateObject("Excel.Application") ' Open Excel
Excel.WorkBooks.Add() ' Add a new workbook

Set Sheet = Excel.ActiveSheet

For Each TestCase In TestList
'Save a specified set of fields.
Sheet.cells(Row, 1).Value = TestCase.Field("CY_CYCLE")
Sheet.Cells(Row, 2).Value = TestCase.Field("TC_TEST_ID")
Sheet.Cells(Row, 3).Value = TestCase.Field("TS_NAME")
Sheet.Cells(Row, 4).Value = TestCase.Field("TC_STATUS")
' and continue so on to fill all the fields
Row = Row+1
Next

'Save the newly created workbook and close Excel.
Excel.ActiveWorkbook.SaveAs("C:\Documents and Settings\Admin\Desktop\QualityCenter_Demo"&a&b&".xls")
Excel.Quit
'--------
If Err.number <> 0 Then WScript.Echo Err.Description & ":" & Err.Number

QCConnection.Disconnect
QCConnection.Logout
QCConnection.ReleaseConnection
WScript.Echo "Report Complete"

Tags (2)
0 Likes
1 Reply
ranand_d Respected Contributor.
Respected Contributor.

Re: Get Test Instance details/test execution details of specific test sets from QC through a VBScrip

For your question, you will get help in the ALM OTA Referrence.

Check the example code section > Test execution code samples

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.