Using with Selenium
See and use a fully working example in the Alfa examples repository.
The following code sets up a Selenium automation script and runs an accessibility audit using the Accessibility Code Checker. The result is logged to the console.
import { Selenium } from "@siteimprove/alfa-selenium";
import { Browser, Builder } from "selenium-webdriver";
import { Audit, Logging } from "@siteimprove/alfa-test-utils";
// Set up web driver for chrome browser.
const driver = await new Builder().forBrowser(Browser.CHROME).build();
// Navigate to the page to audit.
// This supposes that the server is already running.
// TODO: Replace with your own page
await driver.get("http://localhost:8080");
// Get the driver and scrape the page.
const alfaPage = await Selenium.toPage(driver);
// Run an accessibility audit.
const alfaResult = await Audit.run(alfaPage);
// Log the result of the audit.
Logging.fromAudit(alfaResult).print();
await driver.quit();