Token导航 LogoToken导航

Agent Skill · 开发

playwright-pro(Playwright 专业版)

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

playwright-pro 是开发类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为操作浏览器;许可证信息还不明确,第三方扫描已通过,按安装量在开发类的 21,746 个 Skill 里排第 11,046。

总安装 1,958周安装 80GitHub Stars 103下载 627核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/borghei/claude-skills --skill playwright-pro

这个 Skill 是做什么的

开发类 Skill 面向写代码、改代码和排查问题,一般会读写仓库文件,部分还会执行构建或测试命令。

playwright-pro 提供生产级端到端测试解决方案,支持从用户故事自动生成测试用例。采用 Page Object 模式与稳健定位策略,集成 CI/CD 与视觉回归测试。输出可维护的测试套件与 flaky test 修复指南,提升回归验证效率。执行测试时需区分模拟环境与真实浏览器行为,避免误判逻辑缺陷。

适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

来源仓库内路径:skills/playwright-pro

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/borghei/claude-skills --skill playwright-pro;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要操作浏览器,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

playwright-pro 怎么安装?

在终端执行 npx skills add https://github.com/borghei/claude-skills --skill playwright-pro。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

playwright-pro 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

playwright-pro 需要什么权限?

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

playwright-pro 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

playwright-pro 用的人多吗?

公开数据是累计安装 1,958 次,近一周安装 80 次,下载 627 次,GitHub 103 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

playwright-pro 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理开发类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

开发类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
skill-vetter

技能审查员 · OpenClaw

8,779,018986操作浏览器MIT-0通过
ontology

本体论 · OpenClaw

6,636,960576只读MIT-0通过
entra-app-registration

内部应用程序注册 · Codex、Claude

6,631,872764接触敏感数据未明确通过
entra-app-registration

内部应用程序注册 · Codex、Claude

3,757,680201接触敏感数据未明确通过
nano-banana-pro

纳米香蕉专业版 · OpenClaw

3,526,898364接触敏感数据MIT-0有提醒
playwright-pro

Playwright 专业版 · 本页

1,958103操作浏览器未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Playwright Pro

Tier: POWERFUL Category: Engineering / Testing Maintainer: Claude Skills Team

Overview

Production-grade end-to-end testing with Playwright. Generate tests from user stories, implement the Page Object pattern for maintainability, apply the correct locator strategy for resilient tests, diagnose and fix flaky tests, migrate from Cypress or Selenium, integrate with CI/CD, run visual regression tests, and perform accessibility audits. Enforces the 10 golden rules that eliminate 90% of E2E test failures.

Sub-Skills

This skill uses compound sub-skill architecture. Each sub-skill in skills/ handles a specific workflow:

Sub-SkillFilePurpose
Initskills/init.mdBootstrap Playwright in a project -- install, configure, create first test
Generateskills/generate.mdGenerate test files from user stories or page descriptions
Fixskills/fix.mdDiagnose and fix failing or flaky tests using trace analysis
Migrateskills/migrate.mdMigrate from Cypress or Selenium to Playwright
Reviewskills/review.mdAudit test quality, coverage gaps, and flaky test indicators
Reportskills/report.mdGenerate execution reports from Playwright JSON output
Coverageskills/coverage.mdMap tests to user stories, identify coverage gaps
BrowserStackskills/browserstack.mdBrowserStack cloud integration for cross-browser testing
TestRailskills/testrail.mdTestRail integration for test case management

Sub-Skill Flow

Init ──> Generate ──> Review ──> Fix (if needed)
                         │
                    Coverage ──> Generate (fill gaps)
                         │
                    Report ──> BrowserStack / TestRail

Typical lifecycle: Init sets up the project, Generate creates tests from stories, Review audits quality, Fix resolves failures, Coverage identifies gaps that feed back into Generate, and Report/BrowserStack/TestRail handle reporting and integration.

Scripts

ScriptPurpose
scripts/test_generator.pyGenerate Playwright test code from user story descriptions
scripts/flaky_detector.pyAnalyze multiple CI runs to detect flaky test patterns
scripts/coverage_mapper.pyMap tests to user flows and identify coverage gaps
scripts/page_object_generator.pyGenerate Page Object classes from HTML or selector lists
scripts/test_analyzer.pyScan test files for anti-patterns and quality issues
scripts/test_report_parser.pyParse Playwright JSON reports into summaries

