Micro Focus QTP (UFT) Forums
QC-QTP Integration - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: QC-QTP Integration (/Thread-QC-QTP-Integration)



QC-QTP Integration - shipu - 04-29-2014

Hello,

I am trying to attach a file in QC test lab-test set- current test from QTP. How can QTP tell which test is being run and then attach the file to the current test only?
Please advise.
-S


RE: QC-QTP Integration - Jay - 05-29-2014

The following function will be useful :

Code:
Function DownloadAttachements(qtApp, tdc, testPath, strFSAPath)

    For Each oTestSet In tdc.TreeManager.NodeByPath(testPath).TestFactory.NewList("")
            ScriptName = oTestSet.Name
            Script = "[QualityCenter] " & testPath & "\" & ScriptName
            Dim otaAttachmentFactory
            Dim otaAttachment 'As TDAPIOLELib.Attachment
            Dim otaAttachmentList 'As List,
            Dim TAttach 'As Attachment 'As TDAPIOLELib.List
            Dim otaTreeManager 'As TDAPIOLELib.TreeManager
            Dim otaSysTreeNode 'As TDAPIOLELib.SysTreeNode
            Dim otaExtendedStorage, AttachDow
            Dim fso
            
            Set fso = CreateObject("Scripting.FileSystemObject")
            Set otaAttachmentFactory = oTestSet.Attachments
            Set otaAttachmentList = otaAttachmentFactory.NewList("")
            'MsgBox "Attachment Count:" & otaAttachmentList.Count
            
            If otaAttachmentList.Count > 0 Then
            Set otaAttachment = otaAttachmentList.Item(1)
            otaAttachment.Load True, ""
            strPath = otaAttachment.Filename
            
                     DownloadAttachements = strPath
                     SysPathF = strFSAPath & "Attachments_" & oTestSet.Name
                     Call CreateFolder(SysPathF)
                     SysPath = SysPathF & "\"
                     Call CreateFolder(SysPath)
                     fso.CopyFile strPath, SysPath
            Else
            'MsgBox "Fail"
            DowloadAttachment = "Empty"
            End If
          
            Set otaAttachmentFactory = Nothing
            Set otaAttachment = Nothing
            Set otaAttachmentList = Nothing
            Set otaTreeManager = Nothing
            Set otaSysTreeNode = Nothing
            Set fso = Nothing

        Next

End Function