Friday, February 17, 2017

Export Selenium IDE scripts for Grails

Export Selenium IDE scripts for Grails


Thanks to the documentation provided on Adam Gouchers blog Ive 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 (doesnt extend anything, uses annotations and assertThat) formats.

I think everything is working. There are some things Id still like to do:
  • Custom commands are currently exported as commented out which they dont need to be given Grails Selenium RC test cases can call Javascript extension functions directly.
  • I havent 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 IDEs File menu.

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

Available link for download