Keywords

Playwright, E2E testing, end-to-end testing, page objects, flaky tests, test generation, Cypress migration, Selenium migration, visual regression, accessibility testing, CI integration

10 Golden Rules

These rules are non-negotiable. Following them eliminates 90% of E2E test failures.

  1. getByRole() over CSS/XPath — resilient to markup changes
  2. Never page.waitForTimeout() — use web-first assertions instead
  3. expect(locator) auto-retries; expect(await locator.textContent()) does NOT
  4. Isolate every test — no shared state between tests
  5. baseURL in config — zero hardcoded URLs in tests
  6. Retries: 2 in CI, 0 locally — retries mask flakiness in dev
  7. Traces: 'on-first-retry' — rich debugging without slowdown
  8. Fixtures over globals — test.extend() for shared setup
  9. One behavior per test — multiple related assertions are fine
  10. Mock external services only — never mock your own app

Locator Priority (Most to Least Preferred)

1. getByRole('button', { name: 'Submit' })     — semantic, accessible
2. getByLabel('Email address')                   — form fields with labels
3. getByText('Welcome back')                     — visible text content
4. getByPlaceholder('Enter your email')          — inputs with placeholder
5. getByTestId('submit-button')                  — when no semantic option exists
6. page.locator('.submit-btn')                   — CSS as last resort
7. page.locator('//button[@type="submit"]')      — XPath: avoid entirely

Why This Order Matters

// FRAGILE: breaks when CSS class changes
await page.locator('.btn-primary-lg').click();

// FRAGILE: breaks when DOM structure changes
await page.locator('div > form > button:nth-child(2)').click();

// RESILIENT: survives refactors, tests what users see
await page.getByRole('button', { name: 'Create account' }).click();

Configuration

playwright.config.ts

import { defineConfig, devices } from '@playwright/test';

export default defineConfig({
  testDir: './tests/e2e',
  fullyParallel: true,
  forbidOnly: !!process.env.CI,
  retries: process.env.CI ? 2 : 0,
  workers: process.env.CI ? 4 : undefined,
  reporter: process.env.CI
    ? [['html'], ['github'], ['json', { outputFile: 'test-results.json' }]]
    : [['html']],

  use: {
    baseURL: process.env.BASE_URL || 'http://localhost:3000',
    trace: 'on-first-retry',
    screenshot: 'only-on-failure',
    video: 'retain-on-failure',
  },

  projects: [
    // Auth setup: runs once, shares state with all tests
    { name: 'setup', testMatch: /.*\.setup\.ts/ },

    {
      name: 'chromium',
      use: { ...devices['Desktop Chrome'] },
      dependencies: ['setup'],
    },
    {
      name: 'firefox',
      use: { ...devices['Desktop Firefox'] },
      dependencies: ['setup'],
    },
    {
      name: 'mobile-chrome',
      use: { ...devices['Pixel 5'] },
      dependencies: ['setup'],
    },
  ],

  webServer: {
    command: 'pnpm dev',
    url: 'http://localhost:3000',
    reuseExistingServer: !process.env.CI,
    timeout: 30000,
  },
});

Page Object Pattern

// pages/login.page.ts
import { type Page, type Locator, expect } from '@playwright/test';

export class LoginPage {
  readonly page: Page;
  readonly emailInput: Locator;
  readonly passwordInput: Locator;
  readonly submitButton: Locator;
  readonly errorMessage: Locator;
  readonly forgotPasswordLink: Locator;

  constructor(page: Page) {
    this.page = page;
    this.emailInput = page.getByLabel('Email address');
    this.passwordInput = page.getByLabel('Password');
    this.submitButton = page.getByRole('button', { name: 'Sign in' });
    this.errorMessage = page.getByRole('alert');
    this.forgotPasswordLink = page.getByRole('link', { name: 'Forgot password?' });
  }

  async goto() {
    await this.page.goto('/login');
  }

  async login(email: string, password: string) {
    await this.emailInput.fill(email);
    await this.passwordInput.fill(password);
    await this.submitButton.click();
  }

