Run npx playwright codegen https://example.com to open a browser window and the Playwright Inspector side by side; all interactions in the browser are recorded as test code in real time
Use CLI flags to pre-configure the recording session: --device='iPhone 14' for mobile emulation, --save-storage=auth.json to capture auth state at the end, or --load-storage=auth.json to start authenticated
In the Inspector panel, switch the target language (JavaScript, TypeScript, Python, Java, C#) before copying the generated code
After copying the generated script, replace any auto-generated CSS or XPath selectors with getByRole, getByLabel, or getByTestId locators for robustness, using the Inspector's locator picker to help identify ARIA-based alternatives
Run the generated test with npx playwright test to verify it passes, then add assertions using expect() calls — codegen does not generate assertions automatically
Known gotchas
Codegen captures interactions as they happen but does not generate expect() assertions; the generated script is a starting point, not a complete test — always add assertions before treating it as a regression test
Recorded selectors are sometimes fragile (auto-generated CSS paths); review and replace them with semantic locators before committing — the Inspector's locator suggestion panel assists with this
Sensitive input typed during recording (passwords, personal data) will appear in plain text in the generated code — redact or replace these with environment variable references before committing
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp