There is a minor bug in the selenium plugin for Grails. It has been discussed on the mailing list, but I thought I would also document it here. I’m using Grails 1.0.3 with version 0.4 of the selenium plugin, which wraps selenium core version 0.8.3.

If you install the plugin and try to run the new Grails tasks (create-selenium-test, create-selenium-domain-test, or run-selenium), the system fails with the error

Could not execute method appContext
No such property: appContext for class: ...

It turns out that the way the appContext variable is handled in Grails has changed, and the plugin hasn’t yet updated to accommodate it.

The recommended fix is to go into the “plugins/selenium-0.4/scripts” directory in your Grails project, and replace ${appContext} with ${grailsAppName} in all the Groovy scripts.

If you use the Selenium IDE in Firefox to write your tests, then the fix doesn’t matter until you try to use the run-selenium target. Still, might as well fix it everywhere. This came up on the mailing list back in July, so I assume an updated plugin will be available as soon as the author gets around to it.

I also find that adding the path to firefox.exe to my system path (default is “c:\Program Files\Mozilla Firefox” — don’t you hate Windows paths with spaces??) makes it easier to run the test suite.

Incidentally, unlike Canoo Web Test, you have to make sure your web app is running before executing the test suite. Selenium fires up the browser and puts it through the proper sequence, so the app has to be running first.

I’ve decided that rather than choosing between Selenium and WebTest, I actually like using both. The Selenium IDE in Firefox is really slick and easy to use, while the output reports in WebTest are gorgeous.

One thought on “Minor bug in Grails selenium plugin

  1. Thanks for letting me know about this issue with grails-selenium. My apologies for not addressing it sooner. There has been some discussion about the progress of the plugins:

    http://www.nabble.com/Grails-add-ons-plugins%2C-owners-and-knowing-if-things-are-current–att%3A-Selenium%2C-GroovyWs-and-JSunit-owners–td19628880.html

    so I’ve created components for logging problems in JIRA. See http://jira.codehaus.org/browse/GRAILSPLUGINS/component/13494

    This link is also on the plugin homepage http://www.grails.org/Selenium+plugin

    Thanks for using the plugin and your feedback!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.