Token导航 LogoToken导航TokenDH.com
研究检索操作浏览器github未标认证来源可访问许可证需确认审计提醒

playwright-test-generatorPlaywright 测试生成器

Agent Skill

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

总安装

441

周安装

18

GitHub Stars

1

下载量

141
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/dididy/e2e-skills --skill playwright-test-generator

简介

playwright-test-generator 从零生成完整的 Playwright 端到端测试。

  • 包含环境检测、覆盖率分析和浏览器探索阶段。
  • 支持 EnterPlanMode 与人工审批结合的测试设计流程。
  • 自动执行 YAGNI 审核并通过 playwright-debugger 调试失败。
  • 适用于复杂交互场景的测试用例自动生成。

SKILL.md

playwright-test-generator

General-purpose Playwright E2E test generation pipeline. From zero to reviewed, passing tests.

Pipeline Overview

Step 1: Environment Detection
Step 2: Coverage Gap Analysis  (skipped if $ARGUMENT provided)
Step 3: Browser Exploration    (Playwright CLI / agent-browser)
Step 4: Scenario Design        (EnterPlanMode → user approve)
Step 5: Code Generation        (see code-rules.md)
Step 6: YAGNI Audit + e2e-reviewer
Step 7: TS Compile + Test Run  (playwright-debugger on failure)

Step 1: Environment Detection

Read project files to build a project profile before doing anything else.

WhatWhere to look
Playwright configplaywright.config.ts, playwright.config.js
Base URLbaseURL in playwright config → fallback: PLAYWRIGHT_BASE_URL env var → if neither exists, ask user
Test directoryconfig testDir → fallback scan: e2e/, tests/, playwright/
POM patternCheck for models/, pages/, page-objects/ directories
Existing specsAll *.spec.ts / *.test.ts files in test dir

Output (project profile):

baseURL: <detected or user-provided>
testDir: <detected path>
hasPOM: true | false
existingSpecs: [list of file paths]

If baseURL cannot be determined: stop and ask the user to provide the target URL before proceeding.


Step 2: Coverage Gap Analysis

Skipped if $ARGUMENT is provided — jump to Step 3 with that target.

When no argument is given:

  1. Scan for routing files in priority order:

