codegen
Record browser interactions in a live Chromium window to generate pytest test code. Build baseline tests interactively before refining with automated tools.
Instructions
Launch interactive test recording for the active runner. Useful as a baseline-builder before refining with generate_test.
Behavior:
pytest-playwright: spawns
playwright codegen -o <output> <url>— a real Chromium window opens, you click / type / navigate, Playwright transcribes every action into runnable pytest code, output is saved to PROJECT_ROOT/ on browser closeMaestro: returns a human-readable hint string pointing at
maestro studio(no shell-able codegen exists for it)jest / cypress / go runners: same Maestro-style fallback hint Returns: a string with the saved path or the manual-record hint.
When to use:
Building a baseline happy-path test interactively (you click, it transcribes)
Site has complex auth / JS state you'd rather not script by hand
Quick prototype before refining with generate_test
User says 「record / 錄製 / use codegen / 紀錄操作」
When NOT to use:
Headless CI / container environments → can't open Chromium
Need structured, AI-driven test generation from analysis → use generate_test or auto_generate_tests instead
One-shot per-module test coverage → use auto_generate_tests
Mobile UI flows → returns a hint anyway, consider analyze_screen + generate_test instead
Edge cases:
outputcontains..or is absolute → blocked by security guardrailChromium not installed → playwright codegen fails; user sees the
playwright installhint in stderr
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | 受測 URL。Playwright codegen 會開瀏覽器 navigate 到此網址、從這頁開始錄製你的互動。 | |
| output | No | 選填,輸出檔名(相對於 PROJECT_ROOT,不可絕對路徑、不可含 `..`)。預設 `recorded_test.py`。 | recorded_test.py |