This plugin provides the Geb dependencies and a create-functional-test
command for generating Geb tests in a Grails app.
It also provides a ContainerGebSpec
class, which can be used in place of GebSpec
, that automatically
runs the browser in a container using Testcontainers. This requires a
compatible container runtime such as
Docker to be installed.
For further reference please see the Geb documentation.
If you are looking for examples on how to write Geb tests, check:
Geb/Grails example project or Grails functional test suite where Geb tests are used extensively.
Grails comes with a set of pre-installed browser drivers.
To set up additional drivers you need to add the driver to your build.gradle
for example:
integrationTestRuntimeOnly "org.seleniumhq.selenium:selenium-edge-driver:$seleniumVersion"
You also need to add it to the GebConfig.groovy
file in the src/integration-test/resources/
directory. For example:
/*
This is the Geb configuration file.
See: http://www.gebish.org/manual/current/#configuration
*/
/* ... */
import org.openqa.selenium.edge.EdgeDriver
environments {
/* ... */
edge {
driver = { new EdgeDriver() }
}
}
Now you can run your tests with the new driver by specifying the Geb environment:
./gradlew integrationTest -Dgeb.env=edge