2015-10-13 69 views
0

我正在使用Java web start应用程序(通过JNLP运行)。目前,我想要使用此代码来寻找应用程序主框架:使用Robot定位主框架(JFrame)(FEST Swing测试)

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:超时等待组件使用匹配器找到[email protected] 无法使用匹配器[email protected]查找组件。

下面的方法是,我使用的名称框匹配:

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

可以anyobody请告知,如果我做错什么或不考虑东西,我应该。我是新来的巨星和刚刚开始使用它

感谢

+0

小幅盘整FrameFixture帧= WindowFinder .findFrame(getMainFrameByName() “* MyApp的*。?。?”),使用(机器人)。 frame.focus(); –

回答

0

好像当前AWT层次结构将看到应用程序,如果我从类在本机运行罐子只