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
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
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.

It is just QTP launching, Can we record test script from C#??
Thanks in advance
Sarnendu De
how to i add environment variable to QTPTest?
QuickTest.ApplicationClass _qtApp = new QuickTest.ApplicationClass();
_qtApp.Test.Environment
it returns ERROR: The server threw an exception. (Exception from HRESULT: 0×80010105 (RPC_E_SERVERFAULT)).
Please Help.