Audit from alfa-act & input directly from Puppeteer - possible? #736
Answered
by
kasperisager
BogdanCerovac
asked this question in
Questions
-
Hi, and am wondering if we can maybe use audit directly on Puppeteers page/content? So by not using chai and mocha, but passing Puppeteer content (page / raw HTML) directly to Audit (input)? For example: (async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://example.com');
// await page.screenshot({ path: 'example.png' });
const pageContStr = await page.content();
/* probably some transformation from string to json */
const outcomes = await Audit.of(pageContJson, rules).evaluate();
await browser.close();
})(); |
Beta Was this translation helpful? Give feedback.
Answered by
kasperisager
Mar 4, 2021
Replies: 1 comment 6 replies
-
Hi there! You can absolutely do that, yes: import { Puppeteer } from "@siteimprove/alfa-puppeteer";
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://example.com');
const handle = await page.evaluateHandle(() => window.document);
const outcomes = await Audit.of(await Puppeteer.toPage(handle), rules).evaluate();
await browser.close(); In fact, the Puppeteer example you linked does effectively the same thing right here: https://github.com/Siteimprove/alfa-examples/blob/ead4b79932f33135df718ef20d43e0e0f69203af/end-to-end-testing/puppeteer/test/page.spec.ts#L15 |
Beta Was this translation helpful? Give feedback.
6 replies
Answer selected by
BogdanCerovac
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi there! You can absolutely do that, yes:
In fact, the Puppeteer example you linked does effectively the same thing right here: https://github.com/Siteimprove/alfa-examples/blob/ead4b79932f33135df718ef20d43e0e0f69203af/end-to-end-testing/puppeteer/test/page.spec.ts#L15