Extremely sorry about the delay on Part 2 of this series. Graduate exams are just round the corner and I am unable to find time for quality research. Exams get over by end of November.
I thoroughly enjoy Geb and I think it is the most stylish way to write functional tests. So, I could promise you one thing - this is going to be a fun ride.
This is Part 1 of i-dont-know-how-many parts of how to build some cool functional/smoke tests with reporting abilities based on Geb. The end goal will be to replace the stack mentioned here.
So, the Prerequisites :
Some Groovy Magic. Most of all that you need to learn Groovy is covered in this manual but for obvious reasons if you get obsessed with the language you might want to consider Groovy in Action. If you are from a Java (except for closures) or a Python background, you could probably skim through the tutorial for 15 minutes and you are there already).
A little Selenium. The more, the better but fear not this single page tells you all that you need to know about the Selenium Webdriver that you would generally use.
jQuery selectors (everybody says that it is easy but frankly, I refer to the manual at least twice per hour. I am dumb, so…). If you are new to jQuery, you would want to start from basic selectors and click on the left navigation menu for more.
PageObjects is actually not a prerequisite for Geb but PageObjects are so awesome that you never wanted to think about Geb outside of it. Interestingly, PageObjects is not a technology that you need to pick. It is cute little pattern which says that you wrap the structure of your HTML page into an Object so that the actual test does not have to deal with it. Hah. Got you. Let me put that in plain English.
In Selenium, you would do a very similar thing
So, if you would want to populate
Jason in your text box in Selenium, you would do a
If you do that for all your input fields, very soon your testcases become ugly and hateful. Instead of that, in OO terms, you encapsulate. You create a new class, say
RegistrationPage and wrap your
sendKeys as in :
1 2 3 4 5 6 7 8 9 10 11 12
and from your testcase, you would say
1 2 3
(Even better idea is to wrap your input values into a class and pass it to the fillRegistrationForm)
In fact, Geb leverages PageObjects in a much better way - jQuery selectors to the rescue
1 2 3 4 5 6 7 8 9
and in your testcase, you would just say
(you could do even better. Stay tuned)