【问题标题】:FEST-swing example doesn't work, frame.isShowing() return falseFEST-swing 示例不起作用,frame.isShowing() 返回 false
【发布时间】: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


    【解决方案1】:

    问题是您在启动应用程序之后调用robotWithNewAwtHierarchy。发生的情况是,在调用 robotWithNewAwtHierarchy 之前实例化的任何框架或对话框都不会被创建的 Robot 看到。

    您可以将robotWithNewAwtHierarchy 移到启动应用程序的行之前,也可以使用robotWithCurrentAwtHierarchy 代替(无论何时调用此方法,都会看到任何实例化的框架或对话框。)

    【讨论】:

      猜你喜欢
      • 2015-07-13
      • 2018-12-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-31
      • 2013-03-13
      • 1970-01-01
      相关资源
      最近更新 更多