Skip to content

[Feature] routeFromHar should also apply to apiRequestContext #22869

Closed

Description

@stkevintan

Let us know what functionality you'd like to see in Playwright and what your use case is.
Do you think others might benefit from this as well?

Currently for routeFromHar
If we turn on the option update , it will record all the requests in side browserContext including apiRequestContext into har file.

However, when we turn off, it intercepts all the requests except apiRequestContext.

It is not symmetrical and makes trouble for teams which need fully simulation on the network in both browser side and node side.

Did some investigation:
when recording har, this PR #11502 added the apiRequestContext into trace
when replaying har, Playwright is done by the Fetch domain of chrome devtool protocol, but apiRequestContext is implemented by native http(s) module of nodejs, which obviously cannot be mainipulated by CDP events.

Activity

  1. thomasrepnik commented on Jul 25, 2023

    @thomasrepnik

    We have actually the same problem, which makes playwright unusuable for certain tests.
    We need to make some PUT call prior to the test, which needs to be recorded and replayed. The recording works, but the request is never replayed.

    //This request is getting recorded but never replayed
    const putResponse= await page.request.put('http://some.url/v1/testdata', {
            data: {
                isManager: false
            }
        })
    
    const putResponseBody= await putResponse.json();
    
    //Here we need the ID of the recorded request in order to proceed with the test
    await page.goto(`http://some.url#some-location=%2Fusermanagement%2F${putResponseBody.userId}`);
    
    
  2. pavelfeldman commented on Apr 22, 2024

    @pavelfeldman
    Member

    Why was this issue closed?

    Thank you for your involvement. This issue was closed due to limited engagement (upvotes/activity), lack of recent activity, and insufficient actionability. To maintain a manageable database, we prioritize issues based on these factors.

    If you disagree with this closure, please open a new issue and reference this one. More support or clarity on its necessity may prompt a review. Your understanding and cooperation are appreciated.

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

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions