使FEST等待应用程序加载

我是基于FEST的GUI测试的新手。

MyFrame是我的应用程序的根类。

@Before public void onSetUp() { MyFrame frame = GuiActionRunner.execute(new GuiQuery() { protected MyFrame executeInEDT() { return new MyFrame(); } }); frame2 = new FrameFixture(robot(), frame); frame2.show(); // shows the frame to test } 

当我运行测试用例时,

 @Test public void testGui() { String rs = frame2.label("hl").text().toString(); assertTrue(rs.equals("First")); } 

上述方法不会打印标签中存在的实际字符串。

我认为FEST API不等待应用程序加载。

是否有任何方法可以推迟GUI元素查找?

 //do your clicks fixture.robot.waitForIdle();//give the GUI time to update //do your asserts 

这将暂停您的代码,直到您的GUI没有任何内容可以更新。 Pause的优点是,您不必通过传递大的时间间隔等待所需的时间。

也许你可以使用org.fest.swing.timing中的pause方法。

看看这里http://fest.easytesting.org/swing/apidocs/org/fest/swing/timing/Pause.html