I am looking to make assertions on the DOM once I open the printer dialog option on a PDFjs page
What I am looking to do:
- Load the page (https://mozilla.github.io/pdf.js/web/viewer.html)
- Wait for the
.page
class divs to load (waitFor({ state: 'attached' }
) - Click the Print button
- Assert that there are now
.printedPage
divs that are a count greater than 0
Currently I am getting to a state where, after I click the Print button, it times out waiting for the .printedPage
divs to have an attached state
Code I am running:
import { test, expect } from '@playwright/test';
test('page has print button', async ({ page }) => {
await page.goto('https://mozilla.github.io/pdf.js/web/viewer.html');
await page.locator('.page').first().waitFor({ state: 'attached' });
const printBtn = page.locator('#print');
const printContainer = page.locator('#printContainer');
await expect(page.locator('.page')).not.toHaveCount(0);
await expect(printBtn).toHaveAttribute('title','Print');
await expect(printContainer).toBeEmpty();
await printBtn.click();
await page.locator('.printedPage').first().waitFor({ state: 'attached' });
await expect(page.locator('.printedPage')).not.toHaveCount(0);
});
Any guidance would be appreciated