Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement page.on('request') #4281

Open
ankur22 opened this issue Jan 24, 2025 · 0 comments
Open

Implement page.on('request') #4281

ankur22 opened this issue Jan 24, 2025 · 0 comments

Comments

@ankur22
Copy link
Contributor

ankur22 commented Jan 24, 2025

Feature Description

What

We want to implement page.on('request'). More details of the API can be found here. The request object that is returned to the handler is detailed here. This is a read only API, and no modifications can be done on the request object. k6 browser should not wait for a response from the handler, it fire and forgets.

Why

Users have asked to be able to read the requests that are being sent out from chromium to the website under test. This can be helpful in validating/asserting certain aspects of the request which could be important for the test to be deemed successful.

Comments

While testing the Playwright implementation i noticed that some of the methods on the request object are async. An example of this is data.response():

    page.on('request', async (data) => {
      console.log("url: " + data.url());
      if (data.url() === "https://quickpizza.grafana.com/api/quotes") {
        console.log(await data.response());
      }
    })

What's interesting about this is that the call to data.response() will in fact wait until a response is received. The current implementation of response on the request object does not fulfil this behaviour and we will need to change that too.

Async methods on request that will need to be checked to see if they behave the same as in PW:

Suggested Solution (optional)

No response

Already existing or connected issues / PRs (optional)

No response

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

No branches or pull requests

1 participant