Automation Testing

UFT API How to Save a QC/ALM Resource using OTA

By Test Guild
  • Share:
Join the Guild for FREE

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#. (FYI this functionality is now available in the latest version of UFT API)

How to configure UFT API 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
  • When you run your script, the resource file should download to your local directory

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

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


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


  3. 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!


  4. 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?


      1. When i use the above code i am seeing the below error:-
        Compilation started.
        Warning MSB3245: Could not resolve this reference. Could not locate the assembly “TDAPIOLELib”. Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
        Error MSB3091: Task failed because “AxImp.exe” was not found, or the correct Microsoft Windows SDK is not installed. The task is looking for “AxImp.exe” in the “bin” subdirectory beneath the location specified in the InstallationFolder value of the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A. You may be able to solve the problem by doing one of the following: 1) Install the Microsoft Windows SDK. 2) Install Visual Studio 2010. 3) Manually set the above registry key to the correct location. 4) Pass the correct location into the “ToolPath” parameter of the task.
        Compilation failed. (00:00:14.2744273)

  5. Hi,

    How to test a POST service with payload in QTP

    Preview taken from POSTMAN tool:

    POST /xxx/services/xxx/xxxx/xxxxxxx HTTP/1.1
    Content-Type: application/json
    Cache-Control: no-cache


  6. Hi Joe,

    Thanks for this and I also enjoyed your API testing manifesto. I have followed your steps however I don’t get the option exactly as you have it

    TDAPIOLELib.TDConnection qcConn = new TDAPIOLELib.TDConnection();

    TDAPIOLELib.TDConnection qcConn = new TDAPIOLELib.TDConnectionClass();

    I can log in ok but cannot get passed the line
    oResource = (QCResourceFactory)qcConn.QCResourceFactory;

    as it throws an error. Any ideas why the TDConnection lines are different



  7. Under your CodeActivity#_OnExecuteEvent add the following code

    There is no code here on this page could you please update.

  8. I am not getting QCResourceFactory class type inside TDAPIOLELib library although required library is added from COM as suggested, hence I am unable to perform any operation from ALM in C#, could you please let me know what will be possible issue, I am using ALM 12.03 and UFT 14.03 and for API testing and I have to download Excel from either resource or Test Plan.


{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Mastering AI in Test Automation: Expert Tips!

Posted on 05/14/2024

Over the last couple of years, many of my podcast guests who work ...

What is Synthetic Monitoring? (2024 Guide)

Posted on 04/18/2024

I've found over the years many testers are unsure about what is synthetic ...

SafeTest: Next Generation Testing Framework from Netflix

Posted on 03/26/2024

When you think of Netflix the last thing you probably think about is ...