- Angular: app-routing.module.ts, *-routing.module.ts - Next.js: app/ directory (App Router), pages/ directory (Pages Router) - React Router: router.ts, routes.ts, routes.tsx - Fallback: grep source files for path:, route(, <Route patterns - If no routes found at all: ask user to list the pages they want covered

  1. Map existing spec files to routes:

- Match by file name (e.g. login.spec.ts/login) - Match by page.goto() calls inside spec files

  1. Output uncovered routes. Flag as high priority:

- Auth-related paths (/login, /register, /forgot-password) - Form-heavy pages (any page with <form> or multiple inputs)

  1. Ask the user which target to start with before continuing.

Step 3: Browser Exploration

Do not guess selectors from source code alone. Use live browser exploration to discover real element roles, labels, and testids.

Navigation target: <baseURL>/<target-path> from the project profile (Step 1) + selected route (Step 2). If the page requires authentication, open the login page first, authenticate, then navigate to the target.

Use agent-browser tools as the primary exploration method:

1. browser_navigate <target-URL>
2. browser_snapshot → identify interactive elements (do NOT paste raw content into responses)
3. For each key interaction (button click, form fill, modal open, nav link):
   a. browser_click / browser_type / browser_fill_form / browser_select_option
   b. browser_snapshot → capture resulting state
4. browser_close

Reference only — do not use as primary: npx playwright codegen <URL> launches an interactive browser recorder. It is useful for manually discovering selectors during development but cannot be automated in an agent pipeline.

If agent-browser tools are unavailable, use npx playwright codegen <URL> manually and paste discovered selectors into the Locator Mapping Table in Step 4.

Snapshot handling: Extract element roles, labels, testids, and visible text from snapshot output. Summarize findings — do NOT paste raw YAML into responses.

Collect before moving to Step 4:

  • Interactive elements: buttons, links, inputs, selects, modals, dropdowns
  • Locator candidates: role+name pairs, label text, data-testid values, attribute selectors
  • Key state transitions: loading states, error messages, empty states, open/close toggles

Step 4: Scenario Design + User Approval

Call EnterPlanMode. This switches Claude Code into plan mode — the AI writes a plan in the conversation and waits for the user to explicitly approve before any files are written. Do not write any code until the user approves.

Write a plan containing:

Scenarios

## Scenario 1: [descriptive title]
- Given: [precondition — what state the app is in]
- When: [user action]
- Then: [expected result — what the user sees]

Cover at minimum: one happy path + one error/edge case per feature.

Locator Mapping Table

| Locator name   | File              | Selector                                 | Used in | New/Existing |
|----------------|-------------------|------------------------------------------|---------|--------------|
| submitButton   | login-page.ts     | getByRole('button', { name: 'Sign in' }) | 1, 2    | New          |
| emailInput     | login-page.ts     | getByLabel('Email')                      | 1, 2    | New          |
| errorMessage   | login-page.ts     | getByText('Invalid credentials')         | 2       | New          |

Rules:

  • Do not create any locator not listed in this table
  • No getter methods — locators are exposed directly as readonly properties
  • .nth(), .first(), .last() require // JUSTIFIED: <reason> on the line immediately above

Call ExitPlanMode. Wait for user approval before proceeding to Step 5.


Step 5: Code Generation

Follow code-rules.md in this directory for:

  • Structure detection (POM vs flat spec)
  • Selector priority
  • POM rules and composition pattern
  • Spec rules and forbidden patterns

Key principle: detect project structure first, match existing patterns when extending.


Step 6: YAGNI Audit + e2e-reviewer

YAGNI audit (run immediately after writing code)

  1. List every locator defined in the generated/modified POM file(s)
  2. Grep each locator name across all spec files
  3. Delete any locator with zero usages
  4. Output the audit table:
| Locator        | File           | Used in          | Status  |
|----------------|----------------|------------------|---------|
| submitButton   | login-page.ts  | login.spec.ts:18 | IN USE  |
| unusedLocator  | login-page.ts  | (none)           | DELETED |

e2e-reviewer (automatic quality gate)

Invoke the e2e-reviewer skill using the Skill tool, targeting the generated spec and POM files.

  • P0 issues found: fix immediately, re-invoke e2e-reviewer, repeat until 0 P0s
  • P1/P2 issues found: output in the final report, do not block Step 7

Step 7: Verification + Failure Handling

# 1. Type check — must pass with 0 errors
# Use e2e-specific tsconfig if present (e.g. e2e/tsconfig.json), otherwise root tsconfig
npx tsc --noEmit -p <e2e/tsconfig.json or tsconfig.json>

# 2. Run generated tests
npx playwright test <generated-spec-file> --project=chromium

Failure handling (max 3 auto-fix attempts)

AttemptFocusAction
1Selector mismatchesRe-snapshot the page if needed, update locators to match actual DOM
2Assertion failuresFix expected values, add {timeout} for slow elements
3Structural issuesFix missing await, wrong test setup, incorrect beforeEach

After 3 failed attempts: invoke playwright-debugger skill using the Skill tool. Do not attempt a 4th fix.

Completion report (on full pass)

## playwright-test-generator — Complete

Generated:
- <path to POM file> (new | modified)
- <path to spec file> (new, N scenarios)

Coverage added: <route path>

e2e-reviewer: N P0 (fixed), N P1 (listed below)
Tests: N passed

Reference

  • Playwright best practices: see best-practices.md in this directory
  • Code generation rules: see code-rules.md in this directory

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

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

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

平台分布

Codex

35.09%
按下载量换算49

Claude

33.38%
按下载量换算47

Cursor

18.05%
按下载量换算25

Gemini CLI

9.51%
按下载量换算13

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

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

来源信息

继续浏览同类 Skills