Skip to content

Commit 3b49dfe

Browse files
inancgumusschalksnyman
authored andcommitted
Async frame.waitForNavigation
1 parent c6d9886 commit 3b49dfe

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: 'waitForNavigation([options])'
3+
description: 'Browser module: frame.waitForNavigation([options]) method'
4+
---
5+
6+
# waitForNavigation([options])
7+
8+
Waits for the given navigation lifecycle event to occur and returns the main resource response.
9+
10+
<TableWithNestedRows>
11+
12+
| Parameter | Type | Default | Description |
13+
| ----------------- | ------ | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
14+
| options | object | `null` | |
15+
| options.timeout | number | `30000` | Maximum time in milliseconds. Pass `0` to disable the timeout. Default is overridden by the `setDefaultTimeout` option on [BrowserContext](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/browsercontext/) or [Page](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/page/). |
16+
| options.waitUntil | string | `load` | When to consider operation to have succeeded. See [Events](#events) for more details. |
17+
18+
</TableWithNestedRows>
19+
20+
### Events
21+
22+
{{% admonition type="caution" %}}
23+
24+
`networkidle` is DISCOURAGED. Don't use this method for testing especially with chatty websites where the event may never fire, rely on web assertions to assess readiness instead.
25+
26+
{{% /admonition %}}
27+
28+
Events can be either:
29+
30+
- `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
31+
- `'load'` - consider operation to be finished when the `load` event is fired.
32+
- `'networkidle'` - Consider operation to be finished when there are no network connections for at least `500` ms.
33+
34+
### Returns
35+
36+
| Type | Description |
37+
| --------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
38+
| Promise<null \| [Response](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/response/)> | The `Response` instance associated with the frame. Else, it returns `null` |

0 commit comments

Comments
 (0)