Git Product home page Git Product logo

geb-example-grails's Introduction

Example of Geb & Grails integration

Master branch - Travis badge geb-1.1.1 - Travis badge

OCI Webinar: Browser Automation with Geb and Grails

This repositories contains a Grails 3 application which uses WebDriver 3.x and Geb 2.x. Both JDK8 only. Check Branch geb-1.1.1 for an example of Grails 3 in combination with Geb 1.1.1, Web Driver 2.4.x JDK7 compatible.

The Spock tests RoomCRUDSpec, ExtraCRUDSpec, BookingCRUDSpec, used in this project extend from geb.spock.GebReportingSpec.

This superclass is shipped by Geb Spock integration. This superclass automatically takes reports at the end of test methods with the label “end”. They also set the report group to the name of the test class (substituting “.” with “/”).

The build reports directory is defined in build.gradle

To allow integration tests to be run without Geb Specifications, RoomCRUDSpec, ExtraCRUDSpec and BookingCRUDSpec are annotated with:

@IgnoreIf({ !System.getProperty('geb.env') })

The application uses Geb Pages and Modules to faciliate test maintainability.

The Page Object Pattern allows us to apply the same principles of modularity, reuse and encapsulation that we use in other aspects of programming to avoid such issues in browser automation code.

This application leverage Geb environments to run tests with three different drivers:

  • Chrome
  • Chrome Headless
  • Firefox

Those drivers are configured in GebConfig.groovy

You can run integration tests with different browsers by supplying geb.env System Property.

./gradlew -Dgeb.env=chrome iT
./gradlew -Dgeb.env=chromeHeadless iT
./gradlew -Dgeb.env=firefox iT

Gradle Plugins

The application uses webdriver-binaries to cache WebDriver binaries specific to the OS the build runs on.

The application applies Idea JUnit plugin to the project which together with webdriver-binaries does the following:

  • configure the ideaWorkspace task added to the build by Gradle's built-in IDEA plugin to depend on configureChromeDriverBinary and configureGeckoDriverBinary tasks.
  • add system properties specific for the drivers setting the path to the downloaded binaries as their values to default default JUnit run configuration in IntelliJ when the configuration tasks are executed The above will ensure that locations of driver binaries are picked up when running tests from IntelliJ.

Geb Tests in CI

This repository runs its tests in Travis using Chrome Headless. Check .travis.yml and travis-build.sh to see the configuration.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.