在java中如何调用qtp
public static void main(String[] args) {//创建 Application 对象
ActiveXComponent app = new ActiveXComponent("QuickTest.Application");
Dispatch object = app.getObject();
//启动 QuickTest
app.invoke("Launch", new Variant[] {});
//使 QuickTest 应用程序可见
Dispatch.put(app, "Visible", new Variant(true));
//设置 QuickTest 运行选项
Dispatch options = app.getProperty("Options").toDispatch();
Dispatch run = Dispatch.get(options,"Run").toDispatch();
Dispatch.put(run,"CaptureForTestResults",new Variant("OnError"));
Dispatch.put(run,"RunMode",new Variant("Fast"));
Dispatch.put(run,"ViewResults",new Variant(false));
Variant openVariant[] = {new Variant("E:\\Program Files\\Mercury Interactive\\QuickTest Professional\\Tests\\Test8"),new Variant(true)};
//以只读模式打开测试
app.invoke("Open",openVariant);
Dispatch test = Dispatch.get(app,"Test").toDispatch();
//为测试设置运行设置
Dispatch settings = Dispatch.get(test,"Settings").toDispatch();
Dispatch settingsRun = Dispatch.get(settings,"Run").toDispatch();
Dispatch.put(settingsRun,"IterationMode",new Variant("rngIterations"));
Dispatch.put(settingsRun,"StartIteration",new Variant(0));
Dispatch.put(settingsRun,"EndIteration",new Variant(4));
Dispatch.put(settingsRun,"OnError",new Variant("NextStep"));
//创建 Run Results Options 对象
ActiveXComponent qtResultsOpt = new ActiveXComponent("QuickTest.RunResultsOptions");
Dispatch qtResultsOptDispatch = qtResultsOpt.getObject();
这个是在网上看到的,但是我怎么用都用不起来,总是说can't map name to dispid: launch
页:
[1]