Rayrun
← Back to Discord Forum

page.waitForLoadState: Navigation failed because page was closed! Ts error

Hi, we did the migration from js to ts and after that all our ui tests became flucky or failing. We did not have problems with js files. On ts we receive

page.waitForLoadState: Navigation failed because page was closed!

We have pretty common workflow

async view(): Promise<void> {
    await test.step(`Load page: ${this.fullUrl}`, async () => {
      await this.page.goto(this.fullUrl);
      await this.page.waitForLoadState('networkidle');
    });
  }

I have also tried

await this.page.goto(this.fullUrl, { waitUntil: 'networkidle' });

Nothing helps me on ci/cd

Version for playwright 1.35.1 and 1.36.2, both give me same error

This thread is trying to answer question "Why am I receiving a 'Navigation failed because page was closed!' error when using the 'page.waitForLoadState' function in TypeScript after migrating from JavaScript?"

6 replies

I’d suggest check for any explicit or implicit page closures. Then also if you haven’t already debug it with tracing

Unrelated to the question, networkidle is discouraged: https://playwright.dev/docs/next/api/class-frame#frame-wait-for-load-state

I rechecked, the problem is in the docker only

Do you use the playwright docker image?

yes, I use image: mcr.microsoft.com/playwright

Other thoughts

Does the docker container have enough resources? Have you adjusted the browser sandbox settings?

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 luc@ray.run.