Selenium_grid_logo_large Continuous Integration with Hudson
by Amit Easow

To give you a little history

Before I discovered Selenium grid and Hudson, I put in place a system for continuous testing using Selenium scripts written in HTML, Cruise Control for continuous integration and Subversion for version control of software code.

Prerequisites:

Download and install Selenium Grid. Run the sample demo to get a feel of what you are working with. I decided to teach myself ruby and what better way to do that than to play with an open source system, which recommends it.

Running the test cases locally??

After downloading the selenium grid project, I renamed it to seleniumSystemTests. Then I created my testSuite directory using the code in the examples/ruby directory, as a reference. Copy the Rake file and the equivalent of the spec_helper file from the examples/ruby directory to the testSuite directory. Modify the URL for application under test, in the spec_helper file equivalent.

application_host = ENV['SELENIUM_APPLICATION_HOST'] || "www.comcast.net"


I added my test cases in the testSuite directory and was able to run the test suite locally by following the steps below

In the first terminal (Mac OS X)

In the second terminal

In the third terminal

Add the seleniumSystemTests project into subversion

svn import seleniumSystemTests https://<svn_server_url>/path/to/repo/seleniumSystemTests -m "Checking in the selenium project"??

Running the test cases remotely

Now that the test cases are running successfully with the hub and remote controls running on the same local machine, the next logical step is to run the hub and remote controls on separate machines.

Machine A:??

Machine B:

Go back to Machine A (continuing from where we left off)

rake tests:run_in_parallel

FAIL!!!!!

This is because the remote control server is set to localhost. Open the testSuite directory and find the spec_helper file equivalent. Modify it to say

remote_control_server = ENV['SELENIUM_RC_HOST'] || "<machineA_url>" ?? ??


Running the test cases remotely and continuously

Now that the test cases are running remotely, the next logical step is to integrate it with Hudson to run it continuously. Sign into Hudson and configure it as below.

First create a node called Selenium Grid


Secondly create a Hudson project to run the test cases regularly

cd testSuite

rake tests:run_in_parallel


Finally, click the Build Now button and sit back.??


Hope this helps. Now you will receive an email only when the build breaks. In that case, once you open the URL in the email click the Console Output link. Now you can debug the problem.

Running the test cases remotely and continuously

Now that the tests are running continuously against the web application on an hourly basis, the next logic step I am going to take is to run it against more environments. Right now the test cases were running against the Mac/FF environment. Mac/Safari, Windows/IE and Windows/FF are on my list. From my initial investigation it looks like this should work by adding more parameters, indicating the browser and operating system being used, while starting up the remote control and while running the test cases.

Further logical steps include

Look out for further posts when I put the final pieces in place.