Click here to Skip to main content
Licence CPOL
First Posted 22 Feb 2008
Views 15,683
Bookmarked 15 times

QTPInvoker

By | 24 Feb 2008 | Article
This tool simple invokes the QTP from .Net 2005

Introduction

This Article will help to invoke or call QTP i.e, Quick Test Professional from .Net 2005.

Background

To work with this Tool you need to have basic idea about QTP automation on WebPages and C#.Net windows application.

Using the code

Before getting into coding one must have QTP software install in the system.

Add a Textbox and a button into the design of the form.

As getting into code behind, first add QuickTest.dll as reference to the solution.

Create an instance to the QTP application

          QuickTest.Application QTPInstance=new QuickTest.Application();         

With this object creation to the applcation we have the access to the methods and properties of the QTP.

     QTPInstance.Launch(); // To launch the application

     QTPInstance.Visible = false; // To make the applcation visible while running

     QTPInstance.Open(txtFolderPath.Text, true, false);// this will open the script file of automation, extension .mts

     QTPInstance.Test.Run(null, false, null);
// this will run the automation script 

Compile the above code into a function named LanuchQTP() so that is can be used many times.

Points of Interest

The main purpose of QTPInvoker is that it can be used for scheduling the automation run (Automation Tester know it.) Now how to do it?

Very simple...use a timer control to invoke QTP at the specified time

void Schedule_Tick(object sender, EventArgs e)

{

string datetime=dtPicker.Value.ToString("MM/dd/yyyy hh:mm:ss tt");

if (System.DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt") == datetime)

{

Scheduler.Enabled = true; // Scheduler is the timer control

cmdRun.Enabled = true;

LanuchQTP(); // Invokes QTP

MessageBox.Show("QTP Running!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

}

Now how to stop after being invoked? I have used System Diagnostics to kill the application itself

private static void KillProcess()

{

System.Diagnostics.Process[] ps = System.Diagnostics.Process.GetProcessesByName("QTPro")

{

ps.Kill();

}

System.Diagnostics.Process[] qs = System.Diagnostics.Process.GetProcessesByName("QTAutomationAgent")

{

qs.Kill();

}

}

Any Queries mail to roobansolomonraja@rediffmail.com

Rooban Solomon Raja.D

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

RoobanSolomonRaja

Web Developer

India India

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 1 PinmemberretZ7:21 11 Jan '10  
QuestionQuery ??? PinmemberAbhijit Jana3:20 22 Feb '08  
AnswerRe: Query ??? [modified] PinmemberRoobanSolomonRaja3:34 22 Feb '08  
GeneralRe: Query ??? PinmemberAbhijit Jana20:39 22 Feb '08  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web03 | 2.5.120517.1 | Last Updated 25 Feb 2008
Article Copyright 2008 by RoobanSolomonRaja
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid