VIDEO – How to get a QC resource using QTP with OTA

PerfectoTopAd

In this video I show a simple example on how to use Quality Center’s Open Test Architecture (OTA) in QuickTest Pro.

QTP using OTA to download a QC Test Resource

Code used in video to get a QC test resource:

saveTo = "D:\DEMO"
resourceName = "QCGETRESOURCE.txt"

Set qcConn = QCUtil.QCConnection
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.FileName = resourceName
oFile.DownloadResource saveTo, True
End If


* About the code:


The QCUtil object is used to access the Quality Center Open Test Architecture (OTA) interface. You can use the properties associated with the QCUtil object to return Quality Center OTA objects.  Using the property QCConnection object, allow you to interact with the current Quality Center session and provides access to the Quality Center object model.

The QCResourceFactory object allows you to manage the QC resources section.  You can use the Filter property to locate the resource that you want. Then the Filter’s NewList method is used to create a list of objects according to the specified filter.

 To save and retrieve files from a QC test set ‘attachment' tab check out:QC & QTP – How to Attach a File to a Test Sets Attachment Tab

9 comments
How to save and retrieve a Quality Center Test Resource — Joe Colantonio -- QuickTest Pro, Tech Geek, Bibliomanic, The Software Test Automation Imagineer - February 8, 2011

[…] by Joe Colantonio TweetUsing Quality Center’s Test Resource module is really helpful when you need to use test information across multiple tests, lab machines and environments. Here are some QuickTest Pro functions I created to save and get a “test resource” from Quality Center. ( Also check out my video : How to get a QC resource using QTP with OTA) […]

Reply
Gareth - February 10, 2012

Just wondering if you knew how to download a specific baseline of a Resource?

The DownloadResource functionality only appears to get the latest and not a specified version. At runtime I want to check whether a test is “pinned to baseline” from QC which I believe I can do through the Test.VCS properties but I cannot see how to then use that to grab it’s resources of the same baseline?

Reply
    Joe Colantonio - February 11, 2012

    Gareth » HI Gareth – I’m not sure. I will have to try and see if I can figure it out. I’ll let you know what I find. Please let me know if you find a solution first.Cheers~Joe

    Reply
Jason Koelewyn - March 22, 2012

How can you change this to download a file attached to a test?

Reply
Murali - March 25, 2012

Joe,
Need your help.
Goal : To load a function library stored in QC Resource from qtp script which has been called from QC Run test set.
1. Mt QTP script thats been attached to each QC tests will attempt tp load function library and use its methods.
2. This was working before for me since I was storing all my function libraries & datafiles under QTP’s machine.
3. Now I want to use QC’s resource folder since it can be accessed by all team members and moved the function libraries to QC path “[QualityCenter] Resources\My Automation Resources\Mastercript\”.
4. When I attempted to LoadLibrary by providing the QC path, it not taking.
5. Could you please help on how to load function library from resource that can be used in the current qtp script initiated from QC ?
‘———————————————————————————
‘Before using QC : Worked for me
g_qc_framework_root = C:\\My Automation Resources\Mastercript\”

LoadFunctionLibrary g_qc_framework_root & “main_driver_lib.vbs”
‘———————————————————————————
‘Afterusing QC : FAILS
g_qc_framework_root = “[QualityCenter] Resources\My Automation Resources\Mastercript\”

LoadFunctionLibrary g_qc_framework_root & “main_driver_lib.vbs”

Thanks

Murali

Reply
    Joe Colantonio - April 9, 2012

    Murali » Hi Murali – I have to try a few things to see how to do this. Dumb question have you tried just opening the QTP script and in File>Settings under Test Settings click on resources? In the resources you can point to the function library in QC/ALM.

    Reply
Kevin - January 3, 2013

Joe is there a way to do this using a VAPI-XP-Test in vbscript. .
I tired just using the code above but the following error on Run-Time Error [424] object required

here is a copy of the VAPI-XP-Test code

‘ test [VBScript]
‘ Created by Quality Center
‘ 1/3/2013 12:31:13 PM
‘ ====================================================

‘ —————————————————-
‘ Main Test Function
‘ Debug – Boolean. Equals to false if running in [Test Mode] : reporting to Quality Center
‘ CurrentTestSet – [OTA COM Library].TestSet.
‘ CurrentTSTest – [OTA COM Library].TSTest.
‘ CurrentRun – [OTA COM Library].Run.
‘ —————————————————-
Sub Test_Main(Debug, CurrentTestSet, CurrentTSTest, CurrentRun )
‘ *** VBScript Limitation ! ***
‘ “On Error Resume Next” statement suppresses run-time script errors.
‘ To handle run-time error in a right way, you need to put “If Err.Number 0 Then”
‘ after each line of code that can cause such a run-time error.
On Error Resume Next

‘ clear output window
TDOutput.Clear

QCGetResource()

If Not Debug Then
End If
‘ handle run-time errors
If Err.Number 0 Then
TDOutput.Print “Run-time error [” & Err.Number & “] : ” & Err.Description
‘ update execution status in “Test” mode
If Not Debug Then
CurrentRun.Status = “Failed”
CurrentTSTest.Status = “Failed”
End If
End If
End Sub
‘XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Function QCGetResource()

saveTo = “C:\temp”
resourceName = “FitnesseConfig.txt”

Set qcConn = QCUtil.QCConnection
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.FileName = resourceName
oFile.DownloadResource saveTo, True
End If
End Function
‘XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Reply
Paul - August 16, 2013

Hi Joe,

Thanks for the useful info on your website.

Do you know how to verify if a test resource is checked-out or checked-in with OTA?
thanks

Paul

Reply
abhimanyu - October 21, 2013

Hi
Can anyone please help me with a code which can download the QTP runtime time data table using QC API?

Thanks

Reply
Click here to add a comment

Leave a comment: