mcpField
B
browser-automation

browser-automation

github.com/civitaiテスト・品質7.3k82 回インストール今日更新
リポジトリ

browser-automation について

browser-automation は、ブラウザー操作やテストを行うスキルです。ページ操作の再実行や複数ユーザーの検証が必要なチーム向けに、セッション、認証プロファイル、再利用可能な Playwright フローを HTTP 経由で管理します。

主な機能

  1. 01ブラウザーセッションの作成と管理
  2. 02認証プロファイルの保存と利用
  3. 03再利用可能なフローの記録と実行
  4. 04Playwright ページコードの実行
  5. 05ページ状態とスクリーンショットの確認

活用シーン

  1. 01異なる権限のユーザーでページをテスト
  2. 02保存済みブラウザーフローを再実行
  3. 03ローカルモックアップと実ページを比較

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/civitai/civitai --skill browser-automation

インストール後、Claude Code で/browser-automationを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

package-lock.json
package.json
server.mjs

詳細

ブラウザー自動化スキル

ページを対話的に探索し、再利用可能なフローを構築して、複数ユーザーのシナリオをテストします。

クイックスタート

# Start server
node .claude/skills/browser-automation/server.mjs &

# Check available profiles
curl http://localhost:9222/profiles

# Create a session
curl -X POST http://localhost:9222/sessions \
  -d '{"name": "test", "url": "http://localhost:3000", "profile": "member"}'

# Inspect the page
curl http://localhost:9222/inspect

# Execute code
curl -X POST http://localhost:9222/chunk \
  -d '{"label": "Click button", "code": "await page.click(\"button.submit\");"}'

# Shutdown
curl -X POST http://localhost:9222/exit

エンドポイント

エンドポイントメソッド説明
/profilesGET説明付きの認証プロファイルを一覧表示します
/sessionsGETアクティブなセッションを一覧表示します
/sessionsPOSTセッションを作成します { name, url, profile?, headless? }
/sessions/:nameDELETEセッションを終了します
/flowsGET保存済みフローを一覧表示します
/flows/:name/runPOSTフローを実行します { profile?, startUrl?, headless? }
/statusGETセッションの状態
/inspectGETページの状態とスクリーンショット。ページ全体のスクリーンショットを撮るには ?fullPage=true を追加します
/chunkPOSTコードを実行します { label, code }
/navigatePOST移動します { url, fullPage? }。ページ全体のスクリーンショットを撮るには fullPage: true を設定します
/save-authPOST認証情報を保存します { profile, description }
/reviewGET記録されたチャンクを確認します
/exitPOSTサーバーをシャットダウンします

複数のセッションがアクティブな場合は、?session=name を使用します。

複数ユーザーのテスト

# Create two sessions with different profiles
curl -X POST http://localhost:9222/sessions \
  -d '{"name": "creator", "url": "http://localhost:3000", "profile": "creator"}'
curl -X POST http://localhost:9222/sessions \
  -d '{"name": "viewer", "url": "http://localhost:3000", "profile": "member"}'

# Creator does something
curl -X POST "http://localhost:9222/chunk?session=creator" \
  -d '{"label": "Publish", "code": "await page.click(\"button.publish\");"}'

# Viewer sees it
curl -X POST "http://localhost:9222/navigate?session=viewer" \
  -d '{"url": "http://localhost:3000/models"}'

プロファイル

# List profiles
curl http://localhost:9222/profiles

# Create new profile (description required)
curl -X POST http://localhost:9222/save-auth \
  -d '{"profile": "moderator", "description": "User with mod permissions"}'

# Refresh existing profile
curl -X POST http://localhost:9222/save-auth \
  -d '{"profile": "moderator"}'
プロファイル説明
moderatorコンテンツレビュー用のモデレーター権限
creatorコンテンツを公開済みの利用歴の長いユーザー
member標準のログイン済みユーザー
new-userオンボーディングフロー用の新規アカウント

フロー

保存済みフローは再利用可能な Playwright スクリプトです。

# List flows
curl http://localhost:9222/flows

# Run a flow
curl -X POST http://localhost:9222/flows/my-flow/run \
  -d '{"profile": "member"}'

# Run with custom start URL
curl -X POST http://localhost:9222/flows/my-flow/run \
  -d '{"profile": "member", "startUrl": "http://localhost:3000"}'

フローは .browser/flows/*.js に保存されます。

Playwright コード

チャンクの実行時には page を使用できます。

await page.click('button.submit');
await page.fill('input[name="email"]', '[email protected]');
await page.waitForSelector('h1');
await page.goto('https://example.com');
const title = await page.textContent('h1');

モックアップとの比較

file:// URL でローカル HTML モックアップを開き、実際のページと比較します。

# 1. Open mockup and take full-page screenshot
curl -X POST http://localhost:9222/sessions \
  -d '{"name": "compare", "url": "file:///C:/path/to/mockup.html"}'
curl "http://localhost:9222/inspect?session=compare&fullPage=true"

# 2. Navigate to live page and screenshot
curl -X POST "http://localhost:9222/navigate?session=compare" \
  -d '{"url": "http://localhost:3000/page", "fullPage": true}'

# 3. Compare screenshots in session folder

ファイルの場所

  • フロー:.browser/flows/*.js
  • プロファイルのメタデータ:.browser/profiles/profiles.meta.json
  • 認証状態:.browser/profiles/*.json(gitignore 対象)
  • スクリーンショット:.browser/sessions/{id}/screenshots/

コメント