I’m having issues with some test cases that make use of JFileChoosers. I’m looking for a way to programmatically get rid of file chooser windows (instead of pressing ESC 7 times) when running the JUnit tests.
I’ve tried to include the following in my test case:
Robot robot = new Robot();
robot.delay(1000);
robot.keyPress(KeyEvent.VK_ESCAPE);
This does not seem to work.
Do you have a suggestion?
Thanks in advance.
Just a guess, but sounds like you’re running the
Roboton the same thread as you’re launching theJFileChooser. If memory serves, a lot of the JFileChooser methods block the current thread until the user has selected a file.Try launching the
Robotin a separate thread if you aren’t already.EDIT:
For example: