TechChase
Skip to content


QTP Automation using C# and Visual Studio development Environment

QuickTest Professional (QTP) provides flexibility of writing QuickTest automation scripts in any language and development environment that supports automation, like C# .NET Visual Studio. In this article you will find basic implementation of QTP Automation using C# . There are numerous options for development environments available for designing and running automation scripts.

QuickTest (QTP) automation scripts can be written in any language that support automation ex. VBScript, JavaScript, Visual Basic, Visual C++, or Visual Studio.NET(C#, VB.net).

In this article we used Visual Studio 2008 and .Net C# language, to take advantage of features like Microsoft Intellisense, automatic statement completion, other features. After selecting an environment that supports type referencing , we have to add reference to the QuickTest type library before begin writing or running your automation script.

Creating C# Console Application for QTP Automation

Create a new project in Visual studio, selecting visual C# project console application.

Adding Reference to Object Model

Visual Studio development environment support(s) referencing a type libaray. A type library is a binary file containing the description of the objects, interfaces, and other definitions of an object model.

Visual Studio Add Project Reference

Visual Studio Add Project Reference

Choose Project > References to open the References dialog box for your project,Then select QuickTest Professional Object Library the current installed version of the QuickTest automation type library. Add QuickTest automation object model type library file named QTObjectModel.dll , file stored in <QuickTest installation folder>bin folder.

Writing Automation Script

Simple script to launch QuickTest Professional, Add QTP object model by using QuickTest:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//Quick Test ObjectModel
using QuickTest;

namespace ginitest
{
class Program
{
static void Main(string[] args)
{
//Declare the Application object variable
QuickTest.Application qtpApp;
//Create the Application object
qtpApp = new QuickTest.Application();
//Start QuickTest
qtpApp.Launch();
//Make the QuickTest application Visible
qtpApp.Visible = true;
}// End Main()
}//End Class Program
}//End namespace GiniTest


Digg This
Reddit This
Buzz This
Vote on DZone
Share on a Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

Posted in Automation Solutions, Functional Automation Testing.

Tagged with , , , , , , .

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.


3 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Sarnendu De says

    It is just QTP launching, Can we record test script from C#??

    Thanks in advance

    Sarnendu De

  2. starter says

    how to i add environment variable to QTPTest?

    QuickTest.ApplicationClass _qtApp = new QuickTest.ApplicationClass();

    _qtApp.Test.Environment

  3. Guest says

    it returns ERROR: The server threw an exception. (Exception from HRESULT: 0×80010105 (RPC_E_SERVERFAULT)).

    Please Help.



Some HTML is OK

or, reply to this post via trackback.