gpt4 book ai didi

java - FEST Swing new frame on click,无法制作新的框架夹具

转载 作者:行者123 更新时间:2023-11-30 11:44:45 25 4
gpt4 key购买 nike

我正在尝试编写 Fest Swing 测试,但在制作/寻找框架夹具时遇到了问题。我有两个 JFrame,一个在单击时打开另一个,我想:

1.) 找到新打开的JFrame的frame fixture

2.) 从创建的新 JFrame 对象中创建一个新的 frame fixture(我可以从原始 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。有什么建议么?谢谢!

最佳答案

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

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

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

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

关于java - FEST Swing new frame on click,无法制作新的框架夹具,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10626357/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com