Skip to content

[BUG] HTML response is null on requestfinished when opening popup #5542

Closed

Description

Context:

  • Playwright Version: 1.8.1
  • Operating System: Linux 5.4 KDE neon 5.21
  • Node.js version: v14.15.5
  • Browser: All
  • Extra:
$ npx envinfo --preset playwright

  System:
    OS: Linux 5.4 KDE neon 5.21
    Memory: 3.68 GB / 15.56 GB
    Container: Yes
  Binaries:
    Node: 14.15.5 - /usr/bin/node
    Yarn: 1.22.5 - /usr/bin/yarn
    npm: 6.14.11 - /usr/bin/npm
  Languages:
    Bash: 5.0.17 - /usr/bin/bash
  npmPackages:
    playwright: 1.x => 1.8.1 

Code Snippet

"use strict";

import { chromium, firefox, webkit } from "playwright";

(async () => {
  const browser = await chromium.launch({
    headless: false,
    devtools: true,
  });
  const context = await browser.newContext();

  context.on("page", (page) => {
    page.on("requestfinished", (req) => {
      (async () => {
        const res = await req.response();

        if (res === null /* || 400 <= res?.status() */) {
          console.error(`No response returned at ${req.url()}`);
        }
      })();
    });
  });

  const page = await context.newPage();
  await page.goto("https://www.dropbox.com/login");
  await page.click(".auth-google");

  // await browser.close();
})();

Describe the bug

I'm trying to open a popup window and check if any requests failed.
As above code snippet, I add context.on("page", ...) event listener and attach page.on("requestfinished", ...) event listener when page is created.

However, in the requestfinished event of the HTML request (in the above code snippet, https://accounts.google.com/o/oauth2/auth/oauthchooseaccount...), await req.response() returns null.
I checked the browser window and devtools' console by adding headless: false and devtools: true option, but the HTML seems loaded properly.

I guess this happens only for the pages opened by the popup windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions