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

发布于 2024-10-31 15:33:22 字数 194 浏览 5 评论 0原文

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

非常感谢您的帮助。

I'm using Selenium for automated testing my websites. I have around 100 test cases and I want to run them every day by making Test Suite automatically. I had written my test cases in Selenium 1 (Selenium RC) and now it is not very easy to migrate to selenium 2 (WebDriver). Is there any way or application out there that can load and execute the Selenium 1 scripts automatically?

Thanks very much for the help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

莫言歌 2024-11-07 15:33:22

您无需将测试转换为 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 服务器,它可以在设定的时间运行测试,也可以根据代码提交触发运行测试。

You don't need to convert your tests to Selenium 2 to be able to run them. Selenium 2 contains all the code for Selenium 1 and Selenium merged with webdriver. Your existing scripts should run fine with the latest version of selenium.

From the questions above I am assuming that you have recorded your scripts in Selenium IDE and want to run them using Selenium Server, if so have a look at the following:

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.

The above is taken from http://seleniumhq.org/docs/05_selenium_rc.html

As others have said you can also set up cron jobs or scheduled tasks to automate the running of scripts at set times, although I would suggest investigating a CI server like Jenkins CI (formally Hudson) that can either run tests at a set time or be triggered to run tests based on code commits.

谎言月老 2024-11-07 15:33:22

开始->节目->配件->系统工具->计划任务
如果您可以让这些脚本被 .exe 调用,那么您就可以开始了,非常简单。

Start -> Programs -> Accessories -> System Tools -> Scheduled Tasks
If you can get those scripts to be called by a .exe then you are good to go, nice and easy.

忘东忘西忘不掉你 2024-11-07 15:33:22

您需要在 Windows 中设置计划任务(假设您提到 C# 后就在 Windows 上)。

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

You need to setup a scheduled task in windows (assuming you're on windows since you mention C#).

So setup the automated task on Selenium RC, which will run your tests.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文