如何使用CI(持续集成)运行Selenium测试?

我使用Selenium来自动测试我的网站。 我有大约100个测试用例,我想通过自动测试套件每天运行它们。 我在Selenium 1(Selenium RC)中编写了我的测试用例,现在迁移到Selenium 2(WebDriver)并不是很容易。 有没有可以自动加载和执行Selenium 1脚本的方法或应用程序?

非常感谢您的帮助。


您无需将您的测试转换为Selenium 2即可运行它们。 Selenium 2包含Selenium 1和Selenium与webdriver合并的所有代码。 您现有的脚本应该在最新版本的硒上运行良好。

从上面的问题我假设你已经在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:absolutepathtomyHTMLSuite.html" "c:absolutepathtomyresults.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作业或计划任务,以便在特定时间自动运行脚本,但我会建议调查一个CI服务器,如Jenkins CI(正式Hudson),可以在特定时间运行测试,或者触发以基于代码提交运行测试。


开始 - >程序 - >附件 - >系统工具 - >计划任务如果你可以让这些脚本被.exe调用,那么你很好去,很好,很容易。


你需要在Windows中设置一个计划任务(假设你在提到C#之后就开始使用Windows)。

因此,在Selenium RC上设置自动化任务,它将运行您的测试。

链接地址: http://www.djcxy.com/p/50779.html

上一篇: How to run Selenium tests with CI (Continuous Integration)?

下一篇: Selenium RC in Hudson