Can I generate codegen-style Playwright test code from a prompt-driven playwright-mcp flow?
In microsoft/playwright-mcp, a user wants the LLM-driven browser flows run through MCP to also be recorded by codegen, so the resulting Playwright tests can run in CI without the LLM or MCP server. The feature request was closed as completed, and the maintainer pointed to an existing tool instead. Is there a supported way to get reusable, selector-rich test code from a prompt-driven flow?
Originally asked on GitHub: https://github.com/microsoft/playwright-mcp/issues/123
5 answers
Status: the request is closed as completed, and the thread does not show codegen-style capture being added to playwright-mcp. The maintainer instead pointed to an existing built-in tool.
The maintainer suggested
browser_generate_playwright_testas a possible fit. A commenter replied that this tool is not what they needed because codegen also records selectors, and the built-in tool does not. That commenter did not report actually running it, so there is no confirmed success or failure in the thread.As an alternative, a commenter linked to executeautomation/mcp-playwright, saying it supports recording a flow via editor/MCP and producing test code that runs in CI. Another commenter noted that this server works on raw HTML rather than accessibility snapshots, which makes LLM calls much larger. Nobody in the thread reported using that server end to end, so treat it as unverified.
The motivation from the reporters: running tests directly through the LLM and MCP is slower, more expensive, and less deterministic than running plain Playwright code. Generating code from a flow would let a team debug a single scenario, verify a fix, and then add the test to the suite so a reported bug does not regress.
If you need selector-rich output like codegen, check the current playwright-mcp documentation for what
browser_generate_playwright_testactually captures before building a workflow around it (general advice).Did this work for you?What @pavelfeldman tried on GitHub (Outcome unclear)
A maintainer suggested using the built-in
browser_generate_playwright_testtool to generate a Playwright test from the browser session.Source: https://github.com/microsoft/playwright-mcp/issues/123#issuecomment-2852596290 (opens external site)
Did this work for you?What @usamaJ17 tried on GitHub (Outcome unclear)
A commenter said the suggested tool is not what was required because codegen also provides selectors; they did not report running it.
Source: https://github.com/microsoft/playwright-mcp/issues/123#issuecomment-2919066155 (opens external site)
Did this work for you?What @aarjithn tried on GitHub (Outcome unclear)
A commenter pointed to executeautomation/mcp-playwright as an alternative that records flows and produces CI-runnable test code. It was not reported as tested in the thread.
Source: https://github.com/microsoft/playwright-mcp/issues/123#issuecomment-2780686542 (opens external site)
Did this work for you?What @pavelfeldman tried on GitHub (Outcome unclear)
A maintainer asked whether driving tests through MCP is more efficient than recording them with codegen; this framed the discussion but did not describe a fix.
Source: https://github.com/microsoft/playwright-mcp/issues/123#issuecomment-2774306590 (opens external site)
Did this work for you?
Related questions
- Playwright MCP browser_take_screenshot shows no saved file or unreadable image in Cursor or VS Code
- Windows: playwright-mcp via Claude Desktop fails: Chromium distribution 'chrome' is not found
- playwright-mcp fails to start in Cursor after 0.0.19/0.0.20 (Client closed / Connection closed)
- Does Playwright MCP have a quiet mode to reduce page snapshot tokens?
- How to fix 'Browser window not found' when using playwright-mcp in headless mode?