> ## 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 リグレッションテスト

> 壊れやすいテストスクリプトを自己修復する手順書に置き換え。メンテナンス不要の E2E テスト。

## 概要

E2E テストは重要ですが、メンテナンスコストが高くつきます。Playwright や Selenium のテストは UI が変わるたびに壊れます。CSS クラスの変更、フォーム構造の変更、ナビゲーションの刷新 — チームはバグを見つけるよりもセレクタの修正に時間を費やしています。

Refrain は壊れやすいテストスクリプトを自己修復する手順書に置き換えます。各テストで検証したい内容を記述し、手順書を生成して CI/CD パイプラインに組み込むだけ。UI が変わっても手順書が自動的に適応し、テストコードのメンテナンスは不要です。

## 手順書の例

```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
```

## 生成と実行

<Steps>
  <Step title="テスト用手順書を生成する">
    ```bash theme={null}
    npx @refrainai/cli generate -- \
      --url https://staging.example.com/login \
      --goal "テスト用認証情報でログインし、ダッシュボードにウェルカムメッセージが表示されることを確認する" \
      --context ./context.md \
      --output ./tests/login-flow.yaml
    ```
  </Step>

  <Step title="ローカルで実行する">
    ```bash theme={null}
    npx @refrainai/cli execute -- \
      --runbook ./tests/login-flow.yaml \
      --secrets ./secrets.json \
      --report ./test-reports/login-flow.md
    ```
  </Step>

  <Step title="CI/CD に組み込む">
    CI パイプラインに実行コマンドを追加します：

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

## Refrain が向いている理由

* **テストコード不要** — 手順書が Playwright / Selenium スクリプトを置き換え。セレクタのメンテナンス不要。
* **自己修復** — UI 変更にも自動対応。リニューアルでテストが壊れない。
* **CI/CD ネイティブ** — CLI で任意のパイプラインから実行可能。GitHub Actions、GitLab CI、Jenkins 等に対応。
* **ビジュアルデバッグ** — `--headless false` と `--screenshots` で失敗箇所を視覚的に確認。

## 次のステップ

<CardGroup cols={2}>
  <Card title="自動修正モード" icon="wrench" href="/ja/guides/self-heal">
    アプリ変更時にテスト手順書を自動修正する。
  </Card>

  <Card title="CLI リファレンス" icon="terminal" href="/ja/cli/execute">
    CI 統合に必要な execute コマンドのオプション。
  </Card>
</CardGroup>
