Skip to content

[Feature] route handler to support redirects #3993

@tjenkinson

Description

@tjenkinson

Context:

  • Playwright Version: 1.4.2
  • Operating System: Mac
  • Node.js version: 14.12.0
  • Browser: All

Code Snippet

const playwright = require('playwright');

(async () => {
  for (const browserType of ['chromium', 'firefox', 'webkit']) {
    const browser = await playwright[browserType].launch({ headless: true });
    const context = await browser.newContext();
    const page = await context.newPage();

    let seenRequest = false;
    page.route('**', (route) => {
      const url = route.request().url();
      if (url.includes('account.bbc.com')) {
        seenRequest = true;
      }
      route.continue();
    });

    await page.goto('https://www.bbc.co.uk/');
    await page.click('"Sign in"');
    await page.waitForRequest(/account\.bbc\.com/);
    if (!seenRequest) {
      console.error('Did not see request');
    }
    await browser.close();
  }
})();

Describe the bug

When clicking 'sign in' there is a 302 redirect from https://session.bbc.co.uk/session to https://account.bbc.com/.

It looks like the handler is not called again with the new url on the redirect.

The docs say:

If request gets a 'redirect' response, the request is successfully finished with the 'requestfinished' event, and a new request is issued to a redirected url.

So I'm expecting the handler to be called again with the new url.

I'm expecting "Did not see request" not to be logged in my example, but it is.

Metadata

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