繁体   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