1

Im working with a Java web start app (run through a JNLP). Currently I'm trying to locate Main Frame for the application using this code:

Process p = Runtime.getRuntime().exec("C:\\Windows\\System32\\cmd.exe /c cd C:/Users/ash/Documents/MyApp/Environment & launcher.jnlp", null, new File("C:\\Users\\ash\\Documents\\MyApp\\Environment"));
    p.waitFor();
    Thread.sleep(40000);
    robot = BasicRobot.robotWithCurrentAwtHierarchy();
    robot.settings().delayBetweenEvents(50);
FrameFixture frame = WindowFinder.findFrame(getMainFrameByTitle(".*?MyApp.*?")).using(robot);
    frame.focus();

However I'm getting an error:

org.fest.swing.exception.WaitTimedOutError: Timed out waiting for component to be found using matcher swing.app.simple.test.JavaSwingTests$9@6c5b675e Unable to find component using matcher swing.app.simple.test.JavaSwingTests$9@6c5b675e.

Below method is that I'm using for matching the frame by name:

private static GenericTypeMatcher<javax.swing.JFrame> getMainFrameByName(
        final String frame) {
    GenericTypeMatcher<javax.swing.JFrame> textMatcher = new GenericTypeMatcher<javax.swing.JFrame>(
            javax.swing.JFrame.class) {
        protected boolean isMatching(javax.swing.JFrame frameName) {
            return (frame.replace(" ", "")).equals(frameName.getName()
            .replace(" ", ""));
        }
    };
    return textMatcher;
}

Can anyobody please advise if I'm doing anything wrong or not considering something I should. I'm new to FEST and just starting to use it

Thanks

  • Small correction FrameFixture frame = WindowFinder.findFrame(getMainFrameByName(".*?MyApp.*?")).using(robot); frame.focus(); – Anton.Shalak Oct 16 '15 at 10:39

1 Answers1

0

Seems like current awt hierarchy will see the app if I run it from Class in a native jar only