Ad-Hockery

ad-hockery: /ad·hok'@r·ee/, n.
Gratuitous assumptions... which lead to the appearance of semi-intelligent behavior but are in fact entirely arbitrary. Jargon File

Export Selenium IDE scripts for Grails

Thanks to the documentation provided on Adam Goucher’s blog I’ve created a simple Firefox plugin that extends the Selenium IDE and adds formatters that allow you to export a script as a Grails Selenium RC test case. You have the option of JUnit 3 (extends GroovyTestCase, uses assertEquals) or JUnit 4 (doesn’t extend anything, uses annotations and assertThat) formats.

I think everything is working. There are some things I’d still like to do:

  • Custom commands are currently exported as commented out which they don’t need to be given Grails Selenium RC test cases can call Javascript extension functions directly.

  • I haven’t yet figured out how to output a command such as

    selenium.waitForAlertPresent()

rather than

selenium.waitFor {
    selenium.isAlertPresent()
}

The Firefox plugin is available from Selenium HQ. You will need to have Selenium IDE installed for it to work, obviously. Once installed you should find options

  • Export Test Case As → Grails Selenium RC (JUnit 3)

  • Export Test Case As → Grails Selenium RC (JUnit 4)

have been added to Selenium IDE’s File menu.

Whilst I would certainly not leave the exported test case as is it’s a quick way to get started. From the exported script you can easily refactor out some page objects or helper methods.

Web Statistics