3

I am trying to get Java FEST to find a pop up dialogue and click on the the yes button. I have the following code:

JOptionPaneFixture fixture = JOptionPaneFinder.findOptionPane().using(TestSite.myRobot);
fixture.buttonWithText("Yes" ).click();

On the first line the following exception is thrown:

org.fest.swing.exception.WaitTimedOutError: Timed out waiting for component to be found using matcher org.fest.swing.core.TypeMatcher[type=javax.swing.JOptionPane, requireShowing=true] Unable to find component using matcher org.fest.swing.core.TypeMatcher[type=javax.swing.JOptionPane, requireShowing=true].

The option pane of course did pop up on my gui, yet FEST doesn't find it.

I tried using the window finder as mentioned here: FEST Swing new frame on click, can't make new frame fixture

But to no avail!!

Please help!

Community
  • 1
  • 1
whomaniac
  • 1,258
  • 4
  • 15
  • 22
  • Are you using a background thread for this? – Hovercraft Full Of Eels Jul 22 '12 at 14:35
  • There is the multithreaded gui program and the test is running on a seperate thread. I have a sleep call before calling the finder. – whomaniac Jul 22 '12 at 14:48
  • But you're absolutely sure that the call to set the JOptionPane visible and the code above are on two completely distinct threads, right? – Hovercraft Full Of Eels Jul 22 '12 at 14:50
  • yes. This part of an automation test. So the JOptionPane's visibilty configuration is not in the test code. Maybe in the gui code i need to correctly pass the parent frame of my OptionPane popup when I create it? – whomaniac Jul 22 '12 at 14:55
  • 1
    Yup the problem was a null parent frame – whomaniac Jul 22 '12 at 16:13
  • 2
    argh, good pick up. It's always the little things that get you. Thanks for letting us know how you resolved this. 1+ You might want to post your comment above as an answer for the benefit of future coders who run into the same problem. – Hovercraft Full Of Eels Jul 22 '12 at 16:15
  • @whomaniac please post your comment as an answer and accept it to make your question useful to other StackOverflow users. – Richard Neish Jun 17 '15 at 14:01
  • Just wanted to let you know that you could use AssertJ Swing in future; FEST is outdated and not maintained anymore. AssertJ Swing is the fork of FEST so the transition will be easy. Even if the development speed is slow, it is being maintained ;) – Bertram Nudelbach Jul 23 '15 at 17:21

0 Answers0