Download all the attachments from a specific folder in QC
There was a recent request from Salman asking how to download the folder contents from QC. I’m assuming he meant to download all the attachments from a specific folder in QC. I tweaked my earlier function to download all the files instead of specific file. Here is the function.. Enjoy.
Public Function DownloadAttachments(TDFolderPath, sDownloadTo)
Dim otaAttachmentFactory 'As TDAPIOLELib.AttachmentFactory
Dim otaAttachment 'As TDAPIOLELib.Attachment
Dim otaAttachmentList 'As TDAPIOLELib.List
Dim otaAttachmentFilter 'As TDAPIOLELib.TDFilter
Dim otaTreeManager 'As TDAPIOLELib.TreeManager
Dim otaSysTreeNode 'As TDAPIOLELib.SysTreeNode
Dim otaExtendedStorage 'As TDAPIOLELib.TreeManager
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Dim strPath 'As String
Set otaTreeManager = QCUtil.TDConnection.TreeManager
Set otaSysTreeNode = otaTreeManager.NodeByPath(TDFolderPath)
Set otaAttachmentFactory = otaSysTreeNode.Attachments
Set otaAttachmentFilter = otaAttachmentFactory.Filter
otaAttachmentFilter.Filter("CR_REFERENCE") = "'ALL_LISTS_" & otaSysTreeNode.NodeID & "_*'"
Set otaAttachmentList = otaAttachmentFilter.NewList
DowloadAttachments = ""
If otaAttachmentList.Count > 0 Then
For i = 1 to otaAttachmentList.Count
set otaAttachment = otaAttachmentList.Item(i)
otaAttachment.Load True, ""
If (fso.FileExists(otaAttachment.FileName)) Then
strFile = otaAttachmentList.Item(i).Name
myarray = split(strFile,"ALL_LISTS_"& otaSysTreeNode.NodeID & "_")
fso.CopyFile otaAttachment.FileName, sDownloadTo & "\" & myarray(1)
Reporter.ReportEvent micPass, "File Download:", myarray(1) & " downloaded to " & sDownloadTo
DownloadAttachments = sDownloadTo
end if
Next
Else
Reporter.ReportEvent micFail, "No attachments to download", _
"No attachments found in specified folder '" & TDFolderPath & "'."
DowloadAttachments = "Empty"
End If
Set otaAttachmentFactory = Nothing
Set otaAttachment = Nothing
Set otaAttachmentList = Nothing
Set otaAttachmentFilter = Nothing
Set otaTreeManager = Nothing
Set otaSysTreeNode = Nothing
Set fso = nothing
End Function
July 18, 2008 - Posted by haripotter | HP Quality Center and QTP | Attachments, Download, QC | 2 Comments
2 Comments »
Leave a comment
About
I’m Hari from Bangalore, India. I’am a test architect involved in creating test automation frameworks for testing enterprise web applications that manage IT infrastructure. I’m more interested in virtualization technologies, automation tools such as QTP, Silktest, Quality Center etc and HP BladeSystem. On the personal front, I’m married and have a beautiful daughter named Sandra. She is a year and half old. My hobbies are sketching and listening to music. My native place is kerala, God’s own country.
I use this blog as a medium to share some of the knowledge I gain from the automation community. Lot of folks out there, especially “advancedqtp.com” are very helpful and They have inspired me.
-
Blog Stats
- 27,910 hits
-
Recent Posts
-
Top Posts
Archives
-
Top Clicks
-
Archives
- June 2009 (1)
- April 2009 (1)
- March 2009 (1)
- August 2008 (5)
- July 2008 (4)
- May 2008 (2)
- April 2008 (3)
- February 2008 (3)
-
Categories
-
RSS
Entries RSS
Comments RSS
Request you to let me know how to upload an attachment in Test Lab (QC).
Hi I need to download attachments from the currentTestSet in Test lab. Can u please advice? I don’t want the attachments in the folder of the test lab. I need attachments only from the current test set.