Thursday, July 9, 2009

Behavior driven development: Generating Groovy EasyB Story with Selenium IDE

I try to google selenium and easyb, I couldn't found format of Selenium IDE to generate easyb story. So, I decided to create one myself for automated testing of grails project.

Thanks to the post from David, Generating RSpec Tests with Selenium IDE the "Groovy - EasyB - Selenium RC" format is based on his code, easyb Story Example and Java - Selenium RC format come with Selenium IDE.

Download it. from here.
Install it. Open Selenium IDE, select "Options" menu - > "Options ..." menu item. Select "Formats" and click on "Add" button at the left bottom of the screen, you will see two fields, one tiny, one huge. In the tiny field, type "Groovy - EasyB - Selenium RC". In the huge field paste the entire contents of the downloaded file to it and click "OK" button.
Use it. After recorded a test case. Select "File" menu -> "Export Test Case As ..." menu item -> "Groovy - EasyB - Selenium RC" menu item. Please make sure you save the file name as *Story.groovy, for example SimpleGoogleStory.groovy. As easyb's story file name must end with Story.

If you make improvements to this file, please let me know. I’d like to benefit from them as well. Any feedback and suggestion of improvement to the "Groovy - EasyB - Selenium RC" format is welcome.

P/S: Along the way I learn easyb, I found out two important points that seems obvious but not easy for beginner to grasp (I suggest the webmaster of website put these two statements in obvious location):
1) The easyb's story file name must be *Story.groovy or *.story and easyb's specification file name must be *Specification.groovy or *.specification. [More Infor]
2) When to use Story and when to use Specification?
Borrow a statement from Richard Vowles, "Guidelines from The RSpec Book, which says - test APIs with Specifications (as they are more like unit tests) and UI (e.g. controllers) with stories". [More Infor]

Like this blog?

Thanks for visiting! If you like what you see, I'd really appreciate you linking to it or otherwise sharing it with people you think would find it useful.


Tony said...

A very cool integration and another way to tempt Java developers into trying Groovy.

I got this to work only after removing the usages of EqualsArray - is this a version problem? (using IDE v1.0.2 on FF 3.5)

kellyrob said...

Looks great. I've never actually used easyB before, but I write a lot of Selenium tests and this seems to be a great way to try it out.
I'll get back to you when I get a chance to put it to the test.

Lim Chee Kin said...

Hi Tony,
Thanks for report the problem. Yes, the code can run on previous version of Selenium IDE but not version 1.0.2. I have update the code for the fix (Removing the usages of EqualsArray)

Hi kellyrob,
Wish to hear from you soon!

WB said...

I cannot add the script in ver 1.0.6

please let me know how to get around with it.

Lim Chee Kin said...

Hi WB,

I downloaded Selenium IDE 1.0.6 and test it out. It's works! (After click on the "Save" button of "Selenium IDE Format Source" dialog, the dialog remain open. Nevertheless, the new format added successfully, you can see it by click on "Cancel" button to close the dialog box).

Thanks for using it. I would like to hear more about how do you use it. May I know you use it for what project?