Skip to content

Instantly share code, notes, and snippets.

validate a complex pdf using Playwright
import {test, expect} from '@playwright/test';
test('validate a complex pdf II, all pages', async ({page}) => {
const numberOfPages = 2;
for (let i = 1; i < numberOfPages + 1; i += 1) {
let pdfResource =
'https://oedtrngbj.wpengine.com/wp-content/uploads/Powerwall_2_AC_Datasheet_EN_NA.pdf';
let iframe = `<iframe src="${pdfResource}#zoom=60&page=${i}" style="width: 100%;height:100%;border: none;"></iframe>`;
await page.setContent(iframe);
await page.waitForTimeout(5000);
expect(await page.locator('iframe').screenshot()).toMatchSnapshot({
name: `pdf_validation_page_${i}.png`,
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment