How do I get files from ALM/QC Resources area for QTP?
Question ID: 104583
4
0

I have users that would like to update files in Resources area in ALM/QC and have QTP read this file. Does anybody have way to do that?

Marked as spam
Posted by (Questions: 2, Answers: 98)
Asked on September 4, 2012 4:50 pm
751 views
Answers (3)
9
Private answer

You can not directly access the files in ALMQC with QTP. The files will have to be copied from ALMQC server to the local QTP machine. I found a great function at http://www.joecolantonio.com/2010/08/17/how-to-save-and-retrieve-a-qc-test-resource/. I have adapted the code for the following issues:
- Checks to see if spaces are in the filename and then add single quotes around file name.
- Checks the connection to ALMQC is open.
- The code looks for by file name and will error out if there is more than one file with same name.
- The code errors out if it cannot find the file in resources.
This code was tested with ALM 11 patch 9 with QTP 11




'@Function Name: QCGetResource? 
'@Documentation Saves a text file from a QC Test Resource to a local dir?
'@Created By: Joe Colantonio
' orginall code http://www.joecolantonio.com/2010/08/17/how-to-save-and-retrieve-a-qc-test-resource/
'@Modified  By Tom Margrave
'@Return Values: NONE
'@Example: QCGetResource ''qcresourcetest.txt'',''C:Temp''
'-----------------------------------------------------------


Function QCGetResource(resourceName,saveTo)

	'Check to see if  single quote used
	If  not (Left(resourceName,1)=''''')  and not (right(resourceName,1)=''''') Then
		'  single quotes not used check to see if needed because space in name
		If  instr(0,resourceName,'' '')>0 Then
			' Add single quotes
			resourceName= ''''' & trim(resourceName) & '''''
		End If
	End If
	
	Set qcConn = QCUtil.QCConnection

	'Check to see if there is a QC connnection
	If not(QCUtil.IsConnected) Then
        Reporter.ReportEvent micFail, "QC Connection", "This test was stopped because a QC Connection is not working."
		EXITTest(1)
	End If

	Set oResource = qcConn.QCResourceFactory
	Set oFilter = oResource.Filter
	oFilter.Filter(''RSC_FILE_NAME'') = resourceName
	
	Set oResourceList = oFilter.NewList
	
	If oResourceList.Count = 1 Then
		Set oFile = oResourceList.Item(1)
		oFile.DownloadResource saveTo, True
	else
	    'Get data about this test for report 
		'Create the Application object
		Set qtApp = CreateObject(''QuickTest.Application'')
		GetCurrentTestScriptName = qtApp.Test.Name
		GetCurrentTestScriptName= GetCurrentTestScriptName & '' -  '' & qtApp.Test.Location
		Set qtApp = Nothing ' Release the Application object
			
		If oResourceList.Count = 0 Then
			msg=''  There no file named '' & resourceName & '' in ALM Resources''
		Else
			msg='' ALM Resources has  too many files with name '' & resourceName 
		End If
		
		Reporter.ReportEvent micFail, ''ALM Resource Issue'', GetCurrentTestScriptName & ''- Test '' & sGetCurrentTestScriptName & ''  has following issue : '' & msg
		EXITTest(1)
	End If
	
	Set qcConn = Nothing
	Set oResource = Nothing
	Set oFilter = Nothing
	Set oFlieList = Nothing
	Set oFile = Nothing
End Function


'test only one file exist
QCGetResource '''DomesticFlights.xls''',''C:TEMP''   

Marked as spam
Posted by (Questions: 2, Answers: 98)
Answered on September 4, 2012 4:53 pm
0
One thing to point out. When calling the QCGetResource function, use the file name of the test resource. If you use the test resource name, which can be different from the actual file name, the function will fail.
( at February 12, 2014 3:13 am)
1
Private answer

You can directly access some files. I use the below to access our .xls spreadsheets:
Add a file to Quality Center Resource Folder (must be in .xls format, not .xlsx). For the below example, I created an Excel (.xls) file with one worksheet named Step1, two columns and two rows:

[ A ][ B ]
[ Value1 ][ Value2 ]
[ a ][ cash ]

Save it as .xls, upload to Resource path of

ResourcesQTP ResourcesDataTest

Then here is the sample code to access it (Make sure QTP/UFT has an active connection to QC):

Datatable.AddSheet ''newSheet''
Datatable.ImportSheet ''[QualityCenterResources] ResourcesQTP ResourcesDataTest'', ''Step1'', ''newSheet''
msgbox Datatable(''Value1'', ''newSheet'')
msgbox Datatable(''Value2'', ''newSheet'')

Marked as spam
Posted by (Questions: 3, Answers: 12)
Answered on April 5, 2013 5:38 pm
0
Private answer

Hi Everybody,
I need to make a code that is cutting a test resource from one folder and moving it to other Folder. If you have some possible solutions, pls wirte a comment

Marked as spam
Posted by (Questions: 1, Answers: 2)
Answered on September 15, 2017 9:17 am
EyeOnTesting

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

X
Scroll to Top