Skip to main content
Glama

codegen

Record user interactions in a browser window to automatically generate Playwright test code. Useful for building baseline tests on complex sites.

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 close

  • Maestro: 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:

  • output contains .. or is absolute → blocked by security guardrail

  • Chromium not installed → playwright codegen fails; user sees the playwright install hint in stderr

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYes受測 URL。Playwright codegen 會開瀏覽器 navigate 到此網址、從這頁開始錄製你的互動。
outputNo選填,輸出檔名(相對於 PROJECT_ROOT,不可絕對路徑、不可含 `..`)。預設 `recorded_test.py`。recorded_test.py
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations exist, so the description carries full burden. It details opening a real Chromium window, transcribing actions, saving output, security guards on output path, Chromium installation failures, and fallback hints for non-Playwright runners.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear headings and bullet points. Every section adds value, though it is somewhat lengthy. The purpose is front-loaded, and the structure aids scanning.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (multiple runners, security concerns, no output schema), the description covers return value, all relevant behaviors, and edge cases comprehensively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, and the description adds meaningful context beyond parameter names: url is the starting page, output is a relative path with security constraints (no `..`, no absolute).

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a clear verb+resource: 'Launch interactive test recording for the active runner.' It distinguishes from sibling tools like generate_test by framing this as a baseline-builder before refinement.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicit 'When to use' and 'When NOT to use' sections list concrete scenarios and alternative tool names (e.g., generate_test, auto_generate_tests). The 'When NOT to use' section covers headless environments and mobile flows.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kao273183/mk-qa-master'

If you have feedback or need assistance with the MCP directory API, please join our Discord server