跳到主内容
智客 ZICQ

技能库 智客分类:Agent 工作流 playwright-skill

剧作家技能

与 Playwright 完成浏览器自动化 。 自动检测dev服务器,编写可重复使用的测试脚本,并支持截图,应答检查,UX验证,登录流量,链接检查,以及任意浏览器自动化. 当用户想要测试一个网站,自动实现浏览器交互,验证网络功能,或者进行基于浏览器的测试时使用.

5930 安装量

官方网址:skills.sh

技能介绍

先看中文介绍;官方 description 原文单独保留,不改写 SKILL.md。

做什么

与 Playwright 完成浏览器自动化 。 自动检测dev服务器,编写可重复使用的测试脚本,并支持截图、响应性检查、UX验证、登录流量、链接检查和任意浏览器自动化

何时用

还有

代理如何加载

按 Agent Skills 渐进披露:启动时只加载 name 与 description(约 100 token);任务匹配后才读入整份 SKILL.md 正文;scripts/、references/、assets/ 仅在需要时再读。 本文件正文结构:Playwright Browser Automation、Path resolution、Workflow、Setup、Minimal example、Current Playwright patterns。 其中含规范建议的小节:分步指令、输入输出示例。

文件分析

文件分析:这是一份仅含 SKILL.md 的指令型技能,代理激活后整份正文进入上下文。

官方 description(原文)

Complete browser automation with Playwright. Auto-detects dev servers, writes reusable test scripts, and supports screenshots, responsive checks, UX validation, login flows, link checks, and arbitrary browser automation. Use when the user wants to test a website, automate browser interactions, validate web functionality, or perform browser-based testing.

Playwright Browser AutomationPath resolutionWorkflowSetupMinimal exampleCurrent Playwright patternsCommon tasksResponsive checksLogin flowSave scripts and artifactsConnect to an existing Chrome sessionHelpers

兼容:Requires Node.js 20+, npm, and network access on first setup to install Playwright and Chromium. · 许可:MIT · allowed-tools:Bash(node:*) Bash(npm:*) Read Write

来源分类:skills.sh agent-skill

SKILL.md 与 Agent 调用

官方规范 ↗
name
playwright-skill
description
Complete browser automation with Playwright. Auto-detects dev servers, writes reusable test scripts, and supports screenshots, responsive checks, UX validation, login flows, link checks, and arbitrary browser automation. Use when the user wants to test a website, automate browser interactions, validate web functionality, or perform browser-based testing.
compatibility
Requires Node.js 20+, npm, and network access on first setup to install Playwright and Chromium.
allowed-tools
Bash(node:*) Bash(npm:*) Read Write实验字段,支持情况取决于客户端;字段声明本身不会授予工具权限。
许可
MIT
  1. 发现技能客户端向 Agent 提供名称与描述目录。
  2. 匹配与调用用户指定或任务匹配后,载入 SKILL.md 指令。
  3. 按需加载按步骤读取参考文档、使用脚本与素材。

具体调用语法与可用工具以目标 Agent 客户端为准。 查看调用机制说明 ↗

安装这个技能

Skills CLI ↗

先选择目标 Agent 和安装范围,保留技能包的附属文件,安装后检查客户端能否发现该技能。

交给 Agent 安装

复制安装指令给支持 Agent Skills 的代理,确认其中的目标目录与客户端匹配。

把 Agent Skill「playwright-skill」安装到我的项目:SKILL.md 原文与官方 description 见 https://zicq.com/zh/skills/skl-869c17501052c140-%E5%89%A7%E4%BD%9C%E5%AE%B6%E6%8A%80%E8%83%BD.html
请存为 .cursor/skills/playwright-skill/SKILL.md 或 .claude/skills/playwright-skill/SKILL.md,frontmatter 的 name 与 description 保持原样,不要改写。

GitHub 完整包 ↗

终端安装 · Skills CLI

需要 Node.js 与 npx。先查看仓库技能列表,确认实际名称。

npx skills add 'https://github.com/lackeyjb/playwright-skill' --list

npx skills add 'https://github.com/lackeyjb/playwright-skill' --skill 'playwright-skill'

CLI 会交互选择目标 Agent,默认安装到项目;用户级安装使用 -g。先通过查看命令核对仓库内容,再用 npx skills list 检查已安装技能。

阅读排版
--- name: playwright-skill description: Complete browser automation with Playwright. Auto-detects dev servers, writes reusable test scripts, and supports screenshots, responsive checks, UX validation, login flows, link checks, and arbitrary browser automation. Use when the user wants to test a website, automate browser interactions, validate web functionality, or perform browser-based testing. license: MIT compatibility: Requires Node.js 20+, npm, and network access on first setup to install Playwright and Chromium. metadata: author: lackeyjb version: "5.0.0" allowed-tools: Bash(node:*) Bash(npm:*) Read Write --- # Playwright Browser Automation Write and execute focused Playwright scripts for the user's request. Prefer the skill's executor and helpers, but use the full Playwright API when needed. ## Path resolution This skill can be installed in several locations, so resolve its directory first. Set `SKILL_DIR` to the directory containing this SKILL.md file, then run the commands below as written: ```bash export SKILL_DIR= export TMP_DIR="$(node -p 'require("node:os").tmpdir()')" ``` If shell state does not persist between commands, substitute the literal paths for `$SKILL_DIR` and `$TMP_DIR` in each command instead. Common installation paths: - Plugin system: `~/.claude/plugins/marketplaces/playwright-skill/skills/playwright-skill` - Manual global: `~/.claude/skills/playwright-skill` - Project-specific: `/.claude/skills/playwright-skill` ## Workflow 1. For localhost work, detect running servers before writing a URL: ```bash node -e "require('$SKILL_DIR/lib/helpers').detectDevServers().then(s => console.log(JSON.stringify(s)))" ``` Use the only result automatically. Ask which URL to use when there are multiple results. Ask for a URL or offer to start a server when none exist. 2. Write reusable scripts to `$TMP_DIR/playwright-test-*.js` unless the user asks to save them in the project. Use `PW_SCRIPT_DIR` to preserve scripts. 3. Use a visible browser by default. Use `headless: true` only when requested or when the environment has no display. 4. Put the target URL in a constant or environment variable. 5. Run scripts with `node "$SKILL_DIR/run.js" `. 6. Report actions, failures, and artifact paths. Do not claim success without checking the resulting page. ## Setup Run once: ```bash cd "$SKILL_DIR" && npm run setup ``` This installs Playwright and Chromium. Use `cd "$SKILL_DIR" && npm run install-all-browsers` when Firefox or WebKit is required. ## Minimal example ```javascript const os = require('node:os'); const path = require('node:path'); const { chromium } = require('playwright'); const targetUrl = process.env.TARGET_URL || 'http://localhost:3000'; const artifactDir = process.env.PW_ARTIFACT_DIR || os.tmpdir(); (async () => { const browser = await chromium.launch({ headless: false }); try { const page = await browser.newPage(); await page.goto(targetUrl); console.log('Page loaded:', await page.title()); await page.screenshot({ path: path.join(artifactDir, 'page.png'), fullPage: true }); } finally { await browser.close(); } })(); ``` Run it: ```bash node "$SKILL_DIR/run.js" "$TMP_DIR/playwright-test-page.js" ``` For short one-off tasks, use inline execution: ```bash node "$SKILL_DIR/run.js" -e "const browser = await chromium.launch({headless: false}); try { const page = await browser.newPage(); await page.goto('https://example.com'); console.log(await page.title()); } finally { await browser.close(); }" ``` The `-e` process exits as soon as the snippet settles, so close the browser inside the snippet. ## Current Playwright patterns Prefer locators that describe what a user sees, in this order: 1. `page.getByRole()` with an accessible name 2. `page.getByLabel()` for form controls 3. `page.getByText()` for visible content 4. `page.getByTestId()` when the application provides a test contract Actions auto-wait for actionability. Use web-first assertions or a locator's `waitFor()` instead of `waitForSelector()`, fixed sleeps, or `networkidle`. ```javascript await page.getByLabel('Email').fill('[email protected]'); await page.getByRole('button', { name: 'Sign in' }).click(); await page.waitForURL('**/dashboard'); await page.getByRole('heading', { name: 'Dashboard' }).waitFor(); ``` ## Common tasks ### Responsive checks ```javascript { const os = require('node:os'); const path = require('node:path'); const artifactDir = process.env.PW_ARTIFACT_DIR || os.tmpdir(); const viewports = [ { name: 'desktop', width: 1440, height: 900 }, { name: 'mobile', width: 390, height: 844 }, ]; for (const viewport of viewports) { await page.setViewportSize(viewport); await page.goto(targetUrl); await page.screenshot({ path: path.join(artifactDir, `${viewport.name}.png`), fullPage: true }); } } ``` ### Login flow Use test credentials supplied by the user. Never invent or expose real credentials. Verify both the navigation and a post-login element. ```javascript await page.goto(`${targetUrl}/login`); await page.getByLabel('Email').fill(process.env.TEST_EMAIL); await page.getByLabel('Password').fill(process.env.TEST_PASSWORD); await page.getByRole('button', { name: /sign in|log in/i }).click(); await page.waitForURL('**/dashboard'); await page.getByRole('heading', { name: /dashboard/i }).waitFor(); ``` ### Save scripts and artifacts ```bash PW_SCRIPT_DIR=./playwright-tests node "$SKILL_DIR/run.js" "$TMP_DIR/playwright-test-login.js" PW_ARTIFACT_DIR=./playwright-artifacts node "$SKILL_DIR/run.js" "$TMP_DIR/playwright-test-page.js" ``` `PW_SCRIPT_DIR` copies file-based scripts before execution and adds a timestamp when a filename already exists. `PW_ARTIFACT_DIR` controls helper screenshot output; the default is the operating system temporary directory. ### Connect to an existing Chrome session Start Chrome with remote debugging enabled, then connect with Playwright: ```javascript const browser = await chromium.connectOverCDP('http://127.0.0.1:9222'); const page = browser.contexts()[0].pages()[0]; ``` This reuses cookies and extensions in that session. Do not use it for secrets unless the user explicitly asks; a connected browser has the user's access. ## Helpers ```javascript const helpers = require(`${process.env.PW_SKILL_DIR}/lib/helpers`); const servers = await helpers.detectDevServers(); const browser = await helpers.launchBrowser('chromium'); const context = await helpers.createContext(browser); const page = await context.newPage(); await helpers.handleCookieBanner(page); await helpers.takeScreenshot(page, 'result'); ``` Available helpers are `detectDevServers`, `getExtraHeadersFromEnv`, `launchBrowser`, `createContext`, `handleCookieBanner`, and `takeScreenshot`. Use Playwright locators and assertions directly for actions, waits, extraction, authentication, tables, and retries. ## Configuration - `PW_BROWSER`: `chromium`, `firefox`, or `webkit` for `launchBrowser()`. - `PW_CHANNEL`: installed browser channel such as `chrome` or `msedge`. - `PW_EXECUTABLE_PATH`: explicit browser executable path. - `PW_HEADLESS`: `true` or `false`; visible mode is the default. - `SLOW_MO`: action delay in milliseconds. - `PW_HEADER_NAME` and `PW_HEADER_VALUE`: one extra HTTP header. - `PW_EXTRA_HEADERS`: JSON object of extra HTTP headers. - `PW_SCRIPT_DIR`: directory for preserving file-based scripts. - `PW_ARTIFACT_DIR`: directory for helper-generated screenshots. See [API_REFERENCE.md](API_REFERENCE.md) for network interception, API mocking, authentication state, video, visual checks, device emulation, and CI patterns.

相关技能

Agent 工作流

技能创建者Skill Creator

创造有效技能指南。 当用户想创造出新的技能(或更新现有的技能),以专业知识,工作流程,或工具集成来扩展克洛德的能力时,应该使用这种技能.

Agent 工作流

克劳德胡布Clawdhub

使用ClawdHub CLI搜索,安装,更新并发布从taladhub.com的代理技能. 需要获取苍蝇上的新技能时使用,将安装的技能同步到最新版本或特定版本,或者发布 npm-instainddhub CLI 的新/更新的技能文件夹.

Agent 工作流

团队指挥Agent Team Orchestration

管弦乐团多代理团队,任务设定周期,交接协议,审查工作流程. 使用时间: (1)建立2+特派员队伍,具有不同专业,(2)确定任务路线和生命周期(收录框_ spec_建设_审查_完成),(3)在特派员之间制定交接协议,(4)建立审查和质量关口,(5)管理特派员之间的交流和文物共享.

Agent 工作流

超级力量Superpowers

Spec-first,TDD,子代理驱动的软件开发工作流程. 当:(1)构建任何新功能或应用——触发脑暴_计划_子代理执行回路,(2)调试出一个bug或测试失败——触发系统性的根起过程,(3)用户说"让我们构建","帮助我计划","我想添加X",或"这个被打破",(4)完成一个功…