Download attachment from Quality center
HP Quality Center allows us to store any file as attachments. We could use this facility to store testdata, tools or anything that helps us to run a test successfully.
For example : We could store some command line tools in quality center as attachments in a folder. We could download these tools to the qtp system where we want to execute the tool. for such requirements, Try the below code to download an attachment from a testplan folder in qc.
‘Description : Returns the path of downloaded attachment
‘Example Usage :
‘ If you want to move the downloaded file to c:\ folder
‘ attpath = DownloadAttachment(“attachmentname”,”Root\D2D\Purchasing”, “TRUE”)
‘ If you DO NOT want to move the downloaded file to c:\ folder
‘ attpath = DownloadAttachment(“attachmentname”,”Root\D2D\Purchasing”, “FALSE”)
‘==================================================================================
Public Function DownloadAttachment(TDAttachmentName, TDFolderPath, bMovetoRoot)
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 & _
“_” & TDAttachmentName & “‘”
Set otaAttachmentList = otaAttachmentFilter.NewList
If otaAttachmentList.Count > 0 Then
set otaAttachment = otaAttachmentList.Item(1)
otaAttachment.Load True, “”
strPath = otaAttachment.FileName
if(bMovetoRoot) then
If (fso.FileExists(otaAttachment.FileName)) Then
fso.CopyFile strPath, “c:\”&TDAttachmentName
DownloadAttachment = “c:\”&TDAttachmentName
else
DownloadAttachment = strPath
end if
else
DownloadAttachment = strPath
end if
Else
Reporter.ReportEvent micFail, “Failure in library function ‘GetFolderAttachmentPath’”, _
“Failed to find attachment ‘” & TDAttachmentName & “‘ in folder ‘” & TDFolderPath & “‘.”
DowloadAttachment = “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
April 29, 2008 - Posted by haripotter | HP Quality Center and QTP | Attachments, OTA, qtp, Quality Center | 8 Comments
8 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
- 26,114 hits
-
Recent Posts
-
Top Posts
Archives
-
Top Clicks
- None
-
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
Hi How can we get the whole folder content present in my quality center server to my local system?
[...] 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.. [...]
Pingback by Download all the attachments from a specific folder in QC « haripotter’s technorati | July 18, 2008 |
Hi ,
some one let me know whether we can use QC as Shared folder… in the sense i want to upload Msaccess file manually .. and want to get and update value into it from local desktop….with out downloading file to local desktop.
Im sorry I’m new into this , mybe my question are of basic knowledge:
attpath = DownloadAttachment(”attachmentname”,”Root\D2D\Purchasing”, “TRUE”)
attpath is defined as?
”Root\D2D\Purchasing” this root corresponds to?
Thankyou!
”Root\D2D\Purchasing” this root corresponds to the Folder names in Quality center, where the attachment is present.
Thankyou Harry, that worked just fine. I am going to add a new thread. I have a doubt with the upload procedure now.
Greetings!
Hi,
I am trying to download test from qc to my local machine.
when i open the test by using
qtpApp.open [QC],folder path………
qtp is responding like can’t open it as Application is busy.
Can you help me on this
Thanks
jai
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.