Fork me on GitHub

29 Dec 2009

Selenium RC tests with a remote app

I've just released a new snapshot of the Selenium RC plugin. The main new feature is the ability to run your Selenium tests against a running instance of your application instead of having the application start and stop as part of the test phase. A number of people have requested this. It's really useful for CI environments where you may want to start the app up on a different server from where the tests are being run.

All you need to do is set selenium.remote = true in your SeleniumConfig.groovy and set selenium.url to the root URL of the server where the app is running. Once this is done you can run tests as normal (note: when remote mode is used Selenium tests run in the other phase rather than the functional phase).

The really useful thing is that SeleniumConfig.groovy can contain environment blocks just as other Grails config files can. This means you can enable remote mode in your CI environment but continue to test as normal locally. For example:
selenium {
    remote = false
    // etc.

environments {
    hudson {
        selenium.remote = true
        selenium.url = "http://my.test.server/"

The plugin release is a snapshot so you need to specify the version explictly: grails install-plugin selenium-rc 0.2-SNAPSHOT and you need to be using Grails 1.2.


Robert Elliot said...

This is fantastic - looking forward to using it.

franklin said...

Hi Rob,
what command should I execute to run your sample?
I am trying this without success:
grails test-app production -other
And also:
grails test-app production -functional

My production environment is similar to what you have in your hudson environment.


Rob said...

-other should do it. Can you give any more detail about the problem you are seeing?

By the way, in 1.0 final I will be making remote tests run in the functional phase as I have found a way to prevent it from running the app. I think this will be less confusing for everyone.