我正在使用 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:WAITING使用匹配器 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 新手,刚刚开始使用它
谢谢
最佳答案
如果我仅从 native jar 中的类运行它,当前的 awt 层次结构似乎会看到该应用程序
关于java - 使用机器人定位主机(JFrame)(FEST Swing 测试),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33099717/