【发布时间】:2011-02-11 11:49:07
【问题描述】:
尝试使用 FEST-Swing 进行 Swing GUI 测试,并使用来自 http://easytesting.org/swing/wiki/pmwiki.php?n=FEST-Swing.LaunchFromMain 的示例
不幸的是,虽然我已经看到 JavaApp Swing 正在运行,但 frame.isShowing() 总是返回 false
查看我的代码
...
ApplicationLauncher.application(JavaApp.class).start();
GenericTypeMatcher<Frame> matcher = new GenericTypeMatcher<Frame>(Frame.class) {
protected boolean isMatching(Frame frame) {
System.out.println("title:" + frame.getTitle() + " showing:" +frame.isShowing()); // .getTitle());
return "Java Application".equals(frame.getTitle()) && frame.isShowing();
}
};
Robot robot = BasicRobot.robotWithNewAwtHierarchy();
FrameFixture frame2 = WindowFinder.findFrame(matcher).withTimeout(5000).using(robot);
...
来自控制台日志
title: showing: false
两个问题:
1.我必须使用JFrame的Frame insteaf,否则无法匹配,导致标题不正确,我期待“Java应用程序”
2. frame.isShowing()总是返回false,好像很奇怪
顺便说一句:最新的代码似乎需要 GenericTypeMatcher() 的参数 rgs/拉里
【问题讨论】:
标签: swing gui-testing