简体   繁体   English

使用C#在远程计算机上启动QTP

[英]Launch QTP on remote machine using C#

I am trying to launch QTP on a remote machine using C# code. 我正在尝试使用C#代码在远程计算机上启动QTP。 Below is the code i am using to invoke QTP on local machine. 下面是我用来在本地计算机上调用QTP的代码。 I know that we can invoke QTP using VBS by adding the remote Server IP address as below. 我知道我们可以通过添加如下所示的远程服务器IP地址来使用VBS调用QTP。 Can someone please let me know where to add the Server IP address to my C# code below to launch QTP on remote machine and run the test cases? 有人可以让我知道将服务器IP地址添加到下面的C#代码中的位置,以便在远程计算机上启动QTP并运行测试用例吗?

VBS Code VBS代码

Dim qtApp
Set qtApp = CreateObject("QuickTest.Application","Server IP Address")

C# Code i wanted to implement 我想实现的C#代码

protected void btnExecuteScript_Click(object sender, EventArgs e)
{
          QuickTest.Application QTPInstance = new QuickTest.Application();
          QTPInstance.Launch();
          QTPInstance.Visible = true;
}

In order to create a remote object in C# you need to get the remote Type first. 为了在C#中创建远程对象,您需要首先获取远程Type

Type remoteQTP = Type.GetTypeFromProgID("QuickTest.Application", "Server IP Address");
QuickTest.Application qtp = (QuickTest.Application)Activator.CreateInstance(remoteQTP);

qtp.Launch();
qtp.Visible = true;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM