Pragmatic Test Automation with GEB

Pragmatic Test Automation with GEB

Geb is a Web automation framework using Groovy. It is basically a wrapper over Selenium and provides lots of functionalities making the job of test automation easy and quicker. In this post we talk about Geb & Spock (Groovy) automation framework based on our deep experience in implementing test automation solutions across technologies. Needless to say, GEB helps jumpstart test automation with all the cutting edge automation features ready.

By using GEB & SPOCK framework since the beginning, one can definitely gain advantage over typical Selenium Webdriver Frameworks implemented in Java. There are a few major issues with Selenium WebDriver which results in test architects using Groovy automation framework over it. Below are few suggestions to be kept in mind before using Java for Test Automation:

  1. Java is verbose, sophisticated and language heavy. It can be arguably said that it might be an overkill to use Java for test automation.
  2. But Java is Powerful: On the other hand, Java is extremely robust and powerful with tons of features like OOPS, which cannot be used/ implemented holistically in the scripting languages.
  3. Unmatched Open Source Support: Java being one of the most popular web languages, has virtually unlimited support for third party open source tools/utilities and APIs which may remain unused if we step away from Java.

It’s a catch 22. We want to leave Java being an overkill for test automation, but at the same time we want to keep using it because it is full of features and comes with an unmatched open source support. So is there a way, we can use Java without actually using Java?

Answer is Yes, Groovy. Groovy offers:

  • An agile and dynamic language for the Java Virtual Machine
  • Modern programming features available to java developers with low learning curve
  • Ability to statically type check and statically compile your code for robustness and performance
  • Ability to Share base syntax, type system, packages hierarchy with Java
  • Gradle build file ( a groovy script )

GEB Automation Framework:


Geb is a Web automation framework using Groovy. Geb uses WebDriver to test web applications using either real browsers or the HtmlUnit library. What sets Geb apart from the competition is the jQuery-like syntax for querying your HTML pages and its built-in support for the Page Object pattern.

Related :   4 Script-less Test Automation Myths you should not believe

GEB does all the heavy lifting under the hood, eases and improves the productivity of an automation developer manifold.

Few Highlights of Geb:

  • Power of WebDriver
  • Elegance of jQuery Selection
  • Robustness of Page Object Modelling
  • Expressiveness of Groovy

A typical GEB automation script:
The simple,elegant & intuitive scripting as above, makes test automation really easy, fast and effective. This further makes test automation maintenance simpler to update as required with minimal technical complexity, which is really an aid as the test automation grows in terms of size and complexity over the period of time.

SPOCK: Groovy Unit Testing Frameworkspock-logo

The combination of Groovy and GEB is really simple and elegant but the real power comes when it is combined with SPOCK which is a Groovy Unit testing framework (inspired from Junit) which adds lots of much required features in the test automation. Spock is an out of the box framework which works well without compromising the overall simplicity and design of Groovy and GEB framework. There are a couple of strong features which come from SPOCK but it is not a comprehensive list mentioned below:

  1. Data Driven Testing utilising external data sources including text, CSV, excel & databases
  2. Comprehensive Extensible Multi-level status reporting in HTML,XML and plain text formats
  3. Detailed Logs and stack traces for quick root cause analysis in Debugging
  4. Power Assertions
  5. Screenshot Capturing & Screen scraping for capturing DOM structures for later analysis

Selenium Webdriverse-logo

Under the hood, GEB uses powerful Selenium WebDriver APIs which does not need any introduction in the test automation world. In fact, it has become the de facto standard across industry. GEB uses all the power inherited in the Selenium WebDriver API without exposing the complexity to the end User.

cross-browser-iconCross Browser Support

The framework has been designed to specially encounter the most pressing problem in test automation-Cross browser Support. It supports execution on all the standard prevailing browsers, including IE, Firefox, Chrome and more. It also supports headless browser execution for quick turnaround for building verifications and smoke test suites.

Related :   Automated Testing on Real Vs Virtual Devices

Seamless Integration with CI(Jenkins)Jenkins-logo

It has been designed to support CI execution, which has been tested and proven with large scale test automation with Jenkins, which is the standard CI tool for the industry.In the same way it can be integrated with other CI tools as it supports extensively multiple build tools including Maven & Gradle which helps to provide plug and play solutions for most CI test environments.


Cloud Based Test Execution with BrowserStack & Sauce Labs

browserStaks-logoIt has been completely integrated with BrowserStack, which can be utilized over the air for a quick build verificationssauce-labs-logo or large automation suite in any desired environment having support for Cross Platform and across browsers including Windows, MAC, and Linux with IE, Firefox and Chrome browsers.


Apache Maven is an effective software project management and comprehension tool. Based on the concmaven-logoept of an overall project object model (POM), it can be used to  manage a project’s build, reporting and documentation from a central piece of information.


Gradle is a project automation tool that builds upon the concepts of Apache Ant and Apache Maven and introduces a Groovy-based domain-gradle-logospecific language (DSL) instead of the more traditional XML form of declaring the project configuration. Gradle takes the build automation capability to the next level from the Ant & Maven with the grace and easiness of Groovy. This framework works with Gradle completely and can be integrated with a variety of tools further, using Gradle seamlessly and quickly.

Synergy which comes with the integration of all these tools & components, significantly helps to jump start the test automation in most of the settings right away, which in turn accelerates the overall testing process, as observed in a number of our diverse project’s environments in Gallop.

Gallop’s Framework supports complete automation building, dependency management and project creation using all the above mentioned tools which can also be utilized for smooth CI as well as local execution setups across multiple systems.

Gallop’s custom test automation framework integrated with leading tools and reusable libraries makes it easy to kick start the automation efforts.

The opinions expressed in this blog are author's and don't necessarily represent Gallop's positions, strategies or opinions.