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: 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 .

下面的方法是我用来按名称匹配框架:

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 中的 Class 运行它,似乎当前的 awt 层次结构将看到该应用程序

于 2015-10-29T13:16:19.367 回答