Build Playwright tests from a live app with Claude Code
Claude Code inspected a working app, generated a Playwright test, and fixed a locator conflict before a person checked the result.
- What they did
- A developer hooked Playwright MCP into Claude Code and opened the app with an existing authenticated session loaded from storage state. They gave the agent three parts to follow: background on the setup, a plain description of the scenario, and the rules it had to obey. Claude Code navigated the interface through the accessibility tree, wrote the test, executed it, and repaired the code after a failure.
- How it went
- The agent returned a test that ran successfully and used selectors gathered from the live page itself. It also handled a strict-mode locator problem on its own. It does not cope well with lengthy user paths, changing records, nested branching, or OAuth, and no runtime figures were provided.
- Tips
- Add .auth/ to .gitignore so the stored session does not get committed, since this arrangement keeps it outside Playwright’s default ignored paths. Use --repeat-each 5 when you run the test to spot flaky behavior early.
Try it yourself with Claude Code
Connect Playwright MCP to this project, then open [app URL] with the available authenticated session and study the flow for [user journey]. Create Playwright tests with locators you derive from the live interface, run them, and keep fixing issues that are safe to resolve. Stop and ask before any step that would send, submit, delete, or pay. When you finish, show the generated test code and the successful test run.
Fill in the [brackets]. Agents can make mistakes, so review anything before it is sent, paid or deleted.
Get 3 agent uses like this every morning
With the day's top AI news. Free, and one click to unsubscribe.
Related agent uses
Use OpenClaw to run coding agents on PRs
A solo developer used OpenClaw to spin up Codex and Claude Code for coding, testing, commits, PRs, and review replies, while getting Telegram updates when work finished.
Use coding agents to stress-test your docs
A CLI runs coding agents against doc-dependent tasks, spots where they fail, then rewrites the docs and repeats the eval.
Build an anonymous board for AI hopes and worries
They used Claude Code to create a site where people can post anonymously, with one model sorting entries and another finding themes.
Map callers before you rename a symbol
Let an agent trace a function’s users first, then apply a compiler-aware rename across the affected files.
Use Claude Code for a carefully checked migration
A developer used Claude Code to update a reset feature, but the review work and cleanup erased most of the speed gains.
Have Claude Code make a fast macOS markdown viewer
A developer used Claude Code to create a markdown viewer for macOS that opens files very quickly.