I’m getting the error “page.evaluate: Execution context was destroyed, most likely because of a navigation”. This is happening using Light-Playwright for performance testing.
here’s the actual code:
import { expect, test } from '@playwright/test';
import playwright from 'playwright';
import { audit } from '../utils/audit';
test.describe('Top 20 sites', () => {
test(`Ligthouse User Journey performance test`, async () => {
test.slow();
const browser = await playwright['chromium'].launch({
args: ['--remote-debugging-port=9222'],
});
const page = await browser.newPage();
await page.goto('https://www.google.com');
await page.getByRole('button', { name: 'Find Hotels' }).click();
// const context = await browser.newContext();
// Create a new page in a pristine context.
const results = await audit(page, 'userFlow')
await page.close();
await browser.close();
// expect(results.lhr.categories.performance.score, `${'https://www.marriott.com/default.mi'} fell below the minimum threshold`).toBeGreaterThanOrEqual(.30);
});
});
It fails on the playAudit because the page has changed as a result of the click action. How do I grab the new page after the navigation completes. I’ve tried doing a new page context to no avail.