Can I use a language other than VBScript to programmatically execute QTP Tests?

大兔子大兔子 提交于 2019-11-28 18:56:47

Apologies, but I don't have time to convert your full sample over to C#. I've thrown together a simple demo that should get you going. This just uses C# to open a QTP instance:

using System;
using QTObjectModelLib;

namespace QtpDemo
{
    class QtpDriver
    {
        [STAThread]
        static void Main(string[] args)
        {
            Application app = new Application();
            app.Launch();
            app.Visible = true;
        }
    }
}

You'll need to compile it linking to C:\Program Files\Mercury Interactive\QuickTest Professional\bin\QTObjectModelLib.dll (which is the .NET interop library for QTObjectModel.dll) and have that and QTObjectModel.dll in your app directory when you run it.

It shouldn't be that hard from here for you to convert any object declarations and function calls from VBScript to C#. Please ask if anything's unclear.

To your other point about samples on the internet - there are plenty of people out there doing more advanced stuff with QTP and QC, but I think any really clever solutions aren't shared. I, for example, would probably be prohibited from sharing such things by my employment contract, but I agree with you - there is a dearth of good QTP API samples out there, at least on Google. Having said that, I heartily recommend the SQA Forums for your QTP and QC needs.

Rich

YES, you can use anything that can "do" COM, and that includes C#. Also VB.NET of course.

and Perl, Python, Javascript, and others.

With no help from google, you will have to follow your nose, on how to deal with the interface, but it's not that difficult when you have the existing example. Also your vendor, ideally, will have documented the COM interface for you.

if this still matters to you... QTP 11 allows you to script in C#

cREcker

Please see the following answer as it will give you the exact information you are looking for to connect a C# application with QTP/UFT:

https://stackoverflow.com/a/19887866/2794121

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!