51Testing软件测试论坛

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

QQ登录

只需一步,快速开始

微信登录,快人一步

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

[SilkTest] SilkTest系列---实例篇(Silk4J)之计算器

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2013-11-25 17:18:51 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 沅芷湘兰 于 2013-11-25 17:22 编辑

silk4J是集成在Eclipse里的一个插件,两种方法打开silk4J的操作界面:
1.        打开silkTest后,在打开脚本界面选择silk4J,由silkTest来启动Eclipse
2.        自己动手,直接打开Eclipse
然后再在Eclipse新建一个silk4J的项目,如下图所示:

新建项目,如下图所示:

新建一个测试,如下图所示:

弹出如下窗口:

由于我们测试的计算器是属于CS的标准程序,所以选择“standard Test Configuration”,进入被测程序选择窗口:

选择计算器,进入录制状态:

选择“stop Recording”停止录制,生成的脚本如下:
  1. import com.borland.silktest.jtf.Desktop;
  2. import org.junit.Before;
  3. import com.borland.silktest.jtf.BaseState;
  4. import org.junit.Test;
  5. import com.borland.silktest.jtf.Window;
  6. import com.borland.silktest.jtf.common.types.Point;
  7. import com.borland.silktest.jtf.PushButton;
  8. import com.borland.silktest.jtf.TextField;

  9. public class testCalc01 {

  10.         private Desktop desktop = new Desktop();

  11.         @Before
  12.         public void baseState() {
  13.                 BaseState baseState = new BaseState();
  14.                 baseState.execute(desktop);
  15.         }

  16.         @Test
  17.         public void testCalc01() {
  18.                 desktop.<Window>find("/Window[@caption='计算器']").setActive();
  19.                 desktop.<PushButton>find("/Window[@caption='计算器']//PushButton[@caption='1']").select();
  20.                 desktop.<PushButton>find("/Window[@caption='计算器']//PushButton[@caption='+']").select();
  21.                 desktop.<PushButton>find("/Window[@caption='计算器']//PushButton[@caption='2']").select();
  22.                 desktop.<PushButton>find("/Window[@caption='计算器']//PushButton[@caption='=']").select();
  23.                 desktop.<TextField>find("/Window[@caption='计算器']//TextField").setText("3. ");
  24.         }

  25. }

复制代码
带个操作就已经完成了,当然后续大家可以参照其它的帖子来进行参数化等的操作。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?(注-册)加入51Testing

x
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

本版积分规则

关闭

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

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

GMT+8, 2024-5-22 11:31 , Processed in 0.073588 second(s), 28 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

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