51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 1897|回复: 0
打印 上一主题 下一主题

[原创] 在java中如何调用qtp

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2010-9-3 15:17:18 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
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
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-11-23 22:27 , Processed in 1.222846 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表