2011-06-01 32 views
3

的pom.xml看起來像無法刪除文件,同時啓動瀏覽器會話,同時使用Maven插件硒

<build>  
    <plugins> 
     <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>selenium-maven-plugin</artifactId> 
       <version>1.0</version> 
       <executions> 
        <execution> 
         <phase>pre-integration-test</phase> 
         <goals> 
          <goal>start-server</goal> 
         </goals> 
         <configuration> 
          <background>true</background>    
          <logOutput>true</logOutput>        
          <browserSessionReuse>true</browserSessionReuse>        
         </configuration> 
       </execution> 
      </executions> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-surefire-plugin</artifactId> 
      <configuration> 
       <!-- Skip the normal tests, we'll run them in the integration-test phase --> 
       <skip>true</skip> 
      </configuration> 

      <executions> 
        <execution> 
        <id>integration-tests</id> 
        <phase>integration-test</phase> 
        <goals> 
         <goal>test</goal> 
        </goals> 
        <configuration> 
         <skip>false</skip> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
</build> 

的JUnit的TestCase

@Before 
public void setUp() throws Exception { 

    selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://www.google.co.in/"); 
    selenium.start(); 
} 

@Test 
public void testUntitled() throws Exception { 
    selenium.open("/"); 
    selenium.type("q", "Selenium Sucks"); 
} 

@After 
public void tearDown() throws Exception { 
    selenium.stop(); 
} 

我得到執行目標'mvn integration-test'時出現此錯誤消息'我有一個簡單的測試用例,它打開Firefox瀏覽器並在Googe搜索欄中搜索某些文本。

截至目前我還重新安裝了Firefox瀏覽器,但它再次失敗。

例外: 了java.lang.RuntimeException:無法啓動硒會議:無法啓動新的瀏覽器會話:無法刪除文件C:\ DOCUME〜1 \ ADMINI〜1個\ LOCALS〜1個\溫度\ customProfileDirb66b3e06cba84cc1b55eb72a418a5c61 \ parent.lock 在com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:89) 在org.argus.selenium.timepass.TestSelenium.setUp(TestSelenium.java:16)

我在配置中還是在運行mvn目標時丟失了某些東西?

+0

你檢查了上面提到的臨時路徑,看看customProfilefolders是否存在?關閉你的FF瀏覽器,然後檢查Temp文件夾 – 2011-06-02 03:49:01

+0

這個臨時文件夾存在,TaskManager也顯示我在後臺運行的一個firefox實例...但問題是Firefox窗口不彈出,測試沒有播放,我的服務器將退出此實例。 – Vral 2011-06-02 07:27:22

回答

2

傢伙滑稽而怪異.... 只是做出改變的pom.xml

<plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>selenium-maven-plugin</artifactId> 
      <version>1.0</version> 
      <executions> 
       <execution> 
        <phase>pre-integration-test</phase> 
        <goals> 
         <goal>start-server</goal> 
        </goals> 
        <configuration> 
         <background>true</background>    
         <logOutput>true</logOutput>        
         <browserSessionReuse>true</browserSessionReuse>        
        </configuration> 
      </execution> 
     </executions> 
    </plugin> 

更改版本號1.0.1 它應該看起來像

<plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>selenium-maven-plugin</artifactId> 
      <version>1.0.1</version> 
      <executions> 
       <execution> 
        <phase>pre-integration-test</phase> 
        <goals> 
         <goal>start-server</goal> 
        </goals> 
        <configuration> 
         <background>true</background>    
         <logOutput>true</logOutput>        
         <browserSessionReuse>true</browserSessionReuse>        
        </configuration> 
      </execution> 
     </executions> 
    </plugin> 

這應該工作。
謝謝大家:)

相關問題