Playwright Agents
БесплатноБез исполняемых скриптовНе проверенTesting patterns for Playwright AI-powered agents including the Planner, Generator, and Healer architecture for self-healing test automation, intelligent test…
от PramodDutta★ 253 звезды на GitHubОб этом скилле
Playwright Agents Skill
You are an expert in Playwright AI-powered agent architecture. When the user asks you to implement Planner, Generator, or Healer agents for test automation, build self-healing test infrastructure, or create adaptive testing pipelines with Playwright, follow these detailed instructions.
Core Principles
- Three-agent architecture -- Structure test automation around three specialized agents: Planner (decides what to test), Generator (creates test code), and Healer (fixes broken tests). Each agent has a distinct responsibility and interface.
- Selector resilience hierarchy -- Use a prioritized selector strategy: test IDs > ARIA roles > text content > CSS selectors. Self-healing agents should try alternatives in this order when primary selectors fail.
- Snapshot-driven healing -- When tests fail, capture accessibility tree snapshots, DOM state, and screenshots. Feed these to the Healer agent to produce corrected selectors and actions.
- Incremental generation -- Generate tests incrementally from user stories or natural language descriptions. Validate each generated step against the running application before generating the next.
- Execution feedback loops -- Every test run produces structured feedback that informs the next generation or healing cycle. Use JSON-formatted execution reports, not raw console output.
- Human-in-the-loop checkpoints -- Allow developers to review and approve generated or healed tests before they become part of the official suite. Never auto-commit generated tests without review.
- Cost-aware agent orchestration -- Track LLM token usage for each agent invocation. Set budgets per test generation and healing cycle to prevent runaway API costs.
Project Structure
tests/
agents/
planner/
planner-agent.ts
story-parser.ts
test-plan-schema.ts
generator/
generator-agent.ts
code-templates.ts
step-validator.ts
healer/
healer-agent.ts
selector-resolver.ts
snapshot-analyzer.ts
orchestrator/
agent-orchestrator.ts
feedback-loop.ts
cost-tracker.ts
generated/
specs/
.gitkeep
approved/
.gitkeep
fixtures/
page-objects/
login.page.ts
dashboard.page.ts
snapshots/
.gitkeep
config/
agent-config.ts
selector-strategy.ts
e2e/
smoke.spec.ts
critical-paths.spec.ts
playwright.config.ts
Planner Agent
// tests/agents/planner/planner-agent.ts
import Anthropic from '@anthropic-ai/sdk';
export interface TestPlan {
id: string;
title: string;
userStory: string;
priority: 'critical' | 'high' | 'medium' | 'low';
steps: TestStep[];
preconditions: string[];
expectedOutcome: string;
estimatedComplexity: number;
}
export interface TestStep {
order: number;
action: 'navigate' | 'click' | 'fill' | 'select' | 'assert' | 'wait' | 'hover' | 'upload';
target: string;
value?: string;
assertion?: {
type: 'visible' | 'text' | 'url' | 'count' | 'attribute';
expected: string;
};
description: string;
}
export class PlannerAgent {
private client: Anthropic;
private model: string;
constructor(model = 'claude-sonnet-4-20250514') {
this.client = new Anthropic();
this.model = model;
}
async createTestPlan(userStory: string, appContext?: string): Promise<TestPlan> {
const systemPrompt = `You are a test planning agent for Playwright browser automation.
Given a user story, create a detailed test plan with concrete steps.
Each step must map to a Playwright action (navigate, click, fill, select, assert, wait).
Use descriptive selectors based on ARIA roles and test IDs.
Return the plan as a JSON object matching the TestPlan schema.`;
const prompt = `User Story: ${userStory}
${appContext ? `App Context: ${appContext}` : ''}
Create a test plan. Return ONLY valid JSON matching this schema:
{
"id": "string",
"title": "string",
"userStory": "string",
"priority": "critical|high|medium|low",
"steps": [{"order": number, "action": "string", "target": "string", "value?": "string", "description": "string"}],
"preconditions": ["string"],
"expectedOutcome": "string",
"estimatedComplexity": number
}`;
const response = await this.client.messages.create({
model: this.model,
max_tokens: 2048,
temperature: 0,
system: systemPrompt,
messages: [{ role: 'user', content: prompt }],
});
const text = response.content[0].type === 'text' ? response.content[0].text : '';
const jsonMatch = text.match(/\{[\s\S]*\}/);
if (!jsonMatch) throw new Error('Planner failed to generate valid JSON');
return JSON.parse(jsonMatch[0]) as TestPlan;
}
async prioritizeTests(plans: TestPlan[], riskAreas: string[]): Promise<TestPlan[]> {
const prompt = `Given these test plans and known risk areas, reorder by priority.
Risk areas: ${riskAreas.join(', ')}
Plans: ${JSON.stringify(plans.map((p)
Установить Playwright Agents в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл Playwright Agents?
Testing patterns for Playwright AI-powered agents including the Planner, Generator, and Healer architecture for self-healing test automation, intelligent test generation, and adaptive test execution strategies.
Как установить скилл Playwright Agents?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл Playwright Agents запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic