playwright-expert
O que ela faz
Ele orienta o agente de IA a escrever e manter testes de navegador com Playwright. É para testers e desenvolvedores que querem verificar se as aplicações web funcionam do ponto de vista do usuário.
Quando usar
- ✓Quando você precisa de testes ponta a ponta para um fluxo de usuário em um app web.
- ✓Quando seus testes de navegador são instáveis e precisam de depuração.
- ✓Quando você quer testes com Playwright adicionados a um pipeline de CI.
Link da skill
https://github.com/Jeffallan/claude-skills/blob/main/skills/playwright-expert/SKILL.mdCopie e cole na sua IA (Claude, ChatGPT ou Cursor) pedindo para seguir as instruções.
Como usar
O jeito mais fácil: copie a mensagem e cole na sua IA. Ela lê a skill e segue as instruções.
Mensagem pronta para colar
Para Claude Code, Codex ou Cursor: rode na pasta do projeto e a skill fica instalada.
Baixe o SKILL.md e coloque na pasta de skills do seu agente.
Exemplo do que pedir para a IA
“Escreva testes com Playwright para o fluxo de checkout, usando page objects para que os testes sejam fáceis de manter.”
5 skills novas por semana. 1 minuto de leitura.
Como funciona
O agente configura o Playwright e escreve os testes usando seletores baseados em papéis e espera automática. Quando um teste falha, verifica o trace, corrige a causa e roda o teste de novo.
Conteúdo técnico (SKILL.md original)
Texto original do autor, em inglês, direto do GitHub.
Playwright Expert
E2E testing specialist with deep expertise in Playwright for robust, maintainable browser automation.
Core Workflow
- Analyze requirements - Identify user flows to test
- Setup - Configure Playwright with proper settings
- Write tests - Use POM pattern, proper selectors, auto-waiting
- Debug - Run test → check trace → identify issue → fix → verify fix
- Integrate - Add to CI/CD pipeline
Reference Guide
Load detailed guidance based on context:
| Topic | Reference | Load When |
|---|---|---|
| Selectors | references/selectors-locators.md |
Writing selectors, locator priority |
| Page Objects | references/page-object-model.md |
POM patterns, fixtures |
| API Mocking | references/api-mocking.md |
Route interception, mocking |
| Configuration | references/configuration.md |
playwright.config.ts setup |
| Debugging | references/debugging-flaky.md |
Flaky tests, trace viewer |
Constraints
MUST DO
- Use role-based selectors when possible
- Leverage auto-waiting (don't add arbitrary timeouts)
- Keep tests independent (no shared state)
- Use Page Object Model for maintainability
- Enable traces/screenshots for debugging
- Run tests in parallel
MUST NOT DO
- Use
waitForTimeout()(use proper waits) - Rely on CSS class selectors (brittle)
- Share state between tests
- Ignore flaky tests
- Use
first(),nth()without good reason
Code Examples
Selector: Role-based (correct) vs CSS class (brittle)
// ✅ Role-based selector — resilient to styling changes
await page.getByRole('button', { name: 'Submit' }).click();
await page.getByLabel('Email address').fill('user@example.com');
// ❌ CSS class selector — breaks on refactor
await page.locator('.btn-primary.submit-btn').click();
await page.locator('.email-input').fill('user@example.com');
Page Object Model + Test File
// pages/LoginPage.ts
import { type Page, type Locator } from '@playwright/test';
export class LoginPage {
readonly page: Page;
readonly emailInput: Locator;
readonly passwordInput: Locator;
readonly submitButton: Locator;
readonly errorMessage: Locator;
constructor(page: Page) {
this.page = page;
this.emailInput = page.getByLabel('Email address');
this.passwordInput = page.getByLabel('Password');
this.submitButton = page.getByRole('button', { name: 'Sign in' });
this.errorMessage = page.getByRole('alert');
}
async goto() {
await this.page.goto('/login');
}
async login(email: string, password: string) {
await this.emailInput.fill(email);
await this.passwordInput.fill(password);
await this.submitButton.click();
}
}
// tests/login.spec.ts
import { test, expect } from '@playwright/test';
import { LoginPage } from '../pages/LoginPage';
test.describe('Login', () => {
let loginPage: LoginPage;
test.beforeEach(async ({ page }) => {
loginPage = new LoginPage(page);
await loginPage.goto();
});
test('successful login redirects to dashboard', async ({ page }) => {
await loginPage.login('user@example.com', '<test-password>');
await expect(page).toHaveURL('/dashboard');
});
test('invalid credentials shows error', async () => {
await loginPage.login('user@example.com', '<wrong-password>');
await expect(loginPage.errorMessage).toBeVisible();
await expect(loginPage.errorMessage).toContainText('Invalid credentials');
});
});
Debugging Workflow for Flaky Tests
// 1. Run failing test with trace enabled
// playwright.config.ts
use: {
trace: 'on-first-retry',
screenshot: 'only-on-failure',
}
// 2. Re-run with retries to capture trace
// npx playwright test --retries=2
// 3. Open trace viewer to inspect timeline
// npx playwright show-trace test-results/.../trace.zip
// 4. Common fix — replace arbitrary timeout with proper wait
// ❌ Flaky
await page.waitForTimeout(2000);
await page.getByRole('button', { name: 'Save' }).click();
// ✅ Reliable — waits for element state
await page.getByRole('button', { name: 'Save' }).waitFor({ state: 'visible' });
await page.getByRole('button', { name: 'Save' }).click();
// 5. Verify fix — run test 10x to confirm stability
// npx playwright test --repeat-each=10
Output Templates
When implementing Playwright tests, provide:
- Page Object classes
- Test files with proper assertions
- Fixture setup if needed
- Configuration recommendations
Kn
Perguntas frequentes
Ele usa esperas fixas?
Não. A skill diz para não usar timeouts fixos e confiar na espera automática do Playwright.
Ele consegue simular chamadas de API?
Sim. Cobre interceptação de rotas e simulação de API.
Ele testa mudanças visuais?
Sim. Cobre testes de regressão visual.
Detalhes
Descrição original do autor
Use when writing E2E tests with Playwright, setting up test infrastructure, or debugging flaky browser tests. Invoke to write test scripts, create page objects, configure test fixtures, set up reporters, add CI integration, implement API mocking, or perform visual regression testing. Trigger terms: Playwright, E2E test, end-to-end, browser testing, automation, UI testing, visual testing, Page Object Model, test flakiness.
repo: Jeffallan/claude-skills
Popularidade
- Estrelas no GitHub
- 12 mil
- Posição no ranking
- #11444
- Licença
- MIT
- Atualizada em
- 30/10/2026
Comentários
- …
Mais skills deste repositório
angular-architect
12 milAjuda seu agente a criar apps Angular 17 ou mais novos, com componentes standalone, rotas com carregamento sob demanda, estado NgRx, padrões RxJS e ajuste de desempenho.
api-designer
12 milAjuda seu agente a projetar APIs REST ou GraphQL e a escrever especificações OpenAPI 3.1, com regras para recursos, paginação, formatos de erro e versionamento.
architecture-designer
12 milAjuda seu agente a projetar a arquitetura de sistemas, comparar padrões e tecnologias e escrever Architecture Decision Records que explicam cada escolha.
atlassian-mcp
12 milAjuda seu agente a buscar e atualizar issues do Jira e páginas do Confluence pelo MCP, incluindo consultas JQL e CQL, sprints e sincronização de documentação.
Skills parecidas
test-driven-development
311 milEnsina seu agente a escrever primeiro um teste que falha, ver a falha e depois escrever o menor código que passa, antes de criar qualquer funcionalidade ou correção.
verification-before-completion
311 milEnsina seu agente a rodar verificações reais e ler a saída antes de afirmar que uma tarefa, correção ou build está concluído ou passando.
migrate-to-shoehorn
310 milSubstitui conversões de tipo arriscadas nos seus arquivos de teste pela biblioteca shoehorn, para que os testes usem dados parciais e ainda passem na checagem de tipos.