Rayrun
← Back to Discord Forum

page.evaluate: Execution context was destroyed, most likely because of a navigation

import { TestInfo, test } from '@playwright/test';
import AxeBuilder from '@axe-core/playwright';

test.describe('ClientPricingDashboard', () => {
  test('navigation menu should not have automatically detectable accessibility violations', async ({
    page,
  }, testInfo: TestInfo) => {
    await page.goto('http://localhost:4200/#/login?returnUrl=http:%2F%2Flocalhost:4200%2F%23%2Fbuyer-assist%2Fclient-pricing%2Fpricing');
    await page.getByPlaceholder('Username').click();
    await page.getByPlaceholder('Username').fill('[email protected]');
    await page.getByRole('button', { name: 'Next' }).click();
    await page.getByPlaceholder('Password').fill('test');
    await page.getByPlaceholder('Password').press('Enter');

    await page.waitForURL('http://localhost:4200/#/buyer-assist/client-pricing/pricing');

    test.slow();

    const frame = await page.frame({ name: 'contentFrame' });

    await frame?.waitForSelector('table');

    const accessibilityScanResults = await new AxeBuilder({ page })
      .withTags(['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa'])
      .include('#contentFrame')
      .exclude('hmx-sidebar')
      .analyze();

    await testInfo.attach('accessibility-scan-results', {
      body: JSON.stringify(accessibilityScanResults, null, 2),
      contentType: 'application/json',
    });
  });
});

This thread is trying to answer question "Why am I getting an 'Execution context was destroyed, most likely because of a navigation' error when trying to scan a page for accessibility issues using Playwright?"

1 reply

The application is loaded inside of an Iframe. My goal is to scan the page and find all accessibility issues. I am new to playwright and I am not sure what i am doing wrong, please help me

Related Discord Threads

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].