Take a fullpage screenshot with Playwright

Published on 03-01-2023

import { test } from '@playwright/test';

const websites = [
	{
		name: 'linear.app',
		url: 'https://linear.app/integrations'
	}
];

let date = new Date().toISOString().slice(0, 10);

websites.forEach(async (website) => {
	test(`Capture screenshot of ${website.url}`, async ({ page }) => {
		await page.goto(website.url, { waitUntil: 'networkidle' });
		for (const image of await page.getByRole('img').all()) await image.waitFor();
		await page.screenshot({
			path: `screenshots/${date} ${website.name}.png`,
			fullPage: true,
			animations: 'disabled'
		});
	});
});