docs: add more detail to waitForNavigation API method (#3635)

This commit is contained in:
Blake Williams 2020-08-26 00:05:27 -04:00 committed by GitHub
parent 25381cfa43
commit 5f86253ad4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1935,12 +1935,12 @@ Shortcut for [page.mainFrame().waitForLoadState([options])](#framewaitforloadsta
- returns: <[Promise]<[null]|[Response]>> Promise which resolves to the main resource response. In case of multiple redirects, the navigation will resolve with the response of the last redirect. In case of navigation to a different anchor or navigation due to History API usage, the navigation will resolve with `null`.
This resolves when the page navigates to a new URL or reloads. It is useful for when you run code
which will indirectly cause the page to navigate. Consider this example:
which will indirectly cause the page to navigate. e.g. The click target has an `onclick` handler that triggers navigation from a `setTimeout`. Consider this example:
```js
const [response] = await Promise.all([
page.waitForNavigation(), // The promise resolves after navigation has finished
page.click('a.my-link'), // Clicking the link will indirectly cause a navigation
page.click('a.delayed-navigation'), // Clicking the link will indirectly cause a navigation
]);
```