1

私はJava Web Startアプリ(JNLPを介して実行)を使用しています。現在、次のコードを使用してアプリケーションのメイン フレームを見つけようとしています。

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();

ただし、エラーが発生します:

org.fest.swing.exception.WaitTimedOutError: マッチャーの swing.app.simple.test.JavaSwingTests$9@6c5b675e を使用してコンポーネントが見つかるのを待っているときにタイムアウトしました.

以下の方法は、フレームを名前で一致させるために使用しているものです。

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;
}

私が何か間違ったことをしているのか、それとも私がすべきことを考えていないのか、誰かアドバイスしてもらえますか。FEST は初めてで、使い始めたばかりです

ありがとう

4

1 に答える 1

0

クラスからネイティブjarのみで実行すると、現在のawt階層にアプリが表示されるようです

于 2015-10-29T13:16:19.367 に答える