Docs
Dashboard
Examples / QualityBeta

Accessibility check

Run the axe-core accessibility scan on a page in the session's browser and list the issues, worst first. The shell fetches axe-core inside the machine; Playwright runs it in the page.

When to use it: You want an automated accessibility scan of your own pages.

Usesexec (curl), files.readText, Playwright over CDP (evaluate)
Needsa plan with shell sessions; no model
Siteyour page; the default is books.toscrape.com. The runner uses its stand-in page (an image without alt text, a field without a label, a button without a name)
Outputoutput/issues.json
LanguagesNode and Python

The code

The example as it is in its folder. Both versions do the same job and write the same output/, so one result check covers both.

/** * Accessibility check: run the axe-core scan on a page in the session's browser and list the issues, worst first. * The shell fetches axe-core (inside the machine); Playwright runs it in the page. * *   npx tsx node/index.ts            (BOXLINE_API_KEY; PAGE_URL for your own page; a plan with shell sessions) * * Writes output/issues.json. */import { mkdirSync, writeFileSync } from "node:fs";import { join } from "node:path";import { Boxline } from "@boxline/sdk";import { chromium } from "playwright-core";const out = process.env.OUTPUT_DIR ?? "output";const url = process.env.PAGE_URL ?? "https://books.toscrape.com/";const AXE = "https://cdn.jsdelivr.net/npm/axe-core@4.10.2/axe.min.js";const bx = new Boxline();interface Violation {  id: string;  impact: "critical" | "serious" | "moderate" | "minor";  help: string;  helpUrl: string;  nodes: { target: string[] }[];}const session = await bx.sessions.create({ shell: true, timeout: 300, userMetadata: { example: "accessibility-check" } });console.log(`Session: ${session.id}`);const browser = await chromium.connectOverCDP(session.connectUrl!);try {  // 1. The shell downloads axe-core into the workspace; the files API hands its source to this script.  const dl = await session.exec(`curl -sSfL --max-time 60 -o axe.min.js ${AXE}`);  if (dl.exitCode !== 0) throw new Error(`could not download axe-core: ${dl.stderr.trim()}`);  const axeSource = await session.files.readText("axe.min.js");  // 2. The browser opens the page and runs the scan in it.  const page = browser.contexts()[0]!.pages()[0]!;  await page.goto(url, { waitUntil: "load" });  await page.evaluate(axeSource);  const violations = (await page.evaluate("axe.run().then((r) => r.violations)")) as Violation[];  const order = { critical: 0, serious: 1, moderate: 2, minor: 3 };  const issues = violations    .map((v) => ({ id: v.id, impact: v.impact, count: v.nodes.length, help: v.help, helpUrl: v.helpUrl, where: v.nodes.slice(0, 5).map((n) => n.target.join(" ")) }))    .sort((a, b) => order[a.impact] - order[b.impact]);  console.log(`${issues.length} kinds of issue on ${page.url()}:`);  for (const i of issues) console.log(`  ${i.impact.padEnd(8)} ${i.id} (${i.count}): ${i.help}`);  mkdirSync(out, { recursive: true });  writeFileSync(join(out, "issues.json"), JSON.stringify(issues, null, 2));  writeFileSync(join(out, "result.json"), JSON.stringify({ url, axe: AXE, issues }, null, 2));} finally {  await session.stop();  await browser.close().catch(() => undefined);}

Inputs

Environment variables the example reads:

  • PAGE_URL: the page to scan (default https://books.toscrape.com/).

Run it

Get the examples with git clone https://github.com/Boxline-dev/examples.git and open this one: cd examples/accessibility-check. Put your API key in BOXLINE_API_KEY (and BOXLINE_API_URL for another API), then run either version from the example’s folder. Both write to output/ and stop their sessions when they finish.

# Node 18 or newer, in the example's folderexport BOXLINE_API_KEY=…   # your API keynpm install @boxline/sdk playwright-core tsxnpx tsx node/index.ts

Then check the result, from the same folder: npx tsx check.ts output. It exits with 0 only when the result is right.

What its check proves

check.ts reads what the example wrote and passes only when the result is right, not merely when the example ran.

The issues are sorted worst first; on the stand-in, image-alt, label and button-name are found, critical first.

Source

github.com/Boxline-dev/examples/accessibility-check on GitHub, with its README.md, check.ts and .env.example. The examples are open source. See all examples.

These docs describe a beta API. Endpoints, fields and SDK methods may change before general availability; breaking changes will be listed in the changelog.