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

PerfectoTopAd

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
 Next

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


5 comments
xiaolin - April 11, 2011

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

Reply
ravi - March 9, 2013

Hi,
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

Reply
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.

Reply
naren - May 30, 2017

Hi Joe, Thanks for the above sample code..
If I’m capturing a desktop screen print and want to save it QC resource folder on the fly, How to do that? could you help me with that please?

Here is my sample which I want to save to ALM resource folder
Desktop.CaptureBitmap(Path & “\” & 001& “_” & replace(testCaseNames,” “,””) & “.png”)

I did assign path to “[ALM\Resources] Resources\myImages\”, but I am getting error as “The system cannot find the path specified.”

Thanks
Naren

Reply
Click here to add a comment

Leave a comment: