≡ Menu
Joe Colantonio – Selenium-UFT-QTP-SoapUI-ALM-LoadRunner & more

HP Service Test 11.20 – How to Save a QC/ALM Resource using OTA

HP Service Test 11.20 – How to Save a QC/ALM Resource using OTA post image

Service Test 11.20 and Quality Center/ALM’S Open Test Architecture (OTA)

In a previous post I showed you how to download a QC resource from QTP. Since then I’ve gotten a few request for how to do the same with HP’s Service Test 11.20. Unlike QTP — Service Test does not have an activity like QCUtility that allow you to tap into OTA. But like QTP you can call the OTA API directly. The only difference between the two is that QTP uses VBScript and the ST uses C#.

How to configure ST to use OTA

The first thing you need to do to get OTA to work with ST is to add a reference to it in your script.

  • In ST click on the Test>Add Reference menu option
  • In the Add Reference Dialog click on the COM tab
  • Find and click on ‘OTA COM Type Library’ then click on the Select and OK buttons

OTA Code to Download a QC Resource

Once you have a reference to OTA in your script the next step is to write some custom code.

  • In Service Test under the Toolbox/Miscellaneous folder grab a Custom Code activity and drag it onto the main canvas area.
  • Click on the Custom Code activity and under its property sheet click on the events icon
  • For the Event ExecuteEvent select “Create a default handler..”
  • Under your CodeActivity#_OnExecuteEvent add the following code
    TDAPIOLELib.TDConnection qcConn = new TDAPIOLELib.TDConnection();
    TDAPIOLELib.QCResourceFactory oResource;
    oResource = (QCResourceFactory)qcConn.QCResourceFactory;
    TDAPIOLELib.List oCurrentResources = oResource.NewList("");
    int rNum;
    rNum = oCurrentResources.Count;
    string getResource = "ST_OTA_TEST.txt";//Replace with your resource name
    for(int i=1;i <=rNum;i ++)
    TDAPIOLELib.QCResource resItem = (QCResource)oCurrentResources[i];
    string nowResource = resItem .FileName.ToString();
    if (String.Compare(getResource,nowResource) == 0)
    TDAPIOLELib.IResourceStorage iresStorage;
    iresStorage = (TDAPIOLELib.IResourceStorage)resItem;
    //Change to your local folder you want to save resource to
  • When you run your script, the resource file should download to your local directory

8 comments… add one

  • Vaibhav September 3, 2012, 1:16 pm

    Hi Joe,

    First of all thanks for such a wonderful information.

    I am working on assignment to where i have to download folder and it’s sub folders and files inside sub folders for Test Resources tab.

    The above code provided by you only donwloads perticular file. It will be great help if you could provide code snippent for downloading folder from QC and it’s content.


  • Mahesh November 20, 2012, 9:01 am

    Hi Joe,
    I am unable to implement Data Driven testing for Service test script in ALM. I have checked the “Allow data driving from ALM/QC” check box in HP Service Test but I couldn’t run my test in
    ALM Test plan. please help me on the same.


    • Joe Colantonio November 22, 2012, 4:47 pm

      Mahesh » Hmm it’s hard to tell without seeing it. Are you getting any error messages? What patch version is your ST?

  • Vaibhav December 6, 2012, 8:04 am

    Hi Joe,

    Can you please answer my query on downloading folder and its sub folders and files inside sub folders for Test Resources tab from QC.
    The above code provided by you only downloads particular file. It will be great help if you could provide code snippet for downloading folder from QC recursively and it’s content.

    Please help me in this!


  • Prabhu January 23, 2013, 2:14 pm

    Hi Joe,

    Using the above code, am able to connect to ALM. But get error as;
    The type or namespace name ‘QCResourceFactory’ could not be found (are you missing a using directive or an assembly reference?) (CS0246)

    Am I missing anything here?


    • Joe Colantonio January 25, 2013, 1:04 pm

      Prabhu » Before you tried the code are you sure that you added the a reference to the OTA COM Type Library?

  • Victor Esquivel January 17, 2014, 10:39 pm

    Is there a way to do this on Java?

    • Joe Colantonio January 18, 2014, 12:01 am

      I’m sure there is but I’ve never done it. Since OTA is a COM DLL you would need some sort of COM to Java bridge.

Leave a Comment