Playwright Test Builder
Skill9 starsChanged 8 months agoMITView on GitHub
Generates robust Playwright end-to-end tests for web pages and user flows.
In this repository61 other files it gives its agents.
- Accessibility Audit HelperSkill
- Agent Context File WriterSkill
- Agent Evaluation Framework BuilderSkill
- AI Feature Spec WriterSkill
- API Documentation GeneratorSkill
- REST API Endpoint DesignerSkill
- Architecture ExplainerSkill
- Article RepurposerSkill
- Auth Flow PlannerSkill
- Blog Outline GeneratorSkill
- Breaking Change DetectorSkill
- Bug Root Cause AnalyzerSkill
- Caching Strategy AdvisorSkill
- Changelog CuratorSkill
- Code Review ChecklistSkill
- Database Schema ReviewerSkill
- Docker Compose GeneratorSkill
- Documentation Gap FinderSkill
- Edge Case DiscoverySkill
- Error Log SummarizerSkill
- FAQ GeneratorSkill
- Flaky Test AnalyzerSkill
- Form UX OptimizerSkill
- Git Commit WriterSkill
- Hallucination Risk ReviewerSkill
- Hybrid Search ArchitectSkill
- Incident Postmortem WriterSkill
- Issue to PR PlannerSkill
- Landing Page Copy ImproverSkill
- LangGraph State Machine DesignerSkill
- LLM Cost OptimizerSkill
- LLM Tracing and Observability SetupSkill
- MCP Integration AssistantSkill
- MCP Server BuilderSkill
- Migration Guide WriterSkill
- Newsletter Summary WriterSkill
- Observability ChecklistSkill
- PR Description WriterSkill
- Prompt Injection Defense AuditorSkill
- Prompt RefinerSkill
- Prompt Version Control WorkflowSkill
- RAG Chunking Strategy AdvisorSkill
- RAG Workflow PlannerSkill
- React Component ReviewerSkill
- README WriterSkill
- Refactor PlannerSkill
- Release Notes GeneratorSkill
- Responsive Layout ReviewerSkill
- SDK Quickstart WriterSkill
- SEO Content OptimizerSkill
- SEO Metadata GeneratorSkill
- Social Post Thread WriterSkill
- Sprint Summary GeneratorSkill
- SQL Query OptimizerSkill
- Stack Trace AnalyzerSkill
- Technical Blog Post WriterSkill
- Tech Debt AuditorSkill
- Troubleshooting Guide BuilderSkill
- Unit Test ImproverSkill
- Unit Test WriterSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
15 rules. About 0 are common, 7 are distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 19
Use this when you want reliable E2E coverage for critical user journeys — login, checkout, form submission, navigation flows — without …
- Very specific: line 35
Add the "Prompt / Instructions" section below to your .cursorrules file.
- Distinctive: line 43
When asked to write Playwright tests, follow these steps:
- Distinctive: line 45
Understand the flow: Ask for (or infer from context):
- Distinctive: line 58
Never use XPath unless absolutely necessary
- Distinctive: line 60
Add assertions at every meaningful step: After each action, assert:
- Distinctive: line 62
Not just "click and hope" — every interaction must have a follow-up assertion
- Very specific: line 63
Use expect(locator).toBeVisible(), toHaveText(), toHaveURL(), toBeEnabled(), etc.
- Very specific: line 66
Use test.describe to group related tests
- Very specific: line 67
Use test.beforeEach for shared setup (navigation, login)
- Very specific: line 68
Use test.afterEach or test.afterAll for cleanup if needed
- Distinctive: line 70
Keep each test focused on one behavior
- Very specific: line 72
Handle async correctly: Every page.click, page.fill, page.goto, and expect must be awaited.
- Very specific: line 77
Avoid hard-coded page.waitForTimeout() sleeps — use condition-based waits
- Very specific: line 79
Include a Page Object Model class: if the flow spans multiple pages or the test is complex.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Playwright Test Builder
What this skill does
This skill directs the agent to write well-structured Playwright end-to-end tests for a given user flow or page. It produces tests with proper locator strategies (preferring accessible selectors over brittle CSS), meaningful assertions at every step, correct async/await handling, and solid setup/teardown. The output is ready to drop into a tests/ folder and run immediately.
Use this when you want reliable E2E coverage for critical user journeys — login, checkout, form submission, navigation flows — without writing boilerplate from scratch.
How to use
Claude Code / Cline
Copy this file to .agents/skills/playwright-test-builder/SKILL.md in your project root.
Then describe the flow you want tested and ask:
- "Use the Playwright Test Builder skill to write E2E tests for the login flow."
- "Write Playwright tests for the checkout process using the Playwright Test Builder skill."
Provide the page URL (or a description of the UI), the steps in the flow, and any known selectors or data-testid values if you have them.
Cursor
Add the "Prompt / Instructions" section below to your .cursorrules file. Then describe the flow to test in the chat.
Codex
Paste the relevant HTML or React component code alongside the flow description and the instructions below. Seeing the actual markup helps Codex pick the most stable locators.
The Prompt / Instructions for the Agent
When asked to write Playwright tests, follow these steps:
- Understand the flow. Ask for (or infer from context):
- The URL or page being tested
- The steps a user takes (click X, fill Y, expect Z)
- Any test data needed (usernames, passwords, form values)
- Whether authentication is required before the test
- Choose locators in this priority order (most stable first):
getByRole()with accessible name — best for buttons, links, inputs, headingsgetByLabel()— for form fields with associated labelsgetByText()— for elements identified by their visible textgetByPlaceholder()— for inputs with placeholder textgetByTestId()— whendata-testidattributes are present- CSS selectors — only as a last resort; avoid if any stable alternative exists
- Never use XPath unless absolutely necessary
- Add assertions at every meaningful step. After each action, assert:
- A visible UI change (new element appears, text changes, URL changes)
- Not just "click and hope" — every interaction must have a follow-up assertion
- Use
expect(locator).toBeVisible(),toHaveText(),toHaveURL(),toBeEnabled(), etc.
- Structure the test file properly:
- Use
test.describeto group related tests - Use
test.beforeEachfor shared setup (navigation, login) - Use
test.afterEachortest.afterAllfor cleanup if needed - Give each
test()a descriptive name starting with a verb: "shows...", "allows...", "prevents..." - Keep each test focused on one behavior
- Use
- Handle async correctly. Every
page.click,page.fill,page.goto, andexpectmust be awaited. Never usesetTimeoutfor waiting — usepage.waitForSelector,page.waitForURL, or rely on Playwright's auto-waiting. - Add resilience where appropriate:
- For flaky elements (animations, lazy-loaded content), use
expect(locator).toBeVisible({ timeout: 5000 }) - For network-dependent tests, consider
page.waitForResponse()or mock the network withpage.route() - Avoid hard-coded
page.waitForTimeout()sleeps — use condition-based waits
- For flaky elements (animations, lazy-loaded content), use
- Include a Page Object Model class if the flow spans multiple pages or the test is complex. Keep it in a separate
pages/subfolder. - Output the complete, runnable test file with all imports. Include a comment block at the top describing what the test suite covers.
Example
Input to Agent:
"Use the Playwright Test Builder skill to write tests for our sign-up flow. The user goes to
/register, fills in their name, email, and password, clicks 'Create Account', and should land on/dashboardwith a welcome message."
Output from Agent:
import { test, expect } from '@playwright/test'; /** * Tests for the user registration flow. * Covers: form validation, successful account creation, post-signup redirect. */ test.describe('Registration flow', () => { test.beforeEach(async ({ page }) => { await page.goto('/register'); await expect(page).toHaveURL('/register'); }); test('shows the registration form', async ({ page }) => { await expect(page.getByRole('heading', { name: 'Create your account' })).toBeVisible(); await expect(page.getByLabel('Full name')).toBeVisible(); await expect(page.getByLabel('Email')).toBeVisible(); await expect(page.getByLabel('Password')).toBeVisible(); await expect(page.getByRole('button', { name: 'Create Account' })).toBeEnabled(); }); test('allows a new user to register and redirects to dashboard', async ({ page }) => { await page.getByLabel('Full name').fill('Jane Smith'); await page.getByLabel('Email').fill('jane@example.com'); await page.getByLabel('Password').fill('SecurePass123!'); await page.getByRole('button', { name: 'Create Account' }).click(); await expect(page).toHaveURL('/dashboard'); await expect(page.getByText('Welcome, Jane')).toBeVisible(); }); test('shows a validation error when email is already taken', async ({ page }) => { await page.getByLabel('Full name').fill('Existing User'); await page.getByLabel('Email').fill('existing@example.com'); await page.getByLabel('Password').fill('SecurePass123!'); await page.getByRole('button', { name: 'Create Account' }).click(); await expect(page.getByRole('alert')).toContainText('already in use'); await expect(page).toHaveURL('/register'); }); test('prevents submission when required fields are empty', async ({ page }) => { await page.getByRole('button', { name: 'Create Account' }).click(); // Form should not navigate away await expect(page).toHaveURL('/register'); await expect(page.getByLabel('Email')).toBeFocused(); }); });
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

