簡體   English   中英

如何使用CI(持續集成)運行Selenium測試?

[英]How to run Selenium tests with CI (Continuous Integration)?

我正在使用Selenium來自動測試我的網站。 我有大約100個測試用例,我希望每天通過自動創建Test Suite來運行它們。 我已經在Selenium 1(Selenium RC)中編寫了我的測試用例,現在遷移到selenium 2(WebDriver)並不是很容易。 有沒有可以自動加載和執行Selenium 1腳本的方法或應用程序?

非常感謝你的幫助。

您無需將測試轉換為Selenium 2即可運行它們。 Selenium 2包含Selenium 1和Selenium與webdriver合並的所有代碼。 您現有的腳本應該可以使用最新版本的selenium運行。

從上面的問題我假設你已經在Selenium IDE中記錄了你的腳本並希望使用Selenium Server運行它們,如果是這樣的話,請看看以下內容:

Run Selenese Directly Within the Server Using -htmlSuite

You can run Selenese html files directly within the Selenium Server by passing the html file to the server’s command line. For instance:

java -jar selenium-server.jar -htmlSuite "*firefox" "http://www.google.com" "c:\absolute\path\to\my\HTMLSuite.html" "c:\absolute\path\to\my\results.html"

This will automatically launch your HTML suite, run all the tests and save a nice HTML report with the results.

Note

When using this option, the server will start the tests and wait for a specified number of seconds for the test to complete; if the test doesn’t complete within that amount of time, the command will exit with a non-zero exit code and no results file will be generated.

This command line is very long so be careful when you type it. Note this requires you to pass in an HTML Selenese suite, not a single test. Also be aware the -htmlSuite option is incompatible with -interactive You cannot run both at the same time.

以上內容摘自http://seleniumhq.org/docs/05_selenium_rc.html

正如其他人所說,您也可以設置cron作業或計划任務以在設定的時間自動運行腳本,盡管我建議調查像Jenkins CI(正式Hudson)這樣的CI服務器,它可以在設定的時間運行測試或者是觸發根據代碼提交運行測試。

開始 - >程序 - >附件 - >系統工具 - >計划任務如果您可以通過.exe調用這些腳本,那么您可以輕松上手。

你需要在windows中設置一個計划任務(假設你提到C#,你就在Windows上)。

因此,在Selenium RC上設置自動化任務,它將運行您的測試。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM