> ## Documentation Index
> Fetch the complete documentation index at: https://docs.therefrain.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# E2E Regression Testing

> Replace brittle Playwright selectors with self-healing runbooks for CI/CD integration.

## Overview

End-to-end tests are essential but expensive to maintain. Playwright and Selenium tests break every time the UI changes — a renamed CSS class, a restructured form, a redesigned navigation. Teams spend more time fixing selectors than catching bugs.

Refrain replaces brittle test scripts with self-healing runbooks. Describe what each test should verify, generate a runbook, and integrate it into your CI/CD pipeline. When the UI changes, the runbook adapts — no test code to maintain.

## Example runbook

```yaml theme={null}
name: login-flow-test
url: https://staging.example.com/login
variables:
  - name: test_email
    source: secrets
  - name: test_password
    source: secrets
steps:
  - action: input
    selector: "#email"
    value: "{{ test_email }}"
  - action: input
    selector: "#password"
    value: "{{ test_password }}"
  - action: click
    selector: "#login-button"
  - action: wait
    selector: ".dashboard"
  - action: extract
    selector: ".welcome-message"
    capture: welcome_text
  - action: extract
    selector: ".user-menu"
    capture: user_menu
```

## Generate and execute

<Steps>
  <Step title="Generate the test runbook">
    ```bash theme={null}
    npx @refrainai/cli generate -- \
      --url https://staging.example.com/login \
      --goal "Log in with test credentials and verify the dashboard loads with a welcome message" \
      --context ./context.md \
      --output ./tests/login-flow.yaml
    ```
  </Step>

  <Step title="Run locally">
    ```bash theme={null}
    npx @refrainai/cli execute -- \
      --runbook ./tests/login-flow.yaml \
      --secrets ./secrets.json \
      --report ./test-reports/login-flow.md
    ```
  </Step>

  <Step title="Integrate into CI/CD">
    Add the execute command to your CI pipeline:

    ```yaml theme={null}
    # .github/workflows/e2e.yml
    - name: Run E2E tests
      run: |
        npx @refrainai/cli execute -- \
          --runbook ./tests/login-flow.yaml \
          --secrets ./secrets.json \
          --report ./test-reports/login-flow.md
    ```
  </Step>
</Steps>

## Why this works well

* **No test code** — Runbooks replace Playwright/Selenium scripts. No selectors to maintain.
* **Self-healing** — UI changes are handled automatically. Tests don't break on redesigns.
* **CI/CD native** — Run via CLI in any pipeline — GitHub Actions, GitLab CI, Jenkins, etc.
* **Visual debugging** — Use `--headless false` and `--screenshots` to debug failures visually.

## What's next

<CardGroup cols={2}>
  <Card title="Self-heal mode" icon="wrench" href="/guides/self-heal">
    Auto-fix test runbooks when the app changes.
  </Card>

  <Card title="CLI reference" icon="terminal" href="/cli/execute">
    All execute command options for CI integration.
  </Card>
</CardGroup>
