Token导航 LogoToken导航TokenDH.com
开发敏感数据github未标认证来源可访问许可证需确认审计提醒

playwrightPlaywright 浏览器测试

Agent Skill

用于辅助测试设计、自动化测试、用例整理和回归验证。它适合让 Agent 编写单元测试、端到端测试、测试计划或根据失败日志定位问题。使用时需要确认项目测试框架、运行命令和夹具数据,避免为了通过测试而改坏真实逻辑;涉及浏览器或外部服务时,应区分本地模拟、测试环境和生产环境。

总安装

4,480

周安装

183

GitHub Stars

10

下载量

1,449
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:playwright(Playwright 浏览器测试)
来源仓库:https://github.com/oakoss/agent-skills
仓库路径:skills/playwright
安装命令:
npx skills add https://github.com/oakoss/agent-skills --skill playwright
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/oakoss/agent-skills --skill playwright

简介

用于辅助测试设计、自动化测试、用例整理和回归验证。

  • 它适合让 Agent 编写单元测试、端到端测试、测试计划或根据失败日志定位问题。
  • 使用时需要确认项目测试框架、运行命令和夹具数据。
  • 避免为了通过测试而改坏真实逻辑;涉及浏览器或外部服务时,应区分本地模拟、测试环境和生产环境。
  • playwright 属于开发类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Playwright

Overview

Playwright is a browser automation framework for Node.js and Python supporting Chromium, Firefox, and WebKit with a single API. It provides auto-waiting, web-first assertions, and full test isolation for reliable end-to-end testing.

When to use: Browser automation, web scraping, screenshot/PDF generation, API testing, configuring Playwright Test, troubleshooting Playwright errors, stealth mode and anti-bot bypass.

When NOT to use: Simple HTTP requests (use fetch), unit testing (use Vitest/Jest), serverless scraping at scale (consider Cloudflare Browser Rendering). For E2E test architecture (Page Object Models, CI sharding, test organization, authentication patterns), use the e2e-testing skill.

Quick Reference

PatternAPI / ConfigKey Points
Basic testtest('name', async ({page}) => {})Auto-wait, web-first assertions, test isolation
Locatorpage.getByRole() / page.locator()Prefer role/label/text selectors over CSS
Assertionexpect(locator).toBeVisible()Auto-retrying, configurable timeout
API testingrequest fixture / apiRequestContextSend HTTP requests, validate responses
Aria snapshotexpect(locator).toMatchAriaSnapshot()Validate accessibility tree structure via YAML
Class assertionexpect(locator).toContainClass('active')Match individual CSS class names (v1.52+)
Visible filterlocator.filter({visible: true})Match only visible elements (v1.51+)
Test steptest.step('name', async (step) => {})Timeout, skip, and attachments (v1.50+)
Stealth modeplaywright-extra + stealth pluginPatches 20+ detection vectors
Authenticated sessioncontext.cookies() + addCookies()Save/restore cookies and IndexedDB for persistence
Screenshotpage.screenshot({fullPage: true})Wait for key elements to load first
PDF generationpage.pdf({format: 'A4'})Chromium only, set printBackground: true
Clock APIpage.clockFreeze, fast-forward, or simulate time in tests
A11y assertionstoHaveAccessibleName, toHaveRoleNative assertions without axe-core dependency
Viewport assertionexpect(locator).toBeInViewport()Assert element is within the visible viewport
Changed tests only--only-changed=$GITHUB_BASE_REFRun only test files changed since base branch
Dockermcr.microsoft.com/playwright:v1.58.2-nobleUse --init --ipc=host flags
Debug methodspage.consoleMessages() / page.requests() (v1.56+)No event listeners needed
SpeedboardHTML reporter (v1.57+)Identifies slow tests and bottlenecks
Playwright Agentsnpx playwright init-agentsPlanner, generator, healer for LLM-driven testing
Flaky test detection--fail-on-flaky-tests (v1.50+)Exit code 1 on flaky tests in CI
Modify live responsesroute.fetch() + route.fulfill()Intercept real response, tweak JSON, return it
Soft assertionsexpect.soft(locator)Don't stop test on failure, report all at end
Retry blockexpect(async () => {}).toPass()Default timeout is 0 (forever) — always set one
Custom matchersexpect.extend() / mergeExpects()Define or combine custom assertion methods
Actionability matrixPer-action auto-wait checksclick: all 5 checks, fill: 3, focus/blur: none
Test modifierstest.fixme() / test.fail() / test.slow()fixme=skip+track, fail=assert failure, slow=3x
Parallel modestest.describe.configure({mode: 'serial'})serial, parallel, or default per-describe block
Teardown projectsteardown option on setup projectsAuto-cleanup after all dependents finish

Common Mistakes

MistakeCorrect Pattern
Using CSS selectors over role selectorsPrefer getByRole, getByLabel, getByText for resilience
Not closing browserAlways await browser.close() in finally block
Using setTimeout for waitsUse locator auto-wait or waitForLoadState
page.pause() left in CI codeGuard with if (!process.env.CI) — hangs CI indefinitely
Clicking without waitingUse locator().click() with built-in auto-wait
Shared state between testsEach test gets fresh context via fixtures
Testing implementation detailsAssert user-visible behavior, not DOM structure
Hardcoded waits for dynamic contentWait for selector appearance or content stabilization
Missing await on assertionsAll expect() assertions return promises — must be awaited
Same user agent for all scrapingRotate user agents for high-volume scraping
Using setTimeout for time-dependent testsUse page.clock API to freeze/fast-forward time
Installing axe-core for simple a11y checksUse native toHaveAccessibleName/toHaveRole assertions
Using toPass() without explicit timeoutAlways pass {timeout: 10_000} — default is 0 (forever)
Service worker silently blocking page.route()Set serviceWorkers: 'block' in context config when using MSW
Using fill() for autocomplete/debounce inputsUse pressSequentially() with optional delay for per-keystroke handling
storageState losing sessionStoragestorageState only saves cookies + localStorage — inject sessionStorage via addInitScript()

Delegation

  • Selector troubleshooting: Use Explore agent
  • Test pattern review: Use Task agent
  • Code review: Delegate to code-reviewer agent
For E2E test architecture, Page Object Model patterns, CI sharding strategies, authentication flows, visual regression workflows, or test organization, use the e2e-testing skill.

References

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

34.61%
按下载量换算501

Claude

29.84%
按下载量换算432

Cursor

19.27%
按下载量换算279

Gemini CLI

9.63%
按下载量换算140

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills