Web 自动化测试与浏览器控制
来源: 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"]', 'user@example.com');
// 选择下拉
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
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer