【发布时间】:2015-10-13 10:00:41
【问题描述】:
我正在使用 Java Web 启动应用程序(通过 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 找到组件时超时 无法使用匹配器 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 的新手,刚刚开始使用它
谢谢
【问题讨论】:
-
小修正FrameFixture frame = WindowFinder.findFrame(getMainFrameByName(".*?MyApp.*?")).using(robot); frame.focus();