2014-05-06 100 views
1

下面是我的代码,Firefox浏览器不与硒的webdriver代码的build.xml打开

@Before 
public void launchApplication() { 
    System.setProperty("webdriver.firefox.bin", "D:/Program Files/Mozilla Firefox/firefox.exe"); 
    System.err.println("In launch application, before launching firefox"); 
    driver = new FirefoxDriver(); 
    driver.get(testURL); 
    driver.manage().timeouts().implicitlyWait(300, TimeUnit.SECONDS); 
} 

当执行上面的代码中使用的junit测试,应用(testURL)被成功地打开和我的测试成功运行。

但是,如果使用build.xml(ant xml)启动它,firefox不会启动,并且在控制台中,我只能看到此消息“在启动应用程序中,启动firefox之前”。之后什么都没有发生。

在这帮助我。

谢谢。

回答

0

也许错误是由于应用程序在启动硒时未运行而引发的?

例如,我有一个从ANT启动Firefox的一个例子ANT代码,但对于Web应用程序首先等待变得可用HTTP端口上:

<parallel> 
    <jetty tempDirectory="${work.dir}"> 
     <connectors> 
      <selectChannelConnector port="${jetty.port}"/> 
     </connectors> 
     <webApp name="dwr" warfile="${lib.dir}/dwr-demo-${dwr.version}.war" contextpath="/dwr"/> 
    </jetty> 

    <sequential> 
     <waitfor> 
      <socket server="localhost" port="${jetty.port}"/> 
     </waitfor> 
     <exec executable="firefox" spawn="yes"> 
      <arg line="http://localhost:${jetty.port}/dwr"/> 
     </exec> 
    </sequential> 
</parallel> 

也许你需要效仿这种逻辑,除非你的单元测试已经启动应用程序?

相关问题