Use API to download attachments from Test Plan
Question ID: 106706
0
0

We are trying to download the attachments in the test plan from QC to local desktop. Can someone please provide an API code sample for this?

Marked as spam
Posted by (Questions: 122, Answers: 3)
Asked on February 22, 2016 2:44 pm
109 views
Answers (2)
0
Private answer

This example should get your close. You may need to make some slight adjustments.

Dim qcServer, qcDomain, qcProject, qcUser, qcPassword

qcServer = ''http://YOUR_SERVER:8080/qcbin/''
qcDomain = ''DEFAULT''
qcProject = ''BLANK_PROJECT''
qcUser = ''alex_alm''
qcPassword = ''''

'Create the TD Connection object
Set tdc = CreateObject(''tdapiole80.tdconnection'')

'Initialize the connection and log in to the project
tdc.InitConnectionEx qcServer
tdc.Login qcUser, qcPassword
tdc.Connect qcDomain, qcProject

'If connection is established...
If tdc.Connected = True Then

'Create the TestFactory object
Set TestFact = tdc.TestFactory

'Filter the Tests in a specific folder and create a list.
Set TestFilter = TestFact.Filter
TestFilter.Text = ''{TableName:TEST, ColumnName:TS_SUBJECT, LogicalFilter:0000016^SubjectTestTest123^, VisualFilter:0000016^SubjectTestTest123^, NO_CASE: }''

TestFilter.Filter(''TS_ID'')

Set TestList = TestFilter.NewList()

'Iterate through the Test list.
For Each Test in TestList

'If the Test has attachment(s)...
If Test.HasAttachment = True Then
'Filter the attachments and create a list.
Set AttachFact = Test.Attachments

Set AttachFilter = AttachFact.Filter
Set AttachList = AttachFilter.NewList()

'Iterate through the Attachment list.
For Each Attach in AttachList

'Get the storage object for the attachment.
Set AttachStor = Attach.AttachmentStorage

'Set the download path.
AttachStor.ClientPath = ''C:sample'' & Test.ID

'Download the attachment.
AttachStor.Load

'Kill the storage object.
Set AttachStor = Nothing
Next

'Kill the attachment factory, list, and filter objects.
Set AttachList = Nothing
Set AttachFilter = Nothing
Set AttachFact = Nothing
End If
Next

'Kill the Test Factory and filter objects.
Set TestFilter = Nothing
Set TestList = Nothing
Set TestFact = Nothing

'Notify the user.
MsgBox ''Download Complete.''

End If

'Disconnect from the project and logout of QC
tdc.Disconnect
tdc.Logout

'Kill the connection object
Set tdc = Nothing

Marked as spam
Posted by (Questions: 3, Answers: 168)
Answered on February 22, 2016 2:49 pm
0
Private answer

@Jafar : I am completely new to VB coding. I tried this code with relevant changes for QC server, domain, Project, user id and password details. There was not debug error, however the program seems to be not responding once I run.

TestFilter.Text = ''{TableName:TEST, ColumnName:TS_SUBJECT, LogicalFilter:0000016^SubjectTestTest123^, VisualFilter:0000016^SubjectTestTest123^, NO_CASE: }''

For the above line, how would I change if I had to collect evidences from TEST LAB under folder structure
Root > Project folder > Release folder > System Testing > CR number?
Can you please show me so I can cross check with what I have already done?

Marked as spam
Posted by (Questions: 0, Answers: 1)
Answered on July 2, 2018 3:53 pm
EyeOnTesting

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

X
Scroll to Top