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

a11y-playwright-testinga11y Playwright 测试

Agent Skill

用于辅助无障碍访问检查、页面可用性审计和前端可访问性改进。它适合让 Agent 检查语义标签、键盘操作、颜色对比、ARIA 属性和自动化检测结果。使用时需要结合真实页面和浏览器验证,不应只依赖静态文本判断;涉及修复建议时,应兼顾设计系统、组件复用和 WCAG 等通用无障碍规范。

总安装

815

周安装

35

GitHub Stars

123

下载量

286
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/fugazi/test-automation-skills-agents --skill a11y-playwright-testing

简介

用于辅助无障碍访问检查、页面可用性审计和前端可访问性改进。

  • 适合检查语义标签、键盘操作、颜色对比、ARIA 属性和自动化检测结果。
  • 使用时需要结合真实页面和浏览器验证,不应只依赖静态文本判断。
  • 涉及修复建议时,应兼顾设计系统、组件复用和 WCAG 等通用无障碍规范。
  • 安装前建议确认权限范围、维护状态,以及是否会触发联网或文件读写。

SKILL.md

Playwright Accessibility Testing (TypeScript)

Comprehensive toolkit for automated accessibility testing using Playwright with TypeScript and axe-core. Enables WCAG 2.1 Level AA compliance verification, keyboard operability testing, semantic validation, and accessibility regression prevention.

Activation: This skill is triggered when working with accessibility testing, WCAG compliance, axe-core scans, keyboard navigation tests, focus management, ARIA validation, or screen reader compatibility.

When to Use This Skill

  • Automated a11y scans with axe-core for WCAG 2.1 AA compliance
  • Keyboard navigation tests for Tab/Enter/Space/Escape/Arrow key operability
  • Focus management validation for dialogs, menus, and dynamic content
  • Semantic structure assertions for landmarks, headings, and ARIA
  • Form accessibility testing for labels, errors, and instructions
  • Color contrast and visual accessibility verification
  • Screen reader compatibility testing patterns

Prerequisites

RequirementDetails
Node.jsv18+ recommended
Playwright@playwright/test installed
axe-core@axe-core/playwright package
TypeScriptConfigured in project

Quick Setup

# Add axe-core to existing Playwright project
npm install -D @axe-core/playwright axe-core

First Questions to Ask

Before writing accessibility tests, clarify:

  1. Scope: Which pages/flows are in scope? What's explicitly excluded?
  2. Standard: WCAG 2.1 AA (default) or specific organizational policy?
  3. Priority: Which components are highest risk (forms, modals, navigation, checkout)?
  4. Exceptions: Known constraints (legacy markup, third-party widgets)?
  5. Assistive Tech: Which screen readers/browsers need manual testing?

Core Principles

1. Automation Limitations

⚠️ Critical: Automated tooling can detect ~30-40% of accessibility issues. Use automation to prevent regressions and catch common failures; manual audits are required for full WCAG conformance.

2. Semantic HTML First

Prefer native HTML semantics over ARIA. Use ARIA only when native elements cannot achieve the required semantics.

// ✅ Semantic HTML - inherently accessible
await page.getByRole("button", { name: "Submit" }).click();

// ❌ ARIA override - requires manual keyboard/focus handling
await page.locator('[role="button"]').click(); // Often a <div>

3. Locator Strategy as A11y Signal

If you cannot locate an element by role or label, it's often an accessibility defect.

Locator SuccessAccessibility Signal
getByRole('button', {name: 'Submit'})Button has accessible name
getByLabel('Email')Input properly labeled
getByRole('navigation')Landmark exists
locator('.submit-btn') ⚠️May lack accessible name

Key Workflows

Automated Axe Scan (WCAG 2.1 AA)

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

