VIDEO – How to save a file to a QC resource using QTP with OTA

Automation Guild Online Conference Top ad

Code used for this video – to save a text file to a QC resource using QTP with OTA:

QcResourceName = "SaveResource"
fileNameToSave = "SaveMeToQCResource.txt"
fileToSavePath = "D:\DEMO"
Set qcConn = QCUtil.QCConnection
Set oResource = qcConn.QCResourceFactory
Set oCurrentResources =oResource.NewList("")

resourceCount = oCurrentResources.Count

For iNowResourceNum = 1 To resourceCount
 nowResource = oCurrentResources.Item(iNowResourceNum).Name
   if UCase(nowResource) = UCase(QcResourceName) then
    Set oNewResource = oCurrentResources.Item(iNowResourceNum)
    resourceFound = "True"
   end if

If resourceFound = "True" Then
 oNewResource.Filename = fileNameToSave 
 oNewResource.ResourceType = "Test Resource" 
 oNewResource.UploadResource fileToSavePath, True
   Reporter.ReportEvent micPass,"Resource found","Resource Found"
   reporter.ReportEvent micFail,"Did not find Test Resource module named " &   QcResourceName,"Verify that a resource exist in the QC Test Resource module!"
 End If

xiaolin - April 11, 2011

a>链接: 联通卡刷钻 New a>链接: QQ刷钻

ravi - March 9, 2013

i would like to know how to find out the count or the name of the folders and the subfolders exists in either testresources or tesplan or testlab.can u pls provide me the code to acheive this.

Thanks in advance

Jeremy - March 19, 2015

This seems to upload to the QC Resource only if the resource is already checked out status in QC. I will see if I can check out and check back in after upload. Thanks for sharing this.

Click here to add a comment

Leave a comment: