Search code examples
playwrightplaywright-test

Playwright not replaying requests


I have the following playwright test which is recording/replaying a request:

NOT WORKING

test('replay test', async ({page}) => {

    await page.routeFromHAR('playwright/har/har.zip', {
        update: false,
        url: '**/Time/**'
    });

    const dt = await page.request.get('https://timeapi.io/api/Time/current/zone?timeZone=Europe/Zurich')

    // print out recorded/replayed datetime
    console.log((await dt.json()).dateTime)

});


if this test runs and the recording is enabled with update: true then the request ist recorded correctly. But after disabling the recording with update: false the recorded stub is not replayed.

But if i change the example to the following code, which uses just page.goto everything is working as expected.

WORKING

test('replay test', async ({page}) => {

    await page.routeFromHAR('playwright/har/har.zip', {
        update: false,
        url: '**/Time/**'
    });

    const dt = await page.goto('https://timeapi.io/api/Time/current/zone?timeZone=Europe/Zurich')

    // print out recorded/replayed datetime
    console.log((await dt.json()).dateTime)

});

Why are the requests with page.request.getrecorded but not replayed?

PS: In my real test i have some page.request.put and page.request.post requests i need to record. And the behaviour is exactly the same.


Solution

  • It seems this i a known Bug in Playwright. There is already an existing issue: https://github.com/microsoft/playwright/issues/22869

    If you have the same problem, it would be nice to let them know and comment/subscribe to the issue.