Click here to Skip to main content
16,018,904 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Friends,

I am working on an application in which I am downloading a Qtp script. I need to pass this to Qtp for automatic execution, but I want to do this programatically.

I want to do this in C#. Please suggest me if Qtp Apis are available or something, through which I can automate this process.

Thanks,
Jagjot
Posted
Updated 11-Feb-11 0:55am
v2

Can't you just execute CScript with the script as a temporary file?

You should be able to do that using Process.Start
 
Share this answer
 
Comments
Jagjot Singh 11-Feb-11 8:09am    
OK, I can start qtp with Process.Start, but how to pass the script and run that script? Please suggest
I think you would like to rummage around this site a little: http://qtp.blogspot.com/2008/11/qtp-apis-dlls-and-more.html[^].
It has an abundance of information including tutorial and examples.

Cheers!
 
Share this answer
 
You can integrate QTP with C# dot net,
QTP provides managed dll for dot net integration with it.
     
  • Mercury.QTP.CustomServer.dll (QTP provided dll for dot net)
  • Janus.Windows.GridEX.v3.dll (Janus provides managed dll for identifying janus grid and its attribute.)

    Regards,
    Munna Sarfraz
  •  
    Share this answer
     
    Add reference to Interop.QuickTest.dll in your project/solution - QTP 11, and most likely the last 2 or so versions

    The below code is running for many months in production environment

    C#
    qtApp = new QuickTest.Application(); // reference to QTP Application
    qtApp.Launch();  // Launch QTP
    qtApp.Visible = true; // or false - set visible state
    qtApp.Options.Run.RunMode = "Normal";  // Run Mode
    qtApp.Options.Run.StepExecutionDelay = 250;  // Delay between execution of steps
    qtApp.Options.Run.ViewResults = false;  // Do not view results at end of test
    
    string scriptPath = uncPathToScript;  // UNC path to script, or and other drive/location that the application invoking QTP has access to
    qtApp.Open(scriptPath, true, false);  // Open the script, read only, do not save changes
    
    // Get a reference to the test object
    QuickTest.Test qtTest = qtApp.Test;  // Get reference to test object opened/created by application
    
    qtTest.Settings.Run.OnError = "NextStep"; // Stop
    
    // Get a reference to the Results Object for  test results location
    QuickTest.RunResultsOptions qtRRO = new QuickTest.RunResultsOptions();  // This is just here because, possible not necessary
    
    string dt = DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss");
    dt = dt.Replace("/", "-");
    dt = dt.Replace(":", "-");
    dt = dt.Replace(" ", "-");
    
    string reportDirectory = uncPathToScript.Substring(uncPathToScript.LastIndexOf("\\") + 1);
    reportFilePath = uncPathToScript + "\\" + reportDirectory + "_" + dt;
    
    // Create the report directory under the test itself with a date time stamp
    
    System.IO.Directory.CreateDirectory(reportFilePath);  // Create the report directory as a subdirectory of the script to run
    
    qtRRO.ResultsLocation = reportFilePath;  // Set results location to newly created path (folder)
    
    // Run the test
    qtTest.Run(qtRRO, true, null);  // run the test
    qtTest.Close();  // Close the test
    System.Runtime.InteropServices.Marshal.FinalReleaseComObject(qtTest);  // Cleanly release COM object
    qtTest = null; // set object to null
    
    qtApp.Quit();  // Quit QTP
    
    GC.Collect();  // Garbage collect
    GC.WaitForPendingFinalizers();  // Wait for GC
    System.Runtime.InteropServices.Marshal.FinalReleaseComObject(qtApp);  // Cleanly release COM Object
    qtApp = null;  // set to null
     
    Share this answer
     
    Comments
    Member 12154788 9-Dec-17 0:34am    
    where can get Interop.QuickTest.dll and currently is there any other solution can be used for automate the uft ?
    Member 11758575 3-Jan-21 22:54pm    
    I have also the same question.. where can I get the Interop.QuickTest.dll? when I try to add reference, there that is not available. Please help how to get it....

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



    CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900