Usage with WebdriverIO
WebdriverIO is a Node.js test automation framework built on the WebDriver protocol, supporting both end-to-end and component testing. surea11y integrates through the @surea11y/webdriverio binding.
$ npm install @surea11y/webdriverio webdriverio
WebdriverIO v9 auto-manages a local chromedriver the first time it launches Chrome — a fresh install is enough to launch a real headless Chrome on its own.
const { remote } = require('webdriverio');const { A11yCoreBuilder } = require('@surea11y/webdriverio');const browser = await remote({capabilities: {browserName: 'chrome','wdio:enforceWebDriverClassic': true, // recommended -- see below'goog:chromeOptions': { args: ['--headless=new'] }}});await browser.url('https://example.com/');const results = await new A11yCoreBuilder({ browser }).include('#main') // optional -- call multiple times for multi-region scans.exclude('.cookie-banner') // optional.withTags(['wcag2a', 'wcag2aa']).disableRules(['meta-refresh-no-exceptions']).analyze();console.log(results.checksResults.filter(r => r.outcome === 'fail'));await browser.deleteSession();
Force classic WebDriver, not BiDi, for this workload. WebdriverIO v9 defaults to the BiDi protocol; a long-lived session issuing many browser.execute() calls (exactly what a scan does) degraded badly over BiDi in testing — per-scan latency climbed from ~2s into the minutes. Forcing classic WebDriver with 'wdio:enforceWebDriverClassic': true, as shown above, gave a steady ~150ms per scan.
Also see a runnable example in the package's own repo.
Next: choose which rules run, integrate the scan into CI, and review the full result schema.