  async expectError(message: string) {
    await expect(this.errorMessage).toContainText(message);
  }

  async expectRedirectToDashboard() {
    await expect(this.page).toHaveURL(/\/dashboard/);
  }
}
// pages/dashboard.page.ts
import { type Page, type Locator, expect } from '@playwright/test';

export class DashboardPage {
  readonly page: Page;
  readonly heading: Locator;
  readonly projectList: Locator;
  readonly createProjectButton: Locator;

  constructor(page: Page) {
    this.page = page;
    this.heading = page.getByRole('heading', { name: 'Dashboard' });
    this.projectList = page.getByRole('list', { name: 'Projects' });
    this.createProjectButton = page.getByRole('button', { name: 'New project' });
  }

  async expectLoaded() {
    await expect(this.heading).toBeVisible();
  }

  async getProjectCount() {
    return this.projectList.getByRole('listitem').count();
  }

  async createProject(name: string) {
    await this.createProjectButton.click();
    await this.page.getByLabel('Project name').fill(name);
    await this.page.getByRole('button', { name: 'Create' }).click();
  }
}

Test Generation from User Stories

Given a user story, generate tests following this pattern:

// tests/e2e/auth/login.spec.ts
import { test, expect } from '@playwright/test';
import { LoginPage } from '../../pages/login.page';
import { DashboardPage } from '../../pages/dashboard.page';

test.describe('User Login', () => {
  let loginPage: LoginPage;

  test.beforeEach(async ({ page }) => {
    loginPage = new LoginPage(page);
    await loginPage.goto();
  });

  test('successful login redirects to dashboard', async ({ page }) => {
    await loginPage.login('user@example.com', 'password123');
    const dashboard = new DashboardPage(page);
    await dashboard.expectLoaded();
  });

  test('shows error for invalid credentials', async () => {
    await loginPage.login('user@example.com', 'wrongpassword');
    await loginPage.expectError('Invalid email or password');
  });

  test('shows validation error for empty email', async () => {
    await loginPage.login('', 'password123');
    await loginPage.expectError('Email is required');
  });

  test('shows validation error for invalid email format', async () => {
    await loginPage.login('not-an-email', 'password123');
    await loginPage.expectError('Enter a valid email');
  });

  test('forgot password link navigates to reset page', async ({ page }) => {
    await loginPage.forgotPasswordLink.click();
    await expect(page).toHaveURL(/\/forgot-password/);
  });
});

Authentication Setup (Shared State)

// tests/e2e/auth.setup.ts
import { test as setup, expect } from '@playwright/test';

const authFile = 'playwright/.auth/user.json';

setup('authenticate as test user', async ({ page }) => {
  await page.goto('/login');
  await page.getByLabel('Email address').fill('test@example.com');
  await page.getByLabel('Password').fill('password123');
  await page.getByRole('button', { name: 'Sign in' }).click();

  // Wait for redirect to confirm login succeeded
  await expect(page).toHaveURL(/\/dashboard/);

  // Save authentication state for reuse
  await page.context().storageState({ path: authFile });
});

Flaky Test Diagnosis

Common Causes and Fixes

SymptomCauseFix
waitForTimeout(2000) in testTiming-dependentReplace with await expect(locator).toBeVisible()
Test passes locally, fails in CIRace conditionAdd web-first assertion before interaction
Element not found after navigationPage not loadedawait page.waitForURL('/expected-path')
Stale element referenceDOM re-renderedUse Playwright locators (auto-retry)
Different data between runsShared test stateIsolate with test.beforeEach setup
Flaky on slow CI runnersInsufficient timeoutIncrease expect timeout, not waitForTimeout

Diagnosis Commands

# Run with trace on every test (not just retries)
npx playwright test --trace on

# Run a specific flaky test 10 times
for i in $(seq 1 10); do npx playwright test tests/e2e/checkout.spec.ts; done

