2014-05-06 97 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> 

也許你需要效仿這種邏輯,除非你的單元測試已經啓動應用程序?

相關問題