Skip to content

An integrated framework for web browser automation and web application testing

Notifications You must be signed in to change notification settings

treyturner/geb-spock-gradle-grid

Repository files navigation

geb-spock-gradle-grid

This multi-module Gradle project leverages Geb and Spock to create a behavior-driven development (BDD) web automation framework. The executable specifications, written in Groovy or Java, read like plain English and drive automated Selenium browser sessions locally or (optionally) against a scalable remote grid. The use of Page Object modeling ensures the maintainability and re-usability of code.

Multi-level logging is supported via slf4j and logback. A shared utility package is utilized to store common code. There is seamless Integration with IntelliJ IDEA, enabling easy step-by-step debugging and the testing of pipeline automation entry-points.

The project is intended for educational and demonstration purposes, and can serve as a starting point to rapidly develop functional web application test suites or automation scripts across a variety of web applications. Additional examples and design patterns will be added over time and an effort will be made to keep the integrated technologies up to date with modern browser standards.

Technologies Integrated

Software Version Description
Groovy 4.0.22 A powerful and expressive JVM (Java) scripting language
Geb 7.0 High level WebDriver API
Spock 2.3 BDD test/specification runner
Gradle 8.5 Build tool & dependency management
Selenium (WebDriver) 4.22.0 Browser automation API
ChromeDriver 126.0.6478.126 Selenium driver for Chrome
GeckoDriver 0.33.0 Selenium driver for Mozilla
slf4j 2.0.13 Logging API
logback 1.5.6 Logging implementation
Spock Reports 2.5.1 Third-party HTML reporting module for Spock

Requirements

Setup & Run

  1. Clone the repo.
  1. Change directory.
  • cd geb-spock-gradle-grid
  1. Run specs.
  • On Windows: gradlew.bat test
  • On Mac / Linux: ./gradlew test
  1. View the results.
  • HTML reports are written to build/reports/tests
  • JUnit XML results (for Jenkins/CI consumption) are written to build/test-results/tests
  • Console text logs are written to build/logs

Configuration

You have a few choices on how to run tests.

  • Browser Type
    • chrome
    • chromeHeadless
    • firefox
    • firefoxHeadless
  • Browser Location
    • local
    • grid
      • For continuous integration. Docker is ideal for setting up your own grid (local or remote)
      • If your grid is remote, set gridUrl in WebDriver.groovy accordingly, or you can set a GRID_URL environment variable, ie. http://your.grid.ip.address:4444/wd/hub

Based on your choices to the above, edit the Globals.groovy file for the module you intend to configure. The browser type set in this file applies to IDEA spec executions only, as Gradle sets a value up front. The browser location applies to both Gradle and IDEA.

IntelliJ IDEA

IDEA works great with Gradle; just 'Import project from existing sources' and select the root build.gradle script.

  • It helps if you check 'auto-import' so your changes to Gradle files are immediately refreshed
  • I also check 'automatically create content roots' for when I add a new modules to settings.gradle

Demos

Search Engine Exercises Module

Google Search Demo

There is currently only a very basic Google search in the Search Engine Exercises module. It illustrates:

Adding new modules

It's easy to add a new module to start testing a new application.

  1. Edit settings.gradle and add a line to include 'your-module'
  2. Copy a build.gradle into the newly created your-module/
  3. Copy a GebConfig.groovy into your-module/src/test/resources
  4. Copy a Globals.groovy into your-module/src/main/groovy/your_package and update the package name accordingly
  5. Start writing Page Objects and specs

About

An integrated framework for web browser automation and web application testing

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages