使用ALM中的文件作为上载测试的输入

时间:2018-04-19 07:36:14

标签: hp-uft hp-alm

我尝试在ALM中存储测试文件(pdf,docx,jpg),并将其用作上传测试的输入文件。我不确定,如何将文件复制到ALM,之后如何从UFT访问这些文件。

1 个答案:

答案 0 :(得分:1)

网上有很多例子

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

PS:积分https://github.com/mvlaxminarayan/Learn/blob/5c19b26c2361494b5cb961c36b274cfc937bb137/WMOS_FRAMEWORK/Function_libs/ALM_Component_Library.qfl

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

PS:积分https://github.com/PlusAutomationIkea/PlusAutomationSuite/blob/7489d362f0fcfef657da5f3284c830f84484eb51/FunctionLib/ALMHelper.qfl

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

PS:积分https://github.com/Pradeep-ML/MobileLabsAutomationFramework/blob/248cd135848b5e159c770ab19ec73b7e981a9aad/FunctionLibraries/LoadTesting.qfl