user1307904
user1307904

Reputation:

Stop QTP execution using c#

I recently started working on Selenium and QTP. I have been tasked to fulfill a requirement from the testing team to programatically stop QTP using C#. This small implementation is part of a framework that the team wants to put in place.

I am not sure what I am doing wrong, but according to the documentation, what I am doing should technically work, but it doesn't.

I am able to get the test status etc., but when I try to stop the test, everything goes wrong. QTP stops responding and I fail to even manually stop the test. Below is my code:

Example 1

QuickTest.Application qtp = new QuickTest.Application();
if (qtp.Test.IsRunning)
{
    MessageBox.Show("Test is running"); // works
    qtp.Test.Stop(); // qtp halts and i can't stop execution manually also
}

Example 2

The same as above, except I try to connect to qtp using the following statement:

var app = Marshal.ActivateObject("QuickTest.Application") as QuickTest.Application;

What am i doing wrong?

Upvotes: 2

Views: 1028

Answers (1)

NaveenKumar Namachivayam
NaveenKumar Namachivayam

Reputation: 1202

How about killing the process of QTP, instead of stopping the execution? Does it solve your problem.

Upvotes: 1

Related Questions