• Home  / 
  • ST
  •  /  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

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();
    qcConn.InitConnectionEx("http://yourQcServer/qcbin/");
    qcConn.Login("your.QcUserName","yourQcPassword");
    qcConn.Connect("yourQcDomain","yourQcProject");
    if(qcConn.ProjectConnected)
    {
    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
    iresStorage.DownloadResource("C:\\OTA_TEST",false);
    }
     }
    qcConn.Disconnect();
    qcConn.Logout();
    }
    qcConn.ReleaseConnection();
  • When you run your script, the resource file should download to your local directory
10 comments
Click here to add a comment