accessibility-testing
Original:🇨🇳 Chinese
Translated
7 scriptsChecked / no sensitive code detected
Design accessibility testing plans and test cases covering WCAG 2.1 standards, screen readers, and keyboard navigation. Default output is Markdown, with support for requesting Excel/CSV/JSON formats. Use for accessibility testing.
15installs
Added on
NPX Install
npx skill4agent add naodeng/awesome-qa-skills accessibility-testingTags
Translated version includes tags in frontmatterSKILL.md Content (Chinese)
View Translation Comparison →Accessibility Testing (Chinese Version)
English Version: See the skill .
accessibility-testing-enPrompt templates can be found in in this directory.
prompts/accessibility-testing.mdWhen to Use
- When users mention "accessibility testing", "a11y", or "WCAG"
- When you need to design accessibility testing strategies, test cases, and plans based on WCAG standards
- Trigger Examples: "Design accessibility test cases based on the following requirements" "Create a WCAG 2.1 compliance testing plan"
Output Format Options
This skill outputs Markdown by default (consistent with the Standard-version template). To request other formats, clearly specify at the end of your requirements:
| Format | Description | How to Request (Example) |
|---|---|---|
| Markdown | Default, easy to read and version control | No additional instructions needed |
| Excel | Tab-separated, can be pasted into Excel | "Please output as a tab-separated table compatible with Excel" |
| CSV | Comma-separated, first row as header | "Please output in CSV format" |
| JSON | Easy for program parsing | "Please output in JSON format" |
Detailed explanations and examples can be found in output-formats.md in this directory.
How to Use the Prompts in This Skill
- Open in this directory, copy the content below the dashed line into your AI conversation.
prompts/accessibility-testing.md - Attach your functional requirements or system specifications.
- If you need Excel/CSV/JSON, add the request phrase from output-formats.md at the end.
Reference Files
- prompts/accessibility-testing.md — Standard-version prompts for accessibility testing
- output-formats.md — Instructions for requesting Markdown / Excel / CSV / JSON formats
Code Examples | Code Examples
This skill provides the following real code examples:
-
axe-core + Playwright Automation Testing - Complete accessibility automation testing suite
- 12 test cases
- Covers WCAG 2.1 Level A/AA
- Includes automation and manual testing guidelines
- Detailed violation reports
-
WCAG 2.1 Manual Testing Checklist (Coming soon)
-
Screen Reader Testing Guidelines (Coming soon)
Check the examples/ directory for more examples.
Common Pitfalls | Common Pitfalls
- ❌ Relying solely on automation tools → ✅ Combine automation tools (30% coverage) with manual testing (70% coverage)
- ❌ Ignoring keyboard navigation → ✅ Ensure all functions are accessible via keyboard
- ❌ Insufficient color contrast → ✅ Use tools to check contrast, ensure at least 4.5:1 (normal text)
- ❌ Missing alternative text → ✅ Provide meaningful alt text for all images and icons
- ❌ Missing form labels → ✅ Ensure all form controls have associated labels
- ❌ Testing only after development is complete → ✅ Consider accessibility during design and development phases
Best Practices | Best Practices
-
WCAG Compliance
- Follow WCAG 2.1 Level AA standards (minimum requirement)
- Use automation tools to detect common issues
- Conduct manual testing to verify complex interactions
- Test with real assistive technologies
-
Testing Strategy
- Integrate automated accessibility testing into CI/CD
- Conduct regular manual testing and user testing
- Cross-verify with multiple tools
- Document and track accessibility issues
-
Key Testing Points
- Keyboard navigation (Tab, Enter, Esc, arrow keys)
- Screen reader compatibility (NVDA, JAWS, VoiceOver)
- Color contrast and visual design
- Form accessibility
- Semantic HTML
- Correct use of ARIA attributes
-
Tool Selection
- axe-core: Automation testing (most comprehensive)
- Lighthouse: Quick audits
- WAVE: Visual issue detection
- Screen readers: Real user experience testing
-
Documentation and Reporting
- Clearly document violations and their severity
- Provide repair suggestions and code examples
- Track repair progress
- Generate regular compliance reports
Troubleshooting | Troubleshooting
Issue 1: axe-core reports too many false positives
Symptoms: Automation testing reports numerous issues that are actually false positives
Solutions:
- Configure rules to exclude known false positives:
typescript
await new AxeBuilder({ page }) .disableRules(['color-contrast']) // Exclude specific rules .analyze(); - Filter using tags:
typescript
await new AxeBuilder({ page }) .withTags(['wcag2a', 'wcag2aa']) // Only check WCAG 2.1 A/AA .analyze(); - Manually verify suspicious issues
- Update to the latest version of axe-core
Issue 2: Unable to detect accessibility issues in dynamic content
Symptoms: Issues with dynamic content like modals, dropdown menus are not detected
Solutions:
- Run tests after triggering dynamic content:
typescript
await page.click('[data-testid="open-modal"]'); await page.waitForSelector('[role="dialog"]'); const results = await new AxeBuilder({ page }).analyze(); - Test specific regions:
typescript
await new AxeBuilder({ page }) .include('[role="dialog"]') .analyze(); - Test accessibility in different states
Issue 3: Keyboard navigation tests fail
Symptoms: Some elements cannot be accessed via keyboard
Solutions:
- Check tabindex attributes:
html
<!-- ✅ Recommended: Use tabindex="0" to make elements focusable --> <div role="button" tabindex="0">Click me</div> <!-- ❌ Avoid: tabindex > 0 breaks natural Tab order --> <div tabindex="5">Bad practice</div> - Use semantic HTML:
html
<!-- ✅ Recommended: Native buttons are automatically focusable --> <button>Click me</button> <!-- ❌ Not recommended: Requires additional accessibility attributes --> <div onclick="...">Click me</div> - Add keyboard event handlers:
typescript
element.addEventListener('keydown', (e) => { if (e.key === 'Enter' || e.key === ' ') { // Handle activation } });
Issue 4: Insufficient color contrast
Symptoms: axe-core reports color contrast issues
Solutions:
- Use contrast checking tools:
- Chrome DevTools Lighthouse
- WebAIM Contrast Checker
- Colour Contrast Analyser
- Ensure contrast ratios of at least:
- Normal text: 4.5:1
- Large text (18pt+): 3:1
- UI components: 3:1
- Adjust color schemes:
css
/* ❌ Insufficient contrast */ color: #999; /* Gray text */ background: #fff; /* White background */ /* ✅ Sufficient contrast */ color: #595959; /* Dark gray text */ background: #fff; /* White background */
Issue 5: Screen readers cannot read content correctly
Symptoms: Content is messy or missing when using screen readers
Solutions:
- Use semantic HTML:
html
<!-- ✅ Recommended --> <nav> <ul> <li><a href="/">Home</a></li> </ul> </nav> <!-- ❌ Not recommended --> <div class="nav"> <div class="item">Home</div> </div> - Use ARIA attributes correctly:
html
<!-- ✅ Recommended: Provide meaningful labels --> <button aria-label="Close dialog">×</button> <!-- ❌ Not recommended: Screen readers will only read "multiplication sign" --> <button>×</button> - Use aria-live to notify dynamic changes:
html
<div aria-live="polite" aria-atomic="true"> <!-- Dynamic content --> </div>
Issue 6: Form accessibility issues
Symptoms: Form controls lack labels or error messages are unclear
Solutions:
- Associate labels with inputs:
html
<!-- ✅ Recommended: Explicit association --> <label for="email">Email</label> <input id="email" type="email" /> <!-- ✅ Recommended: Implicit association --> <label> Email <input type="email" /> </label> - Provide clear error messages:
html
<input id="email" type="email" aria-invalid="true" aria-describedby="email-error" /> <span id="email-error" role="alert"> Please enter a valid email address </span> - Use fieldset and legend for grouping:
html
<fieldset> <legend>Contact Information</legend> <!-- Form controls --> </fieldset>
Issue 7: Tests fail in CI environment
Symptoms: Passes locally but accessibility tests fail in CI environment
Solutions:
- Ensure browsers are installed in CI environment:
yaml
- name: Install Playwright run: npx playwright install --with-deps - Check environment differences (fonts, rendering)
- Save screenshots and reports when tests fail:
typescript
if (violations.length > 0) { await page.screenshot({ path: 'a11y-violations.png' }); fs.writeFileSync('a11y-report.json', JSON.stringify(violations)); } - Use Docker containers to ensure environment consistency
Get More Help
If the issue is still not resolved:
- Check FAQ.md
- Check the README.md files in the examples
- Refer to the official WCAG 2.1 documentation
- Use WebAIM resources
- Submit a new Issue with detailed information
Related Skills: functional-testing, manual-testing, automation-testing, test-case-writing.