【问题标题】:FEST Swing new frame on click, can't make new frame fixtureFEST 点击时摇摆新框架,无法制作新框架夹具
【发布时间】:2012-05-17 14:38:22
【问题描述】:

我正在尝试编写 Fest Swing 测试,但无法制作/找到框架夹具。我有两个 JFrame,一个在点击时打开另一个,我想要:

1.) 找到打开的新 JFrame 的框架夹具

2.) 从创建的新 JFrame 对象中制作一个新的框架夹具(我可以从原始 JFrame 对象中获取该对象。)

我尝试过使用

    GenericTypeMatcher<secondGUI> matcher = new GenericTypeMatcher<secondGUI>(secondGUI.class) {
        protected boolean isMatching(secondGUI frame) {
            System.out.println("0".equals(frame.getTitle()) && frame.isShowing());
            return "0".equals(frame.getTitle()) && frame.isShowing();
        }
    };
    Robot robot = BasicRobot.robotWithCurrentAwtHierarchy();

找到框架,但遇到 EdtViolationException。

我也试过

    secondGUI secGUI = GuiActionRunner.execute(new GuiQuery<secondGUI>() {
        @Override
        protected secondGUI executeInEDT() throws Throwable {
            return firstGUI.getController().getWindows().get("0");
        }
    });
    FrameFixture secondWindow = new FrameFixture(secGUI);

但最后一行也给出了 EdtViolationException。 有什么建议么? 谢谢!

【问题讨论】:

    标签: java swing fest


    【解决方案1】:

    尝试使用框架的标题找到你的框架:

    Robot robot = BasicRobot.robotWithCurrentAwtHierarchy();
    FrameFixture frame = WindowFinder.findFrame("Title of my frame").using(robot);
    

    另外,secondGUI 应该是 SecondGUI,因为它是一个类名。

    顺便说一句,很高兴见到另一个 FEST 用户。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-20
      • 1970-01-01
      • 1970-01-01
      • 2012-03-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多