test("page has no WCAG 2.1 AA violations", async ({ page }) => {
  await page.goto("/");

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

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

Scoped Axe Scan (Component-Level)

test("form component is accessible", async ({ page }) => {
  await page.goto("/contact");

  const results = await new AxeBuilder({ page })
    .include("#contact-form") // Scope to specific component
    .withTags(["wcag2a", "wcag2aa", "wcag21a", "wcag21aa"])
    .analyze();

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

Keyboard Navigation Test

test("form is keyboard navigable", async ({ page }) => {
  await page.goto("/login");

  // Tab to first field
  await page.keyboard.press("Tab");
  await expect(page.getByLabel("Email")).toBeFocused();

  // Tab to password
  await page.keyboard.press("Tab");
  await expect(page.getByLabel("Password")).toBeFocused();

  // Tab to submit button
  await page.keyboard.press("Tab");
  await expect(page.getByRole("button", { name: "Sign in" })).toBeFocused();

  // Submit with Enter
  await page.keyboard.press("Enter");
  await expect(page).toHaveURL(/dashboard/);
});

Dialog Focus Management

test("dialog traps and returns focus", async ({ page }) => {
  await page.goto("/settings");
  const trigger = page.getByRole("button", { name: "Delete account" });

  // Open dialog
  await trigger.click();
  const dialog = page.getByRole("dialog");
  await expect(dialog).toBeVisible();

  // Focus should be inside dialog
  await expect(dialog.getByRole("button", { name: "Cancel" })).toBeFocused();

  // Tab should stay trapped in dialog
  await page.keyboard.press("Tab");
  await expect(dialog.getByRole("button", { name: "Confirm" })).toBeFocused();
  await page.keyboard.press("Tab");
  await expect(dialog.getByRole("button", { name: "Cancel" })).toBeFocused();

  // Escape closes and returns focus to trigger
  await page.keyboard.press("Escape");
  await expect(dialog).toBeHidden();
  await expect(trigger).toBeFocused();
});

Skip Link Validation

test("skip link moves focus to main content", async ({ page }) => {
  await page.goto("/");

  // First Tab should focus skip link
  await page.keyboard.press("Tab");
  const skipLink = page.getByRole("link", { name: /skip to (main|content)/i });
  await expect(skipLink).toBeFocused();

  // Activating skip link moves focus to main
  await page.keyboard.press("Enter");
  await expect(page.locator('#main, [role="main"]').first()).toBeFocused();
});

POUR Principles Reference

PrincipleFocus AreasExample Tests
PerceivableAlt text, captions, contrast, structureImage alternatives, color contrast ratio
OperableKeyboard, focus, timing, navigationTab order, focus visibility, skip links
UnderstandableLabels, instructions, errors, consistencyForm labels, error messages, predictable behavior
RobustValid HTML, ARIA, name/role/valueSemantic structure, accessible names

Axe-Core Tags Reference

TagWCAG LevelUse Case
wcag2aLevel AMinimum compliance
wcag2aaLevel AAStandard target
wcag2aaaLevel AAAEnhanced (rarely full)
wcag21a2.1 Level AWCAG 2.1 specific A
wcag21aa2.1 Level AAWCAG 2.1 standard
best-practiceBeyond WCAGAdditional recommendations

Default Tags (WCAG 2.1 AA)

const WCAG21AA_TAGS = ["wcag2a", "wcag2aa", "wcag21a", "wcag21aa"];

Exception Handling

When exceptions are unavoidable:

  1. Scope narrowly - specific component/route only
  2. Document impact - which WCAG criterion, user impact
  3. Set expiration - owner + remediation date
  4. Track ticket - link to remediation issue
// ❌ Avoid: Global rule disable
new AxeBuilder({ page }).disableRules(["color-contrast"]);

// ✅ Better: Scoped exclusion with documentation
new AxeBuilder({ page })
  .exclude("#third-party-widget") // Known issue: JIRA-1234, fix by Q2
  .withTags(["wcag2a", "wcag2aa", "wcag21a", "wcag21aa"])
  .analyze();

Troubleshooting

ProblemCauseSolution
Axe finds 0 violations but app fails manual auditAutomation covers ~30-40%Add manual testing checklist
False positive on dynamic contentContent not fully renderedWait for stable state before scan
Color contrast fails incorrectlyBackground image/gradientUse exclude for known false positives
Cannot find element by roleMissing semantic HTMLFix markup - this is a real bug
Focus not visibleMissing :focus stylesAdd visible focus indicator CSS
Dialog focus not trappedMissing focus trap logicImplement focus trap (see snippets)
Skip link doesn't workTarget missing tabindex="-1"Add tabindex to main content

CLI Quick Reference

CommandDescription
npx playwright test --grep "a11y"Run accessibility tests only
npx playwright test --headedRun with visible browser for debugging
npx playwright test --debugStep through with Inspector
PWDEBUG=1 npx playwright testDebug mode with pause

Common Rationalizations

Common shortcuts and "good enough" excuses that erode test quality — and the reality behind each.
RationalizationReality
"Accessibility can be tested manually later"Automated a11y catches 30-57% of issues instantly. Write a11y tests now, not after release.
"axe-core catches everything"axe covers ~30-50% of WCAG criteria. Manual review and keyboard testing are still required.
"Color contrast is a design concern"It's a legal requirement under WCAG 2.1 AA 1.4.3. Automated contrast checks take zero effort.
"Keyboard navigation tests are optional"Keyboard-only users represent ~10% of your audience. Tab order and focus traps are testable.
"Screen reader testing is too hard to automate"ARIA role and label validation via Playwright catches most structural issues without a real screen reader.
"A11y only matters for public-sector sites"ADA lawsuits target e-commerce, SaaS, and private companies. Non-compliance is expensive.

References

DocumentContent
Snippetsaxe-core setup, helpers, keyboard/focus patterns
WCAG 2.1 AA ChecklistManual audit checklist by POUR principle
ARIA PatternsCommon ARIA widget patterns and validations

External Resources

ResourceURL
WCAG 2.1 Specificationhttps://www.w3.org/TR/WCAG21/
WCAG Quick Referencehttps://www.w3.org/WAI/WCAG21/quickref/
WAI-ARIA Authoring Practiceshttps://www.w3.org/WAI/ARIA/apg/
axe-core Ruleshttps://dequeuniversity.com/rules/axe/

Verification

After completing this skill's workflow, confirm:

  • axe-core audit passesAxeBuilder.analyze() returns zero violations
  • Keyboard navigation tested — All interactive elements reachable via Tab; focus order is logical
  • ARIA attributes valid — No duplicate IDs, no missing labels, roles match element types
  • Color contrast sufficient — WCAG 2.1 AA minimum contrast ratios met (4.5:1 normal text, 3:1 large text)
  • Screen reader compatible — All images have alt text; form inputs have labels; landmarks present
  • Accessibility scan integrated in CI — Accessibility tests run as part of the standard CI pipeline
  • Violation report generated — Axe results saved to file for review and tracking

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

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

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

平台分布

Codex

37.17%
按下载量换算106

Claude

29.31%
按下载量换算84

Cursor

19.74%
按下载量换算56

Gemini CLI

10.94%
按下载量换算31

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

操作浏览器

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

安装前确认

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

来源信息

继续浏览同类 Skills