Let me introduce you to Geb:
assert title == "Google"
$("input", name: "q").value("wikipedia")
$("input", value: "Google Search").click()
assert title.endsWith("Google Search")
def firstResultLink = $("li.g", 0).find("a.l")
assert firstResultLink.text() == "Wikipedia, the free encyclopedia"
This basic example uses Geb without defining page objects - a more powerful feature. The code will navigate to Google, search for "Wikipedia", and verify that the first result is for Wikipedia. Geb can be used by itself for scripting or within an application's codebase.
Geb combines the expressiveness of Groovy with WebDriver and a jQuery-inspired content navigation/inspection API . It is compatible with IE, Firefox, Chrome, and HTMLUnit. Some of Geb's more powerful features include page objects, modules, and a Content DSL that can be used for modules or pages.
About the page object pattern, the documentation states:
The implementation of how to search and how to find the results is going to have to be duplicated in every test, maybe many times per test. The Page Object Pattern allows us to apply the same principles of modularity, reuse and encapsulation that we use in other aspects of programming. … As anyone who has tried to knows, maintaining a large suite of functional web tests for a changing application can become an expensive and frustrating process. A core philosophy of Geb is to address this issue through its content definition DSL.
The Content Domain-Specific Language module is for defining reusable content templates. There are no restrictions on what arguments can be passed to content templates. The Content DSL used for modules is exactly the same as the one used for pages.
To learn more, check out the documentation and give it a try!