Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Stop writing tests: Automate fully with Generative AI

      August 19, 2025

      Opsera’s Codeglide.ai lets developers easily turn legacy APIs into MCP servers

      August 19, 2025

      Black Duck Security GitHub App, NuGet MCP Server preview, and more – Daily News Digest

      August 19, 2025

      10 Ways Node.js Development Boosts AI & Real-Time Data (2025-2026 Edition)

      August 18, 2025

      This new Coros watch has 3 weeks of battery life and tracks way more – even fly fishing

      August 20, 2025

      5 ways automation can speed up your daily workflow – and implementation is easy

      August 20, 2025

      This new C-suite role is more important than ever in the AI era – here’s why

      August 20, 2025

      iPhone users may finally be able to send encrypted texts to Android friends with iOS 26

      August 20, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Creating Dynamic Real-Time Features with Laravel Broadcasting

      August 20, 2025
      Recent

      Creating Dynamic Real-Time Features with Laravel Broadcasting

      August 20, 2025

      Understanding Tailwind CSS Safelist: Keep Your Dynamic Classes Safe!

      August 19, 2025

      Sitecore’s Content SDK: Everything You Need to Know

      August 19, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Why GNOME Replaced Eye of GNOME with Loupe as the Default Image Viewer

      August 19, 2025
      Recent

      Why GNOME Replaced Eye of GNOME with Loupe as the Default Image Viewer

      August 19, 2025

      Microsoft admits it broke “Reset this PC” in Windows 11 23H2 KB5063875, Windows 10 KB5063709

      August 19, 2025

      Windows 11 can now screen record specific app windows using Win + Shift + R (Snipping Tool)

      August 19, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»Automated Accessibility Testing with Puppeteer

    Automated Accessibility Testing with Puppeteer

    April 28, 2025

    As digital products become essential to daily life, accessibility is more critical than ever. Accessibility testing ensures that websites and applications are usable by everyone, including people with vision, hearing, motor, or cognitive impairments. While manual accessibility reviews are important, relying solely on them is inefficient for modern development cycles. This is where automated accessibility testing comes in empowering teams to detect and fix accessibility issues early and consistently. In this blog, we’ll explore automated accessibility testing and how you can leverage Puppeteer a browser automation tool to perform smart, customized accessibility checks.

    Related Blogs

    Top Accessibility Testing Tools: Screen Readers & Audit Solutions

    ADA vs Section 508 vs WCAG: Key Differences Explained

    What is Automated Accessibility Testing?

    Automated accessibility testing uses software tools to evaluate websites and applications against standards like WCAG 2.1/2.2, ADA Title III, and Section 508. These tools quickly identify missing alt texts, ARIA role issues, keyboard traps, and more, allowing teams to fix issues before they escalate.

    Note: While automation catches many technical issues, real-world usability testing still requires human intervention.

    Why Automated Accessibility Testing Matters

    • Early Defect Detection: Catch issues during development.
    • Compliance Assurance: Stay legally compliant.
    • Faster Development: Avoid late-stage fixes.
    • Cost Efficiency: Reduces remediation costs.
    • Wider Audience Reach: Serve all users better.

    Understanding Accessibility Testing Foundations

    Accessibility testing analyzes the Accessibility Tree generated by the browser, which depends on:

    • Semantic HTML elements
    • ARIA roles and attributes
    • Keyboard focus management
    • Visibility of content (CSS/JavaScript)

    Key Automated Accessibility Testing Tools

    • axe-core: Leading open-source rules engine.
    • Pa11y: CLI tool for automated scans.
    • Google Lighthouse: Built into Chrome DevTools.
    • Tenon, WAVE API: Online accessibility scanners.
    • Screen Reader Simulation Tools: Simulate screen reader-like navigation.

    Automated vs. Manual Screen Reader Testing

    S. NoAspectAutomated TestingManual Testing
    1SpeedFast (runs in CI/CD)Slower (human verification)
    2CoverageBroad (static checks)Deep (dynamic interactions)
    3False PositivesPossible (needs tuning)Minimal (human judgment)
    4Best ForEarly-stage checksReal-user experience validation
    Related Blogs

    Screen Reader Accessibility Testing Tools

    Cypress Accessibility Testing: Tips for Success

    Automated Accessibility Testing with Puppeteer

    Puppeteer is a Node.js library developed by the Chrome team. It provides a high-level API to control Chrome or Chromium through the DevTools Protocol, enabling you to script browser interactions with ease.

    Puppeteer allows you to:

    • Open web pages programmatically
    • Perform actions like clicks, form submissions, scrolling
    • Capture screenshots, PDFs
    • Monitor network activities
    • Emulate devices or user behaviors
    • Perform accessibility audits

    It supports both:

    • Headless Mode (invisible browser, faster, ideal for CI/CD)
    • Headful Mode (visible browser, great for debugging)

    Because Puppeteer interacts with a real browser instance, it is highly suited for dynamic, JavaScript-heavy websites — making it perfect for accessibility automation.

    Why Puppeteer + axe-core for Accessibility?

    • Real Browser Context: Tests fully rendered pages.
    • Customizable Audits: Configure scans and exclusions.
    • Integration Friendly: Easy CI/CD integration.
    • Enhanced Accuracy: Captures real-world behavior better than static analyzers.

    Setting Up Puppeteer Accessibility Testing

    Step 1: Initialize the Project

    
    mkdir a11y-testing-puppeteer
    cd a11y-testing-puppeteer
    npm init -y
    
    

    Step 2: Install Dependencies

    
    npm install puppeteer axe-core
    npm install --save-dev @types/puppeteer @types/node typescript
    
    

    Step 3: Example package.json

    
    {
      "name": "accessibility_puppeteer",
      "version": "1.0.0",
      "main": "index.js",
      "scripts": {
        "test": "node accessibility-checker.js"
      },
      "dependencies": {
        "axe-core": "^4.10.3",
        "puppeteer": "^24.7.2"
      },
      "devDependencies": {
        "@types/node": "^22.15.2",
        "@types/puppeteer": "^5.4.7",
        "typescript": "^5.8.3"
      }
    }
    
    

    Step 4: Create accessibility-checker.js

    
    const axe = require('axe-core');
    const puppeteer = require('puppeteer');
    
    async function runAccessibilityCheckExcludeSpecificClass(url) {
      const browser = await puppeteer.launch({
        headless: false,
        args: ['--start-maximized']
      });
    
      console.log('Browser Open..');
      const page = await browser.newPage();
      await page.setViewport({ width: 1920, height: 1080 });
    
      try {
        await page.goto(url, { waitUntil: 'networkidle2' });
        console.log('Waiting 13 seconds...');
        await new Promise(resolve => setTimeout(resolve, 13000));
    
        await page.setBypassCSP(true);
        await page.evaluate(axe.source);
    
        const results = await page.evaluate(() => {
          const globalExclude = [
            '[class*="hide"]',
            '[class*="hidden"]',
            '.sc-4abb68ca-0.itgEAh.hide-when-no-script'
          ];
    
          const options = axe.getRules().reduce((config, rule) => {
            config.rules[rule.ruleId] = {
              enabled: true,
              exclude: globalExclude
            };
            return config;
          }, { rules: {} });
    
          options.runOnly = {
            type: 'rules',
            values: axe.getRules().map(rule => rule.ruleId)
          };
    
          return axe.run(options);
        });
    
        console.log('Accessibility Violations:', results.violations.length);
        results.violations.forEach(violation => {
          console.log(`Help: ${violation.help} - (${violation.id})`);
          console.log('Impact:', violation.impact);
          console.log('Help URL:', violation.helpUrl);
          console.log('Tags:', violation.tags);
          console.log('Affected Nodes:', violation.nodes.length);
          violation.nodes.forEach(node => {
            console.log('HTML Node:', node.html);
          });
        });
    
        return results;
    
      } finally {
        await browser.close();
      }
    }
    
    // Usage
    runAccessibilityCheckExcludeSpecificClass('https://www.bbc.com')
      .catch(err => console.error('Error:', err));
    
    

    Expected Output

    When you run the above script, you’ll see a console output similar to this:

    
    Browser Open..
    Waiting 13 seconds...
    Accessibility Violations: 4
    
    Help: Landmarks should have a unique role or role/label/title (i.e. accessible name) combination (landmark-unique)
    Impact: moderate
    Help URL: https://dequeuniversity.com/rules/axe/4.10/landmark-unique?application-axeAPI
    Tags: ['cat.semantics', 'best-practice']
    Affected Nodes: 1
    HTML Nodes: <nav data-testid-"level1-navigation-container" id="main-navigation-container" class="sc-2f092172-9 brnBHYZ">
    
    Help: Elements must have sufficient color contrast (color-contrast)
    Impact: serious
    Help URL: https://dequeuniversity.com/rules/axe/4.1/color-contrast
    Tags: [ 'wcag2aa', 'wcag143' ]
    Affected Nodes: 2
    HTML Node: <a href="/news" class="menu-link">News</a>
    
    Help: Form elements must have labels (label)
    Impact: serious
    Help URL: https://dequeuniversity.com/rules/axe/4.1/label
    Tags: [ 'wcag2a', 'wcag412' ]
    Affected Nodes: 1
    HTML Node: <input type="text" id="search" />
    
    ...
    
    Browser closed.
    
    

    Each violation includes:

    • Rule description (with ID)
    • Impact level (minor, moderate, serious, critical)
    • Helpful links for remediation
    • Affected HTML snippets

    This actionable report helps prioritize fixes and maintain accessibility standards efficiently.

    Related Blogs

    Accessibility Testing with Playwright: Expert Guide

    BrowserStack Accessibility Testing Made Simple

    Best Practices for Puppeteer Accessibility Automation

    • Use headful mode during development, headless mode for automation.
    • Always wait for full page load (networkidle2).
    • Exclude hidden elements globally to avoid noise.
    • Capture and log outputs properly for CI integration.

    Conclusion

    Automated accessibility testing empowers developers to build more inclusive, legally compliant, and user-friendly websites and applications. Puppeteer combined with axe-core enables fast, scalable accessibility audits during development. Adopting accessibility automation early leads to better products, happier users, and fewer legal risks. Start today — make accessibility a core part of your development workflow!

    Frequently Asked Questions

    • Why is automated accessibility testing important?

      Automated accessibility testing is important because it ensures digital products are usable by people with disabilities, supports legal compliance, improves SEO rankings, and helps teams catch accessibility issues early during development.

    • How accurate is automated accessibility testing compared to manual audits?

      Automated accessibility testing can detect about 30% to 50% of common accessibility issues such as missing alt attributes, ARIA misuses, and keyboard focus problems. However, manual audits are essential for verifying user experience, contextual understanding, and visual design accessibility that automated tools cannot accurately evaluate.

    • What are common mistakes when automating accessibility tests?

      Common mistakes include:

      -Running tests before the page is fully loaded.
      -Ignoring hidden elements without proper configuration.
      -Failing to test dynamically added content like modals or popups.
      -Relying solely on automation without follow-up manual reviews.

      Proper timing, configuration, and combined manual validation are critical for success.

    • Can I automate accessibility testing in CI/CD pipelines using Puppeteer?

      Absolutely. Puppeteer-based accessibility scripts can be integrated into popular CI/CD tools like GitHub Actions, GitLab CI, Jenkins, or Azure DevOps. You can configure pipelines to run accessibility audits after deployments or build steps, and even fail builds if critical accessibility violations are detected.

    • Is it possible to generate accessibility reports in HTML or JSON format using Puppeteer?

      Yes, when combining Puppeteer with axe-core, you can capture the audit results as structured JSON data. This data can then be processed into readable HTML reports using reporting libraries or custom scripts, making it easy to review violations across multiple builds.

    The post Automated Accessibility Testing with Puppeteer appeared first on Codoid.

    Source: Read More

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleThe Elder Scrolls IV: Oblivion causes another Bethesda game to shoot up the charts
    Next Article Evaluate Amazon Bedrock Agents with Ragas and LLM-as-a-judge

    Related Posts

    Development

    Creating Dynamic Real-Time Features with Laravel Broadcasting

    August 20, 2025
    Repurposing Protein Folding Models for Generation with Latent Diffusion
    Artificial Intelligence

    Repurposing Protein Folding Models for Generation with Latent Diffusion

    August 20, 2025
    Leave A Reply Cancel Reply

    For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

    Continue Reading

    An RTX 4060 gaming laptop for $705? Now is the perfect time to switch to PC gaming.

    News & Updates

    Marktechpost Releases 2025 Agentic AI and AI Agents Report: A Technical Landscape of AI Agents and Agentic AI

    Machine Learning

    Ease My Hotel – All-in-One Hotel Management Software

    Web Development

    On Information Geometry and Iterative Optimization in Model Compression: Operator Factorization

    Machine Learning

    Highlights

    CVE-2025-20101 – Intel Graphics Driver Out-of-Bounds Read Vulnerability

    May 13, 2025

    CVE ID : CVE-2025-20101

    Published : May 13, 2025, 9:16 p.m. | 1 hour, 58 minutes ago

    Description : Out-of-bounds read for some Intel(R) Graphics Drivers may allow an authenticated user to potentially enable information disclosure or denial of service via local access.

    Severity: 8.4 | HIGH

    Visit the link for more details, such as CVSS details, affected products, timeline, and more…

    CVE-2025-52552 – FastGPT Open Redirect and DOM-Based XSS Vulnerability

    June 21, 2025

    id Software is updating DOOM: The Dark Ages’ difficulty because you said itwastooeasy

    May 26, 2025

    CVE-2025-52902 – Apache File Browser Stored XSS Vulnerability

    June 26, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.