# Show test timeline
npx playwright test --trace on
npx playwright show-trace test-results/*/trace.zip

# Run in headed mode for visual debugging
npx playwright test --headed --retries 0

# Debug a specific test interactively
npx playwright test --debug tests/e2e/checkout.spec.ts

Cypress to Playwright Migration

CypressPlaywright
cy.visit('/path')await page.goto('/path')
cy.get('.selector')page.locator('.selector')
cy.contains('text')page.getByText('text')
cy.get('[data-testid="x"]')page.getByTestId('x')
cy.intercept('GET', '/api/*')await page.route('/api/*',...)
cy.wait('@alias')await page.waitForResponse('/api/*')
cy.should('be.visible')await expect(locator).toBeVisible()
cy.should('have.text', 'x')await expect(locator).toHaveText('x')
cy.fixture('data.json')JSON.parse(fs.readFileSync(...))
beforeEach(() => {cy.login()})Auth setup project + storageState

CI Integration

GitHub Actions

name: E2E Tests
on: [push, pull_request]

jobs:
  e2e:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: pnpm/action-setup@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: 'pnpm'
      - run: pnpm install --frozen-lockfile
      - run: pnpm exec playwright install --with-deps chromium

      - run: pnpm build  # build the app first
      - run: pnpm exec playwright test
        env:
          BASE_URL: http://localhost:3000

      - uses: actions/upload-artifact@v4
        if: failure()
        with:
          name: playwright-report
          path: playwright-report/
          retention-days: 7

Visual Regression Testing

// tests/e2e/visual/dashboard.spec.ts
import { test, expect } from '@playwright/test';

test('dashboard matches visual snapshot', async ({ page }) => {
  await page.goto('/dashboard');
  await page.waitForLoadState('networkidle');

  // Full page screenshot comparison
  await expect(page).toHaveScreenshot('dashboard.png', {
    maxDiffPixels: 50,  // allow small rendering differences
  });
});

test('project card component snapshot', async ({ page }) => {
  await page.goto('/dashboard');
  const card = page.getByTestId('project-card').first();

  await expect(card).toHaveScreenshot('project-card.png', {
    maxDiffPixelRatio: 0.01,
  });
});
# Generate/update baseline screenshots
npx playwright test --update-snapshots

# Run visual comparison
npx playwright test tests/e2e/visual/

Accessibility Testing

import { test, expect } from '@playwright/test';
import AxeBuilder from '@axe-core/playwright';

test('login page has no accessibility violations', async ({ page }) => {
  await page.goto('/login');

  const results = await new AxeBuilder({ page })
    .withTags(['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa'])
    .analyze();

  expect(results.violations).toEqual([]);
});

test('dashboard meets WCAG AA standards', async ({ page }) => {
  await page.goto('/dashboard');

  const results = await new AxeBuilder({ page })
    .exclude('.third-party-widget')  // exclude elements you don't control
    .analyze();

  // Log violations for debugging
  for (const violation of results.violations) {
    console.log(`${violation.impact}: ${violation.description}`);
    for (const node of violation.nodes) {
      console.log(`  - ${node.html}`);
    }
  }

  expect(results.violations.filter(v => v.impact === 'critical')).toEqual([]);
});

Common Pitfalls

  • page.waitForTimeout(N) — the single most common cause of flaky tests; use web-first assertions
  • CSS selectors as primary strategy — breaks on every refactor; use role/label/text locators
  • Shared state between tests — one test's data pollutes another; isolate with proper setup/teardown
  • No trace configuration — debugging CI failures without traces wastes hours; enable on-first-retry
  • Testing third-party services — mock external APIs; only test your own application
  • Running all browsers in development — test Chromium locally, full matrix in CI only
  • No page objects — duplicate locators across tests create maintenance nightmares

Best Practices

  1. Page Object per page/component — centralize locators, expose user-intent methods
  2. Web-first assertions everywhere — expect(locator).toBeVisible() auto-retries, waitForTimeout does not
  3. Auth as a setup project — authenticate once, reuse storageState across all tests
  4. One behavior per test — keeps failures isolated and test names meaningful
  5. Run in CI with --retries 2 — but investigate any test that needs retries locally
  6. Trace + screenshot on failure — upload as CI artifacts for post-mortem debugging
  7. Visual regression for critical UI — catch unintended visual changes automatically
  8. Accessibility tests in the suite — WCAG compliance as a regression gate, not an afterthought

Troubleshooting

ProblemCauseSolution
locator.click() times outElement hidden behind overlay/modal or not yet renderedAdd await expect(locator).toBeVisible() before clicking; check for z-index overlays blocking the target
Visual snapshots fail on every CI runDifferent OS font rendering between local and CIGenerate baseline screenshots inside CI (Linux), not locally (macOS); use maxDiffPixelRatio: 0.02 for tolerance
Auth setup project runs but tests get 401storageState path mismatch or expired tokenVerify storageState path in playwright.config.ts matches the setup script; confirm tokens don't expire mid-suite
page.route() intercept never triggersRoute pattern doesn't match the actual request URL or glob syntax errorLog requests with page.on('request', r => console.log(r.url())) to verify the exact URL; use ** glob for subpaths
Tests pass individually but fail when run togetherShared mutable state or port collision between parallel workersEnsure test isolation via test.beforeEach setup; use unique test data per worker with test.info().parallelIndex
toHaveScreenshot() throws "missing baseline"Snapshot file not committed to version controlRun npx playwright test --update-snapshots and commit the generated files under the __screenshots__ directory
Accessibility audit returns false positivesAxe scanning third-party embedded widgets or iframesUse .exclude('.third-party-widget') or .include('#app-root') to scope the audit to your own markup

Success Criteria

  • Flaky test rate below 2% — measured over a rolling 7-day window across all CI runs; any test exceeding 5% flake rate is quarantined and fixed within 48 hours
  • E2E suite completes within 10 minutes — full cross-browser matrix (Chromium, Firefox, mobile) on CI with 4 parallel workers; alert if wall-clock time exceeds threshold
  • 100% of critical user journeys covered — login, checkout, onboarding, and core CRUD workflows each have dedicated spec files with happy-path and primary error-path tests
  • Zero waitForTimeout() calls in the codebase — enforced via ESLint rule or grep-based CI check; all waits use web-first assertions
  • Page Object coverage for every tested page — no raw locators in spec files; all element access goes through page object classes with user-intent method names
  • WCAG AA compliance gate passing — accessibility tests run on every PR; zero critical or serious violations allowed to merge
  • Visual regression baselines reviewed on every UI PR — screenshot diffs attached to PR as artifacts; baseline updates require explicit reviewer approval

Scope & Limitations

This skill covers:

  • End-to-end test authoring, organization, and maintenance with Playwright
  • Page Object Model architecture and locator strategy best practices
  • Flaky test diagnosis, CI integration, and trace-based debugging
  • Visual regression testing and WCAG accessibility auditing

This skill does NOT cover:

  • Unit testing or component testing in isolation (see engineering/testing-strategy for test pyramid guidance)
  • API contract testing or load/performance testing (see api-test-suite-builder for API-focused testing)
  • Test data management, database seeding, or factory patterns for test fixtures
  • Mobile native app testing (Appium, Detox); this skill targets web browsers only

Integration Points

SkillIntegrationData Flow
ci-cd-pipeline-builderE2E tests run as a pipeline stage after build and unit testsPipeline config triggers playwright test; artifacts (traces, screenshots) upload on failure
api-test-suite-builderAPI tests validate backend contracts; Playwright tests validate UI flows end-to-endAPI test results confirm endpoint stability before E2E suite runs against the same environment
pr-review-expertPR reviews check for test coverage on UI changes and flag missing E2E specsReview checklist references Playwright Pro golden rules; flags waitForTimeout or raw CSS selectors
performance-profilerPerformance budgets complement E2E tests to catch regressionsProfiler identifies slow pages; Playwright tests add networkidle waits or performance assertions for flagged routes
observability-designerTest failures feed into observability dashboards for flake trackingCI test results export JSON reports; observability pipelines ingest pass/fail/flake metrics over time
release-managerE2E suite is a release gate; green suite required before deployment proceedsRelease workflow calls Playwright CI job; blocks release tag creation on any test failure

平台分布

Codex

35.34%
按下载量换算222

Claude

28.92%
按下载量换算181

Cursor

18.91%
按下载量换算119

Gemini CLI

8.93%
按下载量换算56

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

操作浏览器

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

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills