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 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
await driver.get("http://localhost:8080");
// Get the driver and turn it into a page representation that the Code Checker can work with
const alfaPage = await Selenium.toPage(driver);
// Run an accessiblity audit
const alfaResult = await Audit.run(alfaPage);
// Log the result of the audit
Logging.fromAudit(alfaResult).print();
await driver.quit();