FEST-swing example not working, frame.isShowing () return false

Try using FEST-Swing testing for the Swing GUI and using the example from http://easytesting.org/swing/wiki/pmwiki.php?n=FEST-Swing.LaunchFromMain

Unfortunately, frame.isShowing () always returns false, although I can already see that JavaApp Swing works

See my codes

... ApplicationLauncher.application(JavaApp.class).start(); GenericTypeMatcher<Frame> matcher = new GenericTypeMatcher<Frame>(Frame.class) { protected boolean isMatching(Frame frame) { System.out.println("title:" + frame.getTitle() + " showing:" +frame.isShowing()); // .getTitle()); return "Java Application".equals(frame.getTitle()) && frame.isShowing(); } }; Robot robot = BasicRobot.robotWithNewAwtHierarchy(); FrameFixture frame2 = WindowFinder.findFrame(matcher).withTimeout(5000).using(robot); ... 

from console log

 title: showing: false 

Two questions:
1. I have to use Frame insteaf JFrame, otherwise it cannot be matched, it causes the wrong name, I expect the "Java application"
2. frame.isShowing () always returns false, it seems strange

BTW: The latest code requires a parameter for GenericTypeMatcher () RGS / Larry

+1
source share
1 answer

The problem is that you call robotWithNewAwtHierarchy after you start the application. It happens that any frame or dialog box created by calling robotWithNewAwtHierarchy will not be visible to the created robot.

You can move robotWithNewAwtHierarchy to the line where you start the application, or you can use robotWithCurrentAwtHierarchy (which will see any instance frame or dialog, regardless of when this method is called.)

+3
source

Source: https://habr.com/ru/post/989285/


All Articles