2009-08-05 185 views

回答

37

您需要的硒RC,你可以得到:
http://seleniumhq.org/download/

而Java 1.5或更高版本(Download Java here

1)安裝Java
2)拆開硒RC。
3)打開的cmd.exe窗口,並轉到該目錄包含Selenium服務器(selenium-remote-control-1.0.1\selenium-server-1.0.1
4)運行以下命令:

java -jar selenium-server.jar -htmlSuite "*firefox" "http://10.8.100.106" "C:\mytestsuite\mytestsuite.html" "C:\mytestsuite\results.html" 

這應該運行測試套件在Firefox和寫結果到html文件。很明顯,您需要將"http://10.8.100.106"參數更改爲您自己的服務器(這可能只是localhost/127.0.0.1

+0

他想運行一個特定的測試,但 – AutomatedTester 2009-08-06 08:39:36

+0

好吧,對不起,我錯過了那個小細節!

那麼在這種情況下,他們應該創建一個新的測試套件HTML文件,其中只包含他們想要運行的單個測試html。可能只需要將現有的測試套件html文件拆分爲一個notiional頁眉和頁腳部分,然後編寫一段簡單的代碼將報頭,測試名稱和頁腳連接在一起,然後通過我在答案中給出的命令運行該代碼。

neokain>你熟悉哪種語言,我會嘗試寫一個更完整的例子。 – jmc 2009-08-06 09:11:00

+0

有沒有辦法使用已打開的Firefox實例運行測試? – 2012-10-30 08:31:02

2

我們應該使用下面的命令執行SeleniumRC;

java -jar filename.jar 

例如:

java -jar program1.jar 

的程序1包括以下內容是:

  1. program1.class文件
  2. 資源庫文件如SeleniumRC Server.jar和硒的Java文件client.jar中

此方法適用於SeleniumRC的執行。我們可以使用 File-> Export從eclipse直接創建program1.jar文件。

0

我都需要之前做到這一點,並使用下列內容:

  1. Ant構建(復)
  2. 創建一個測試運行器類類(JUnit框架的一部分)。

大多數情況下,我們會在嘗試從cmd運行時遇到構建路徑錯誤。

0

爲了能夠在Chrome瀏覽器中運行,你可以使用*鉻選項,而不是*火狐像下面

java -jar selenium-server.jar -htmlSuite "*chrome" "http://localhost" "C:\testsuite\testsuite.html" "C:\testsuite\results.html" 

其他瀏覽器列表包括:

*firefox 
*mock 
*firefoxproxy 
*pifirefox 
*chrome 
*iexploreproxy 
*iexplore 
*firefox3 
*safariproxy 
*googlechrome 
*konqueror 
*firefox2 
*safari 
*piiexplore 
*firefoxchrome 
*opera 
*iehta 
*custom 

會話空

0

如果你想從命令提示符運行它,你可以考慮在python中編寫你的硒測試。 如果你在Windows上,確保你安裝了python。 Mac將默認使用python。

3

使用Selenese Runner可以運行單個測試用例。您可以指定單個測試用例文件或測試套件作爲要運行的單元。

0

1)從CMD運行

java -cp "C:\ProjectX\Mortgage\bin;C:\Selenium_latest\selenium2.49.1\*;C:\Selenium_latest\selenium-2.49.1\libs\*" org.testng.TestNG C:\ProjectX\Mortgage\testng.xml 

運行上述C命令:\ projectX創建\房貸

2)創建批處理文件名runner.bat

SET projectLocation=C:\ProjectX\Mortgage 
CD %projectLocation% 
SET classpath=%projectLocation%\bin;C:\Selenium_latest\selenium-2.49.1\*;C:\Selenium_latest\selenium-2.49.1\libs\* 
java org.testng.TestNG %projectLocation%\testng.xml 
PAUSE 

3)運行通過雙擊它來創建批處理文件。

0

CMD的運行測試非常簡單。

按照以下步驟

1轉到主目錄,並設置類路徑

主目錄>設置CLASSPATH =主目錄\ BIN;並按回車鍵

主目錄> set classpath =主目錄\ lib *;然後按回車

2 - 首頁 - 目錄> Java的組織,testng.TestNG的testng.xml testng2.xml testng2.xml並回車

我已經證明所有steps here。希望它會有所幫助。乾杯

相關問題