geb-skill
Generates Geb browser automation tests in Groovy with Spock integration. jQuery-like content DSL and page object pattern. Use when user mentions "Geb", "Groovy test", "GebSpec", "Browser.drive". Triggers on: "Geb", "GebSpec", "Groovy browser test", "Browser.drive".
What this skill does
# Geb Automation Skill
For TestMu AI cloud execution, see [reference/cloud-integration.md](reference/cloud-integration.md) and [shared/testmu-cloud-reference.md](../shared/testmu-cloud-reference.md).
## Core Patterns
### Basic Test (Spock)
```groovy
import geb.spock.GebSpec
class LoginSpec extends GebSpec {
def "login with valid credentials"() {
when:
to LoginPage
emailInput.value("[email protected]")
passwordInput.value("password123")
loginButton.click()
then:
at DashboardPage
welcomeMessage.text().contains("Welcome")
}
def "login shows error for invalid credentials"() {
when:
to LoginPage
emailInput.value("[email protected]")
passwordInput.value("wrong")
loginButton.click()
then:
at LoginPage
errorMessage.displayed
errorMessage.text().contains("Invalid")
}
}
```
### Page Objects
```groovy
class LoginPage extends geb.Page {
static url = "/login"
static at = { title == "Login" }
static content = {
emailInput { $("#email") }
passwordInput { $("#password") }
loginButton { $("button[type='submit']") }
errorMessage(required: false) { $(".error") }
}
}
class DashboardPage extends geb.Page {
static url = "/dashboard"
static at = { $(".dashboard").displayed }
static content = {
welcomeMessage { $(".welcome") }
userName { $(".user-name") }
}
}
```
### Navigator API
```groovy
$("css-selector")
$("div", class: "active")
$("input", name: "email")
$("div.items li", 0) // First match
$("div.items li").size() // Count
// Actions
element.click()
element.value("text")
element << "text" // Append text
element.text()
element.displayed
element.@href // Attribute
```
### Cloud: `driver = new RemoteWebDriver(new URL(gridUrl), caps)`
## Setup: Gradle with `geb-spock` and `selenium-support` dependencies
### Cloud Execution on TestMu AI
Set environment variables: `LT_USERNAME`, `LT_ACCESS_KEY`
```groovy
// GebConfig.groovy
environments {
lambdatest {
driver = {
def ltOptions = [
user: System.getenv("LT_USERNAME"),
accessKey: System.getenv("LT_ACCESS_KEY"),
build: "Geb Build",
name: "Geb Test",
platformName: "Windows 11",
video: true,
console: true,
network: true,
]
def caps = new ChromeOptions()
caps.setCapability("LT:Options", ltOptions)
new RemoteWebDriver(
new URL("https://hub.lambdatest.com/wd/hub"), caps)
}
}
}
```
Run: `./gradlew test -Dgeb.env=lambdatest`
## Run: `./gradlew test`
## Deep Patterns
See `reference/playbook.md` for production-grade patterns:
| Section | What You Get |
|---------|-------------|
| §1 Project Setup | build.gradle, GebConfig.groovy, environments, waiting config |
| §2 Page Objects | Content DSL, at checks, modules for reusable components |
| §3 Spec Tests | Spock integration, data-driven with @Unroll, @Stepwise flows |
| §4 Waiting & Async | Waiting presets, JavaScript interaction, alerts/confirms |
| §5 Advanced Patterns | File upload/download, windows, frames, custom extensions |
| §6 API Testing | REST API specs with Groovy JsonSlurper |
| §7 CI/CD Integration | GitHub Actions with headless Chrome, Gradle caching |
| §8 Debugging Table | 12 common problems with causes and fixes |
| §9 Best Practices | 14-item Geb testing checklist |
Related in e2e-testing
playwright-skill
IncludedGenerates production-grade Playwright automation scripts and E2E tests in TypeScript, JavaScript, Python, Java, or C#. Supports local execution and TestMu AI cloud across 3000+ browser/OS combinations and real mobile devices. Use when the user asks to write Playwright tests, automate browsers, run cross-browser tests, test on real devices, debug flaky tests, mock APIs, or do visual regression. Triggers on: "Playwright", "E2E test", "browser test", "run on cloud", "cross-browser", "TestMu", "LambdaTest", "test my app", "test on mobile", "real device".
selenium-skill
IncludedGenerates production-grade Selenium WebDriver automation scripts and tests in Java, Python, JavaScript, C#, Ruby, or PHP. Supports local execution and TestMu AI cloud with 3000+ browser/OS combinations. Use when the user asks to write Selenium tests, automate with WebDriver, run cross-browser tests on Selenium Grid, or mentions "Selenium", "WebDriver", "RemoteWebDriver", "ChromeDriver", "GeckoDriver". Triggers on: "Selenium", "WebDriver", "browser automation", "Selenium Grid", "cross-browser", "TestMu", "LambdaTest".
cypress-skill
IncludedGenerates production-grade Cypress E2E and component tests in JavaScript or TypeScript. Supports local execution and TestMu AI cloud. Use when the user asks to write Cypress tests, set up Cypress, test with cy commands, or mentions "Cypress", "cy.visit", "cy.get", "cy.intercept". Triggers on: "Cypress", "cy.", "component test", "E2E test", "TestMu", "LambdaTest".
test-framework-migration-skill
IncludedMigrates and converts test automation scripts between Selenium, Playwright, Puppeteer, and Cypress. Use when the user asks to migrate, convert, or port tests from one framework to another; rewrite tests in a different framework; or switch from Selenium to Playwright, Playwright to Selenium, Puppeteer to Playwright, Cypress to Playwright, or vice versa. Triggers on: "migrate", "convert", "port", "selenium to playwright", "playwright to selenium", "puppeteer to playwright", "cypress to playwright", "rewrite tests in", "switch from [framework] to [framework]".
robot-framework-skill
IncludedGenerates Robot Framework tests in keyword-driven syntax with Python. Supports SeleniumLibrary, RequestsLibrary, and custom keywords. Use when user mentions "Robot Framework", "*** Test Cases ***", "SeleniumLibrary", ".robot file". Triggers on: "Robot Framework", "*** Test Cases ***", ".robot", "SeleniumLibrary", "keyword-driven test".
laravel-dusk-skill
IncludedGenerates Laravel Dusk browser tests in PHP. Chrome-based E2E testing for Laravel apps. Use when user mentions "Dusk", "Laravel Dusk", "$browser->visit", "DuskTestCase". Triggers on: "Laravel Dusk", "Dusk test", "$browser->visit", "DuskTestCase".