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

      CodeSOD: A Unique Way to Primary Key

      July 22, 2025

      BrowserStack launches Figma plugin for detecting accessibility issues in design phase

      July 22, 2025

      Parasoft brings agentic AI to service virtualization in latest release

      July 22, 2025

      Node.js vs. Python for Backend: 7 Reasons C-Level Leaders Choose Node.js Talent

      July 21, 2025

      The best CRM software with email marketing in 2025: Expert tested and reviewed

      July 22, 2025

      This multi-port car charger can power 4 gadgets at once – and it’s surprisingly cheap

      July 22, 2025

      I’m a wearables editor and here are the 7 Pixel Watch 4 rumors I’m most curious about

      July 22, 2025

      8 ways I quickly leveled up my Linux skills – and you can too

      July 22, 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

      The Intersection of Agile and Accessibility – A Series on Designing for Everyone

      July 22, 2025
      Recent

      The Intersection of Agile and Accessibility – A Series on Designing for Everyone

      July 22, 2025

      Zero Trust & Cybersecurity Mesh: Your Org’s Survival Guide

      July 22, 2025

      Execute Ping Commands and Get Back Structured Data in PHP

      July 22, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      A Tomb Raider composer has been jailed — His legacy overshadowed by $75k+ in loan fraud

      July 22, 2025
      Recent

      A Tomb Raider composer has been jailed — His legacy overshadowed by $75k+ in loan fraud

      July 22, 2025

      “I don’t think I changed his mind” — NVIDIA CEO comments on H20 AI GPU sales resuming in China following a meeting with President Trump

      July 22, 2025

      Galaxy Z Fold 7 review: Six years later — Samsung finally cracks the foldable code

      July 22, 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. No Aspect Automated Testing Manual Testing
    1 Speed Fast (runs in CI/CD) Slower (human verification)
    2 Coverage Broad (static checks) Deep (dynamic interactions)
    3 False Positives Possible (needs tuning) Minimal (human judgment)
    4 Best For Early-stage checks Real-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

    GPT-5 is Coming: Revolutionizing Software Testing

    July 22, 2025
    Development

    Win the Accessibility Game: Combining AI with Human Judgment

    July 22, 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

    CVE-2025-5703 – “WordPress StageShow Stored Cross-Site Scripting Vulnerability”

    Common Vulnerabilities and Exposures (CVEs)

    CVE-2025-20976 – Samsung Notes Out-of-Bounds Read Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    Elon Musk’s X might have a mole problem: “How could someone enumerate all Twitter user IDs, unless they were an employee?”

    News & Updates

    Critical 9.8 CVSS Flaw: Unpatched PayU CommercePro Plugin Allows Admin Account Takeover!

    Security

    Highlights

    Development

    Building a Task Reminder With Laravel and MongoDB

    June 24, 2025

    Freshly created Laravel applications are configured to use relational databases. The purpose of this tutorial…

    How To Improve Website Performance

    May 6, 2025

    CVE-2025-34029 – Edimax EW-7438RPn Mini OS Command Injection

    June 20, 2025

    Operation DRAGONCLONE: China Mobile Tietong Hit by Advanced APT Attack

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

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