I try to store test files (pdf, docx, jpg) in ALM
and use those as input files for upload tests. I am not sure, how could I copy files to ALM
and after that how are these accessible from UFT
.
Asked
Active
Viewed 380 times
-1

plaidshirt
- 5,189
- 19
- 91
- 181
-
1Lot of examples already out there. Look at https://github.com/mvlaxminarayan/Learn/blob/5c19b26c2361494b5cb961c36b274cfc937bb137/WMOS_FRAMEWORK/Function_libs/ALM_Component_Library.qfl – Tarun Lalwani Apr 22 '18 at 20:07
1 Answers
2
There are lot of examples available online
Function get_ALM_Resources(gstr_FrameWorkPath,gstr_Resourcename,gstr_Foldername)
'Dowload files from ALM TestResource
Set objqcConn = QCUtil.QCConnection
Set lobj_Resource = objqcConn.QCResourceFactory
Set lobj_Filter = lobj_Resource.Filter
lobj_Filter.Filter("RSC_FOLDER_NAME") = gstr_Foldername
lobj_Filter.Filter("RSC_FILE_NAME") = gstr_Resourcename
Set lobj_ResourceList = lobj_Filter.NewList
If lobj_ResourceList.Count <>0 Then
Set lobj_oFile = lobj_ResourceList.Item(1)
lobj_oFile.FileName = gstr_Resourcename
lobj_oFile.DownloadResource gstr_FrameWorkPath, True
End If
End Function
Public Function fn_QCDownloadResource(sFileName, sDestination)
Dim objQC, objRes, objFilter, objFileList, objFile, sFilterPair, iCount
If Not QCUtil.IsConnected Then
Exit Function
End If
Set objQC = QCUtil.QCConnection
Set objRes = objQC.QCResourceFactory
Set objFilter = objRes.Filter
objFilter.Filter("RSC_NAME") = """" & Cstr(sFileName) & """"
Set objFileList = objFilter.NewList
If sDestination = "" Then
sDestination = sDestination
End if
If objFileList.Count = 1 Then
Set objFile = objFileList.Item(1)
objFile.FileName = sFileName & ".xlsx"
objFile.DownloadResource sDestination, True
End If
Set objQC = Nothing
Set objRes = Nothing
Set objFilter = Nothing
Set objFileList = Nothing
Set objFile = Nothing
End Function
Function DownloadQCAttachment(strQCDir, strFileName, strTargetPath)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = QCUtil.QCConnection.TreeManager.NodeByPath(strQCDir)
Set objAttachmentList = objFolder.Attachments.NewList("")
For Each objAttachment In objAttachmentList
If InStr(1, objAttachment.DirectLink, strFileName, 1) > 0 Then
Set objExtStorage = objAttachment.AttachmentStorage
objAttachmentName = objAttachment.DirectLink
objExtStorage.Load objAttachmentName, true
objFSO.MoveFile objExtStorage.ClientPath & "\" & objAttachmentName, strTargetPath & "\" & Split(objAttachment.Name, "_")(UBound(Split(objAttachment.Name, "_")))
Exit For
ElseIf strFileName = "" Then
Set objExtStorage = objAttachment.AttachmentStorage
objAttachmentName = objAttachment.DirectLink
objExtStorage.Load objAttachmentName, true
objFSO.MoveFile objExtStorage.ClientPath & "\" & objAttachmentName, strTargetPath & "\" & Split(objAttachment.Name, "_")(UBound(Split(objAttachment.Name, "_")))
End If
Next
Set objFSO = Nothing
End Function

Tarun Lalwani
- 142,312
- 9
- 204
- 265
-
Could you show me please, where and how can I upload the files? Where is file referenced in these code snippets? – plaidshirt Apr 23 '18 at 06:25
-
Where you want to upload the file? resources, current run? current test? – Tarun Lalwani Apr 23 '18 at 06:29
-
-
Look at the `UploadResource` method in https://github.com/Orasi/VBS-HP_UFT-Toolkit/blob/7ad4a3ec1cde5b08f877d0f63a650a9acfe800db/ALM – Tarun Lalwani Apr 23 '18 at 07:40
-
-
1@plaidshirt, if the answer has helped, don't forget to accept it – Tarun Lalwani Apr 27 '18 at 18:31