我正在使用 FEST 测试我的 Java 对话框,我需要测试是否创建了一个新的模式对话框。
@Before
public void setUp() throws Exception {
TestFrame testFrame = GuiActionRunner.execute(new GuiQuery<TestFrame>() {
@Override
protected TestFrame executeInEDT() throws Throwable {
panel = new CustomPanel();
return new TestFrame(panel);
}
});
frameFixture = new FrameFixture(testFrame);
frameFixture.show();
frameFixture.robot.waitForIdle();
}
注意:TestFrame 是一个辅助类,它扩展了 JFrame 以用于单元测试。
在我的测试中,我单击了一个按钮,它会出现一个模式对话框。我正在尝试查找并验证已创建对话框,但是我的所有尝试都找不到任何东西:
WindowFinder.findDialog("Window Title")).using(robot);
其中机器人 =
- BasicRobot.robotWithCurrentAwtHierarchy();
- BasicRobot.robotWithNewAwtHierarchy();
- frameFixture.robot (frameFixture => JFrame)
我也尝试过指定机器人的查找范围:
robot.settings().componentLookupScope(ComponentLookupScope.ALL);
网上有很多 FEST 示例可以调用,robot()
但我不知道这个机器人功能应该如何或应该是什么。
为什么我找不到我新创建的弹出对话框?