开发者

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

开发者 https://www.devze.com 2023-02-23 13:23 出处:网络
I\'m using Selenium for automated testing my websites. I have around 100 test cases and I want to run them every 开发者_如何学Goday by making Test Suite automatically. I had written my test cases in S

I'm using Selenium for automated testing my websites. I have around 100 test cases and I want to run them every 开发者_如何学Goday 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.


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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消