Skip to content

Commit 3101979

Browse files
committed
browser: Add page on response
1 parent 8a0d548 commit 3101979

File tree

1 file changed

+9
-6
lines changed
  • docs/sources/k6/next/javascript-api/k6-browser/page

1 file changed

+9
-6
lines changed

docs/sources/k6/next/javascript-api/k6-browser/page/on.md

+9-6
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ Registers a handler to be called whenever the specified event occurs.
1414

1515
### Events
1616

17-
| Event | Description |
18-
| --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
19-
| `console` | Emitted every time the console API methods are called from within the page JavaScript context. The arguments passed into the handler are defined by the [`ConsoleMessage`](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/consolemessage) class. See the [example](#console-event-example). |
20-
| `metric` | Emitted every time a metric is measured and emitted for the page. The arguments passed into the handler are defined by the [`MetricMessage`](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/metricmessage) object. See the [example](#metric-event-example). |
21-
| `request` | Emitted every time a request made by the page. The handler gets a [`Request`](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/request) object that contains information about the request. See the [example](#request-event-example). |
17+
| Event | Description |
18+
| ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
19+
| `console` | Emitted every time the console API methods are called from within the page JavaScript context. The arguments passed into the handler are defined by the [`ConsoleMessage`](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/consolemessage) class. See the [example](#console-event-example). |
20+
| `metric` | Emitted every time a metric is measured and emitted for the page. The arguments passed into the handler are defined by the [`MetricMessage`](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/metricmessage) object. See the [example](#metric-event-example). |
21+
| `request` | Emitted every time a request made by the page. The handler gets a [`Request`](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/request) object that contains information about the request. See the [example](#request-and-response-events-example). |
22+
| `response` | Emitted every time a response is received by the page. The handler gets a [`Response`](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/response) object that contains information about the response. See the [example](#request-and-response-events-example). |
2223

2324
### Console event example
2425

@@ -126,7 +127,7 @@ export default async function () {
126127

127128
{{< /code >}}
128129

129-
### Request event example
130+
### Request and response events example
130131

131132
{{< code >}}
132133

@@ -151,6 +152,8 @@ export default async function () {
151152

152153
// registers a handler that logs all requests made by the page
153154
page.on('request', async (request) => console.log(request.url()));
155+
// registers a handler that logs all responses received by the page
156+
page.on('response', async (response) => console.log(response.url()));
154157

155158
await page.goto('https://quickpizza.grafana.com/', { waitUntil: 'networkidle' });
156159
await page.close();

0 commit comments

Comments
 (0)