NISHIO Hirokazu[Translate]
pKouchouAI2025-10-13~14

広聴AIにPlaywright Agentを使う実験

詳細メモ
まず code kouchou-aiする
少し混乱したがoriginがnishio/kouchou-ai、upstreamがdigitaldemocracy2030/kouchou-aiを指しているんだな
Syncした

% git checkout -b playwright-agent

>Playwright を導入 / 更新

% npm install -D @playwright/test@latest
うーん、npm installは禁止中なんだよな
pnpmでやる

:
% pnpm install -D @playwright/test@latest Downloading lefthook-darwin-arm64@1.13.6: 5.52 MB/5.52 MB, done Packages: +31 +++++++++++++++++++++++++++++++ Downloading next@15.5.4: 30.29 MB/30.29 MB, done Downloading @next/swc-darwin-arm64@15.5.4: 42.36 MB/42.36 MB, done Progress: resolved 75, reused 18, downloaded 14, added 31, done dependencies: + @next/third-parties 15.5.4 devDependencies: + @biomejs/biome 1.9.4 (2.2.5 is available) + @playwright/test 1.56.0 + lefthook 1.13.6 ╭ Warning ───────────────────────────────────────────────────────────────────────────────────╮ │ │ │ Ignored build scripts: @biomejs/biome, lefthook, sharp. │ │ Run "pnpm approve-builds" to pick which dependencies should be allowed to run scripts. │ │ │ ╰────────────────────────────────────────────────────────────────────────────────────────────╯ Done in 38s using pnpm v10.18.1

% npx playwright install --with-deps

% node -v
v22.19.0
十分新しい

>Agents 定義を追加(Claude Code を使う想定)

% npx playwright init-agents --loop=claude

入れてなかったので入れる


% npm run test:e2e
>Error: No tests found
そうなんだっけ

まあまず管理画面を開くか

Claude Code のエディタ上で、planner に指示

:
New MCP server found in .mcp.json: playwright-test │ │ MCP servers may execute code or access system resources. All tool calls require approval. Learn more in the MCP documentation. │ │ ❯ 1. Use this and all future MCP servers in this project

「管理画面を開くテストのプランを作って」
英語で作ってきてしまうなぁ
---
>claudeがだいぶ苦労したけどテストができるようになりました
> 苦労した理由はテスト対象のサーバが適切に立ち上がってて、適切にそれを参照するように設定されていないといけないことなんですけど、ちゃんと設定できてるかのテストを先にやらせることによってAIでも何とかなりました


一通りできた

"Engineer's way of creating knowledge" the English version of my book is now available on [Engineer's way of creating knowledge]

(C)NISHIO Hirokazu / Converted from [Scrapbox] at [Edit]