2012-01-10 75 views
4

我是基于FEST的GUI测试的新手。让FEST等待应用程序加载

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

@Before  
     public void onSetUp() { 

     MyFrame frame = GuiActionRunner.execute(new GuiQuery<MyFrame>() { 
      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元素查找?

+0

看我的答案在这里http://stackoverflow.com/questions/8957334/making-fests-component-lookup-mechanism-wait-for-a-component-to-exist/11738497#11738497 – Whimusical 2012-07-31 11:05:27

回答

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

这个一看就会暂停您的代码,直到你的GUI有没有什么可以更新。 Pause的优势在于,您不必等待较长的时间间隔就可以等待更长的时间。