playwright-testing
Browser automation and E2E testing with Playwright — write, execute, and report test scripts
от shogo-labs★ 22 звезды на GitHub
Установить playwright-testing в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Playwright Testing
General-purpose browser automation for testing and validation. Any browser automation task — write custom Playwright code for the specific request.
Critical Workflow
Always follow this order:
- Detect dev servers FIRST — Run
detectDevServers()or check common ports (3000, 3001, 5173, 8080, 8000). Never hardcode a URL. - Write scripts to
/tmp/— All generated test scripts go to/tmp/playwright-test-{feature}-{timestamp}.js. Never pollute the user's project. - Visible browser by default — Launch with
headless: falseso the user sees the browser in real time. Only go headless if user explicitly requests it. - Parameterize URLs — Every script starts with
const TARGET_URL = 'http://localhost:XXXX';using the detected/provided URL. - Wait strategies — Use
waitForSelector,waitForURL,waitForLoadState('networkidle'). Never usewaitForTimeoutunless debugging. - Report with screenshots — Capture screenshots at assertion points. Save to
/tmp/screenshot-{name}-{viewport}-{timestamp}.png.
Common Patterns
Test a Page (Multiple Viewports)
const { chromium } = require('playwright');
const TARGET_URL = 'http://localhost:3000';
const VIEWPORTS = [
{ name: 'desktop', width: 1920, height: 1080 },
{ name: 'tablet', width: 768, height: 1024 },
{ name: 'mobile', width: 375, height: 667 },
];
(async () => {
const browser = await chromium.launch({ headless: false });
for (const vp of VIEWPORTS) {
const context = await browser.newContext({ viewport: { width: vp.width, height: vp.height } });
const page = await context.newPage();
await page.goto(TARGET_URL);
await page.waitForLoadState('networkidle');
await page.screenshot({ path: `/tmp/screenshot-homepage-${vp.name}-${Date.now()}.png`, fullPage: true });
console.log(`✓ ${vp.name} (${vp.width}x${vp.height}) — page loaded`);
await context.close();
}
await browser.close();
})();
Test Login Flow
const page = await context.newPage();
await page.goto(`${TARGET_URL}/login`);
await page.waitForSelector('input[type="email"], input[name="email"], #email');
await safeType(page, 'input[type="email"]', '[email protected]');
await safeType(page, 'input[type="password"]', 'testpassword');
await safeClick(page, 'button[type="submit"]');
await page.waitForURL('**/dashboard**', { timeout: 10000 });
await page.screenshot({ path: `/tmp/screenshot-login-success-${Date.now()}.png` });
Fill and Submit Form
await page.goto(`${TARGET_URL}/form`);
await page.waitForSelector('form');
await safeType(page, '#name', 'Test User');
await safeType(page, '#email', '[email protected]');
await page.selectOption('#role', 'admin');
await safeClick(page, 'button[type="submit"]');
await page.waitForSelector('.success-message, .toast, [role="alert"]');
await page.screenshot({ path: `/tmp/screenshot-form-submitted-${Date.now()}.png` });
Check Broken Links
const links = await page.$$eval('a[href]', els => els.map(a => a.href));
const uniqueLinks = [...new Set(links)].filter(l => l.startsWith('http'));
for (const link of uniqueLinks) {
try {
const response = await page.request.get(link);
if (response.status() >= 400) {
console.log(`✗ BROKEN: ${link} → ${response.status()}`);
} else {
console.log(`✓ OK: ${link} → ${response.status()}`);
}
} catch (e) {
console.log(`✗ ERROR: ${link} → ${e.message}`);
}
}
Take Screenshots with Error Handling
async function takeScreenshot(page, name, viewport) {
try {
await page.setViewportSize({ width: viewport.width, height: viewport.height });
await page.waitForLoadState('networkidle');
const path = `/tmp/screenshot-${name}-${viewport.name}-${Date.now()}.png`;
await page.screenshot({ path, fullPage: true });
console.log(`✓ Screenshot saved: ${path}`);
return path;
} catch (e) {
console.log(`✗ Screenshot failed for ${name}@${viewport.name}: ${e.message}`);
return null;
}
}
Helper Functions
These helpers are available in all generated scripts:
detectDevServers()— Scans common ports (3000, 3001, 5173, 8080, 8000, 4200, 8888) and returns running server URLssafeClick(page, selector)— Waits for element, scrolls into view, then clicks. Handles overlays and cookie banners.safeType(page, selector, text)— Waits for input, clears existing value, then types. Handles focus issues.takeScreenshot(page, name, viewport)— Captures screenshot with error handling, returns file path.handleCookieBanner(page)— Detects and dismisses common cookie consent banners.extractTableData(page, selector)— Extracts table data as an array of objects using header row as keys.
Execution Pattern
- Detect servers → determine
TARGET_URL - Write script to
/tmp/playwright-test-{feature}-{timestamp}.js - Execute via shell: `node /tmp/playwright-t
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
- 01
browser_navigate - 02
browser_screenshot - 03
shell_exec - 04
memory_read - 05
memory_write
FAQ
Что делает скилл playwright-testing?
Browser automation and E2E testing with Playwright — write, execute, and report test scripts
Как установить скилл playwright-testing?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл playwright-testing запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
docx
AnthropicUse this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include…
AnthropicUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple…
xlsx
AnthropicUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing…
pptx
AnthropicUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or…