docs(api.md): add explanation to page.waitForNavigation (#2354)

Fixes #1860
This commit is contained in:
Andrey Lushnikov 2018-04-26 13:32:40 -07:00 committed by GitHub
parent eded38c82a
commit f797f8c307
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1404,6 +1404,17 @@ Shortcut for [page.mainFrame().waitForFunction(pageFunction[, options[, ...args]
- `networkidle2` - consider navigation to be finished when there are no more than 2 network connections for at least `500` ms.
- returns: <[Promise]<[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.
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:
```js
const navigationPromise = page.waitForNavigation();
await page.click('a.my-link'); // Clicking the link will indirectly cause a navigation
await navigationPromise; // The navigationPromise resolves after navigation has finished
```
**NOTE** Usage of the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) to change the URL is considered a navigation.
#### page.waitForSelector(selector[, options])
- `selector` <[string]> A [selector] of an element to wait for
- `options` <[Object]> Optional waiting parameters