mcpField
G
geb-skill

geb-skill

github.com/lambdatestTesting & quality384205 installsUpdated 2w ago
Repository

About geb-skill

A reference skill for browser and web testing with Geb and Spock. It helps Groovy test authors use page objects, selectors, cloud execution, API tests, and CI patterns.

Key features

  1. 01Geb and Spock test patterns
  2. 02Page objects and content DSL
  3. 03Selectors and browser interactions
  4. 04TestMu AI cloud execution setup
  5. 05API testing with Groovy
  6. 06CI/CD and debugging guidance

Use cases

  1. 01Writing browser tests with page objects
  2. 02Running tests on TestMu AI cloud
  3. 03Testing REST APIs with Groovy
  4. 04Integrating tests into CI workflows

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/lambdatest/agent-skills --skill geb-skill

After installing, type/geb-skillin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

reference/
advanced-patterns.md
cloud-integration.md
playbook.md

Details

From the project README

Geb Automation Skill

For TestMu AI cloud execution, see reference/cloud-integration.md and shared/testmu-cloud-reference.md.

Core Patterns

Basic Test (Spock)
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
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
$("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

// 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:

SectionWhat You Get
§1 Project Setupbuild.gradle, GebConfig.groovy, environments, waiting config
§2 Page ObjectsContent DSL, at checks, modules for reusable components
§3 Spec TestsSpock integration, data-driven with @Unroll, @Stepwise flows
§4 Waiting & AsyncWaiting presets, JavaScript interaction, alerts/confirms
§5 Advanced PatternsFile upload/download, windows, frames, custom extensions
§6 API TestingREST API specs with Groovy JsonSlurper
§7 CI/CD IntegrationGitHub Actions with headless Chrome, Gradle caching
§8 Debugging Table12 common problems with causes and fixes
§9 Best Practices14-item Geb testing checklist

Comments

Markdown supported