[英]Locating Main Frame (JFrame) using Robot (FEST Swing tests)
Im working with a Java web start app (run through a JNLP). 我正在使用Java Web Start应用程序(通过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. org.fest.swing.exception.WaitTimedOutError:超时等待使用匹配器swing.app.simple.test.JavaSwingTests$9@6c5b675e找到组件无法使用匹配器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
我是FEST的新手,刚开始使用它
Thanks 谢谢
如果仅从本机jar中的Class运行它,似乎当前的awt层次结构将看到该应用程序
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.