我在尝试使用 BasicRobot (FEST) 时得到以下信息。我不知道如何解决这个问题。
[ConditionalEventPump] Exception occurred during event dispatching:
java.lang.IllegalThreadStateException: Cannot call method from the event dispatcher thread
at org.fest.swing.core.BasicRobot.waitForIdle(BasicRobot.java:669)
at org.fest.swing.core.BasicRobot.waitForIdle(BasicRobot.java:654)
at org.fest.swing.core.BasicRobot.click(BasicRobot.java:426)
at org.fest.swing.core.BasicRobot.click(BasicRobot.java:387)
at org.fest.swing.core.BasicRobot.click(BasicRobot.java:372)
at org.fest.swing.core.BasicRobot.click(BasicRobot.java:360)
at org.fest.swing.driver.ComponentDriver.click(ComponentDriver.java:94)
at org.fest.swing.fixture.JButtonFixture.click(JButtonFixture.java:99)
这是代码:
BasicRobot robot = (BasicRobot) BasicRobot.robotWithCurrentAwtHierarchy()
MainFrame.button( "setup" ).click();
//Exception is thrown in this line
DialogFixture setupViewDialog = WindowFinder.findDialog( "setup" ).using( robot );
setupViewDialog.button( "Save" ).click();
我怎样才能解决这个问题?