Skills/00_Core_Utilities/development-tools/playwright/SKILL.md
Web 自动化测试与浏览器控制
npx skillsauth add liyecom/liye-ai playwrightInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
来源: ComposioHQ/awesome-claude-skills 适配: LiYe OS 三层架构
基于 Playwright 的 Web 自动化测试,验证前端功能、调试 UI 行为、截图。
当需要 Web 自动化时:
import { chromium } from 'playwright';
const browser = await chromium.launch();
const page = await browser.newPage();
await page.goto('https://example.com');
await page.click('button#submit');
await browser.close();
// 点击
await page.click('button.primary');
// 填写表单
await page.fill('input[name="email"]', '[email protected]');
// 选择下拉
await page.selectOption('select#country', 'US');
// 等待元素
await page.waitForSelector('.loading', { state: 'hidden' });
// 截图
await page.screenshot({ path: 'screenshot.png' });
// 全页面截图
await page.screenshot({ path: 'full.png', fullPage: true });
// 录制视频
const context = await browser.newContext({
recordVideo: { dir: 'videos/' }
});
import { expect } from '@playwright/test';
// 文本断言
await expect(page.locator('h1')).toHaveText('Welcome');
// 可见性断言
await expect(page.locator('.modal')).toBeVisible();
// URL 断言
await expect(page).toHaveURL(/.*dashboard/);
用户: 帮我自动化测试网站的登录流程
Claude: [使用 playwright 编写登录测试脚本,验证成功和失败场景]
用户: 帮我截取这个页面在不同设备上的样子
Claude: [使用 playwright 模拟手机、平板、桌面,分别截图]
用户: 帮我自动填写这个复杂的表单
Claude: [使用 playwright 定位元素并填写表单数据]
此技能被以下业务域引用:
Created: 2025-12-28 | Adapted for LiYe OS
tools
SFC patched skill. Use when "ui-ux" is relevant.
data-ai
持续改进方法论 - 基于精益思想
tools
软件架构设计模式与最佳实践
tools
Claude Skills 创建指南与最佳实践