playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[BUG] Different response code recorded in Playwright and Browser DevTools

Open jaktestowac opened this issue 1 year ago • 2 comments
trafficstars

While using page.waitForResponse() response status is logged as 200, and in DevTools there is 304 (test run with VSC extension Browser and DevTools enabled) in console obraz in browser obraz

System info

  • Playwright Version: [v1.40.1]
  • Operating System: [Windows 11]
  • Browser: [Chromium]
  • Other info: VSC with plugin Playwright Test for VSCode 1.0.20

Source code

import { test, expect } from '@playwright/test';

test('test 304', async ({page}) => {
  const response200 = page.waitForResponse(
    (response) => {
      console.log( response.status(), response.url() );
      return response.url() ===  'https://automationintesting.online/'
    }
  );

  await page.goto('https://automationintesting.online/');
  expect((await response200).status()).toBe(200);
  
  const response304 = page.waitForResponse(
    (response) => {
      console.log( response.status(), response.url() );
      return response.url() ===  'https://automationintesting.online/'
    }
  );

  await page.reload();
  expect((await response304).status()).toBe(304);
  
});

Steps

  • Enable option in VSC in Testing Show browser
  • Open browser (run any test form VSC plugin)
  • Open DevTools in Browser and go to Network tab
  • Run the test test 304
  • Compare console log response status with same request in DevTools Network for https://automationintesting.online/

Expected Same response code

Actual Different response codes: 200 logged by page.waitForResponse() 304 in DevTools

jaktestowac avatar Dec 23 '23 06:12 jaktestowac

We are reverting the best effort fix due to regression https://github.com/microsoft/playwright/issues/29441. Some more details: the network stack in Chromium receives 304 response, but Blink receives 200 and we return what Blink code sees. This also allows us to return (cached) response body as the server's 304 response does not contain body. One non-breaking way to fix this could be to expose actual network status in a separate method (e.g. networkStatus).

yury-s avatar Feb 13 '24 19:02 yury-s

@yury-s thank you for the update and for making a thoughtful decision. I look forward to the next steps. 👁️

jaktestowac avatar Feb 14 '24 05:02 jaktestowac

Why was this issue closed?

Thank you for your contribution to our project. This issue has been closed due to its limited upvotes and recent activity, and insufficient feedback for us to effectively act upon. Our priority is to focus on bugs that reflect higher user engagement and have actionable feedback, to ensure our bug database stays manageable.

Should you feel this closure was in error, please create a new issue and reference this one. We're open to revisiting it given increased support or additional clarity. Your understanding and cooperation are greatly appreciated.

pavelfeldman avatar Aug 16 '24 00:08 pavelfeldman