2013-03-06 68 views
2

我試圖用硒Maven的插件才能使用phantomjs司機從遙控器測試使用的角色樞紐Maven來運行硒服務器,到目前爲止我的插件配置是非常簡單的:運行硒樞紐行家

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

    <execution> 
     <id>stop-seleniump</id> 
     <phase>post-integration-test</phase> 
     <goals> 
     <goal>stop-server</goal> 
     </goals> 
    </execution> 
    </executions> 
</plugin> 

然後我使用maven執行插件鉤phantomjs:

<plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>exec-maven-plugin</artifactId> 
    <version>1.2.1</version> 
    <executions> 
    <execution> 
     <phase>pre-integration-test</phase> 
     <goals> 
     <goal>exec</goal> 
     </goals> 
    </execution> 
    </executions> 
    <configuration> 
    <executable>phantomjs</executable> 
    <arguments> 
     <argument>--webdriver=8080</argument> 
     <argument>--webdriver-selenium-grid-hub=http://localhost:4444</argument> 
    </arguments> 
    </configuration> 
</plugin> 

利用這種結構的輸出是:HTTP ERROR: 403 Forbidden for Proxy,我不能再往前走。任何人都已成功配置此?

+0

我決定採取不同的方法來運行phantomjs的硒測試。但是,如果有人能夠回答這個問題,那將是非常酷的,因爲我認爲這可能是一種更有效的處理集成測試的優雅方式。 – jspboix 2013-03-07 09:31:45

回答

0

只要創建一個使用YAJSW(另一個Java服務包裝器)來容納將網格集線器註冊爲服務的腳本就不會太過分。然後,Maven可以調用腳本並將其作爲自己的獨立進程啓動。此外,Maven可以呼叫停止服務來阻止它。我認爲這將是優雅的。

Here is my almost working attempt。我需要徵求Selenium專家的幫助才能使其工作。註冊意外服務時發生錯誤。儘管大部分工作都完成了。一旦我得到這個工作,這將是很好的去爲你。

現在,雖然可以將Grid Hub作爲服務運行,但您不希望對Node執行相同的操作,因爲它需要訪問桌面(並且服務只能訪問自己的隱形私人桌面)。所以,也許這會讓我們回到你想要解決的同樣的問題。