api: remove 'commit' phase, actions to wait until 'domcontentloaded' by default (#1358)

This commit is contained in:
Dmitry Gozman 2020-03-12 11:20:03 -07:00 committed by GitHub
parent 7c59f9ca9a
commit e382bb329b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 156 additions and 151 deletions

View file

@ -921,10 +921,9 @@ Shortcut for [page.mainFrame().addStyleTag(options)](#frameaddstyletagoptions).
- is not moving (for example, waits until css transition finishes),
- receives pointer events at the action point (for example, waits until element becomes non-obscured by other elements).
Even if the action is forced, it will wait for the element matching selector to be in DOM. Defaults to `false`.
- `waitUntil` <"commit"|"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to `commit` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'commit'` - navigation is committed, new url is displayed in the browser address bar.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to fire `domcontentloaded` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'domcontentloaded'` - consider navigation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `'networkidle0'` - consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.
- `'networkidle2'` - consider navigation to be finished when there are no more than 2 network connections for at least `500` ms.
- `'nowait'` - do not wait.
@ -951,10 +950,9 @@ Shortcut for [page.mainFrame().check(selector[, options])](#framecheckselector-o
- is not moving (for example, waits until css transition finishes),
- receives pointer events at the action point (for example, waits until element becomes non-obscured by other elements).
Even if the action is forced, it will wait for the element matching selector to be in DOM. Defaults to `false`.
- `waitUntil` <"commit"|"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to `commit` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'commit'` - navigation is committed, new url is displayed in the browser address bar.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to fire `domcontentloaded` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'domcontentloaded'` - consider navigation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `'networkidle0'` - consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.
- `'networkidle2'` - consider navigation to be finished when there are no more than 2 network connections for at least `500` ms.
- `'nowait'` - do not wait.
@ -1010,10 +1008,9 @@ Browser-specific Coverage implementation, only available for Chromium atm. See [
- is not moving (for example, waits until css transition finishes),
- receives pointer events at the action point (for example, waits until element becomes non-obscured by other elements).
Even if the action is forced, it will wait for the element matching selector to be in DOM. Defaults to `false`.
- `waitUntil` <"commit"|"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to `commit` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'commit'` - navigation is committed, new url is displayed in the browser address bar.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to fire `domcontentloaded` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'domcontentloaded'` - consider navigation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `'networkidle0'` - consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.
- `'networkidle2'` - consider navigation to be finished when there are no more than 2 network connections for at least `500` ms.
- `'nowait'` - do not wait.
@ -1188,10 +1185,9 @@ const fs = require('fs');
- `selector` <[string]> A selector to query page for.
- `value` <[string]> Value to fill for the `<input>`, `<textarea>` or `[contenteditable]` element.
- `options` <[Object]>
- `waitUntil` <"commit"|"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to `commit` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'commit'` - navigation is committed, new url is displayed in the browser address bar.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to fire `domcontentloaded` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'domcontentloaded'` - consider navigation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `'networkidle0'` - consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.
- `'networkidle2'` - consider navigation to be finished when there are no more than 2 network connections for at least `500` ms.
- `'nowait'` - do not wait.
@ -1238,10 +1234,9 @@ Returns frame matching the specified criteria. Either `name` or `url` must be sp
#### page.goBack([options])
- `options` <[Object]> Navigation parameters which might have the following properties:
- `timeout` <[number]> Maximum navigation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultNavigationTimeout(timeout)](#browsercontextsetdefaultnavigationtimeouttimeout), [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout), [page.setDefaultNavigationTimeout(timeout)](#pagesetdefaultnavigationtimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
- `waitUntil` <"commit"|"load"|"domcontentloaded"|"networkidle0"|"networkidle2"> When to consider navigation succeeded, defaults to `load`. Events can be either:
- `'commit'` - navigation is committed, new url is displayed in the browser address bar.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle0"|"networkidle2"> When to consider navigation succeeded, defaults to `load`. Events can be either:
- `'domcontentloaded'` - consider navigation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `'networkidle0'` - consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.
- `'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. If
@ -1252,10 +1247,9 @@ Navigate to the previous page in history.
#### page.goForward([options])
- `options` <[Object]> Navigation parameters which might have the following properties:
- `timeout` <[number]> Maximum navigation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultNavigationTimeout(timeout)](#browsercontextsetdefaultnavigationtimeouttimeout), [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout), [page.setDefaultNavigationTimeout(timeout)](#pagesetdefaultnavigationtimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
- `waitUntil` <"commit"|"load"|"domcontentloaded"|"networkidle0"|"networkidle2"> When to consider navigation succeeded, defaults to `load`. Events can be either:
- `'commit'` - navigation is committed, new url is displayed in the browser address bar.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle0"|"networkidle2"> When to consider navigation succeeded, defaults to `load`. Events can be either:
- `'domcontentloaded'` - consider navigation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `'networkidle0'` - consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.
- `'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. If
@ -1267,10 +1261,9 @@ Navigate to the next page in history.
- `url` <[string]> URL to navigate page to. The url should include scheme, e.g. `https://`.
- `options` <[Object]> Navigation parameters which might have the following properties:
- `timeout` <[number]> Maximum navigation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultNavigationTimeout(timeout)](#browsercontextsetdefaultnavigationtimeouttimeout), [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout), [page.setDefaultNavigationTimeout(timeout)](#pagesetdefaultnavigationtimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
- `waitUntil` <"commit"|"load"|"domcontentloaded"|"networkidle0"|"networkidle2"> When to consider navigation succeeded, defaults to `load`. Events can be either:
- `'commit'` - navigation is committed, new url is displayed in the browser address bar.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle0"|"networkidle2"> When to consider navigation succeeded, defaults to `load`. Events can be either:
- `'domcontentloaded'` - consider navigation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `'networkidle0'` - consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.
- `'networkidle2'` - consider navigation to be finished when there are no more than 2 network connections for at least `500` ms.
- `referer` <[string]> Referer header value. If provided it will take preference over the referer header value set by [page.setExtraHTTPHeaders()](#pagesetextrahttpheadersheaders).
@ -1408,10 +1401,9 @@ The `format` options are:
- `options` <[Object]>
- `text` <[string]> If specified, generates an input event with this text.
- `delay` <[number]> Time to wait between `keydown` and `keyup` in milliseconds. Defaults to 0.
- `waitUntil` <"commit"|"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to `commit` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'commit'` - navigation is committed, new url is displayed in the browser address bar.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to fire `domcontentloaded` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'domcontentloaded'` - consider navigation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `'networkidle0'` - consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.
- `'networkidle2'` - consider navigation to be finished when there are no more than 2 network connections for at least `500` ms.
- `'nowait'` - do not wait.
@ -1427,10 +1419,9 @@ If `key` is a single character and no modifier keys besides `Shift` are being he
#### page.reload([options])
- `options` <[Object]> Navigation parameters which might have the following properties:
- `timeout` <[number]> Maximum navigation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultNavigationTimeout(timeout)](#browsercontextsetdefaultnavigationtimeouttimeout), [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout), [page.setDefaultNavigationTimeout(timeout)](#pagesetdefaultnavigationtimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
- `waitUntil` <"commit"|"load"|"domcontentloaded"|"networkidle0"|"networkidle2"> When to consider navigation succeeded, defaults to `load`. Events can be either:
- `'commit'` - navigation is committed, new url is displayed in the browser address bar.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle0"|"networkidle2"> When to consider navigation succeeded, defaults to `load`. Events can be either:
- `'domcontentloaded'` - consider navigation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `'networkidle0'` - consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.
- `'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.
@ -1489,10 +1480,9 @@ Page routes take precedence over browser context routes (set up with [browserCon
- `label` <[string]> Matches by `option.label`.
- `index` <[number]> Matches by the index.
- `options` <[Object]>
- `waitUntil` <"commit"|"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to `commit` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'commit'` - navigation is committed, new url is displayed in the browser address bar.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to fire `domcontentloaded` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'domcontentloaded'` - consider navigation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `'networkidle0'` - consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.
- `'networkidle2'` - consider navigation to be finished when there are no more than 2 network connections for at least `500` ms.
- `'nowait'` - do not wait.
@ -1522,7 +1512,7 @@ Shortcut for [page.mainFrame().select()](#frameselectselector-values)
- `html` <[string]> HTML markup to assign to the page.
- `options` <[Object]> Parameters which might have the following properties:
- `timeout` <[number]> Maximum time in milliseconds for resources to load, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultNavigationTimeout(timeout)](#browsercontextsetdefaultnavigationtimeouttimeout), [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout), [page.setDefaultNavigationTimeout(timeout)](#pagesetdefaultnavigationtimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
- `waitUntil` <"commit"|"load"|"domcontentloaded"|"networkidle0"|"networkidle2"> When to consider setting markup succeeded, defaults to `load`. Given an array of event strings, setting content is considered to be successful after all events have been fired. Events can be either:
- `waitUntil` <"load"|"domcontentloaded"|"networkidle0"|"networkidle2"> When to consider setting markup succeeded, defaults to `load`. Given an array of event strings, setting content is considered to be successful after all events have been fired. Events can be either:
- `'load'` - consider setting content to be finished when the `load` event is fired.
- `'domcontentloaded'` - consider setting content to be finished when the `DOMContentLoaded` event is fired.
- `'networkidle0'` - consider setting content to be finished when there are no more than 0 network connections for at least `500` ms.
@ -1596,10 +1586,9 @@ Shortcut for [page.mainFrame().title()](#frametitle).
- is not moving (for example, waits until css transition finishes),
- receives pointer events at the action point (for example, waits until element becomes non-obscured by other elements).
Even if the action is forced, it will wait for the element matching selector to be in DOM. Defaults to `false`.
- `waitUntil` <"commit"|"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to `commit` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'commit'` - navigation is committed, new url is displayed in the browser address bar.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to fire `domcontentloaded` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'domcontentloaded'` - consider navigation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `'networkidle0'` - consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.
- `'networkidle2'` - consider navigation to be finished when there are no more than 2 network connections for at least `500` ms.
- `'nowait'` - do not wait.
@ -1620,10 +1609,9 @@ Shortcut for [page.mainFrame().tripleclick(selector[, options])](#frametriplecli
- `text` <[string]> A text to type into a focused element.
- `options` <[Object]>
- `delay` <[number]> Time to wait between key presses in milliseconds. Defaults to 0.
- `waitUntil` <"commit"|"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to `commit` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'commit'` - navigation is committed, new url is displayed in the browser address bar.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to fire `domcontentloaded` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'domcontentloaded'` - consider navigation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `'networkidle0'` - consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.
- `'networkidle2'` - consider navigation to be finished when there are no more than 2 network connections for at least `500` ms.
- `'nowait'` - do not wait.
@ -1649,10 +1637,9 @@ Shortcut for [page.mainFrame().type(selector, text[, options])](#frametypeselect
- is not moving (for example, waits until css transition finishes),
- receives pointer events at the action point (for example, waits until element becomes non-obscured by other elements).
Even if the action is forced, it will wait for the element matching selector to be in DOM. Defaults to `false`.
- `waitUntil` <"commit"|"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to `commit` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'commit'` - navigation is committed, new url is displayed in the browser address bar.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to fire `domcontentloaded` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'domcontentloaded'` - consider navigation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `'networkidle0'` - consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.
- `'networkidle2'` - consider navigation to be finished when there are no more than 2 network connections for at least `500` ms.
- `'nowait'` - do not wait.
@ -1756,10 +1743,9 @@ Shortcut for [page.mainFrame().waitForFunction(pageFunction[, options[, ...args]
- `options` <[Object]> Navigation parameters which might have the following properties:
- `timeout` <[number]> Maximum navigation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultNavigationTimeout(timeout)](#browsercontextsetdefaultnavigationtimeouttimeout), [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout), [page.setDefaultNavigationTimeout(timeout)](#pagesetdefaultnavigationtimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
- `url` <[string]|[RegExp]|[Function]> A glob pattern, regex pattern or predicate receiving [URL] to match while waiting for the navigation.
- `waitUntil` <"commit"|"load"|"domcontentloaded"|"networkidle0"|"networkidle2"> When to consider navigation succeeded, defaults to `load`. Events can be either:
- `'commit'` - navigation is committed, new url is displayed in the browser address bar.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle0"|"networkidle2"> When to consider navigation succeeded, defaults to `load`. Events can be either:
- `'domcontentloaded'` - consider navigation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `'networkidle0'` - consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.
- `'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. In case of navigation to a different anchor or navigation due to History API usage, the navigation will resolve with `null`.
@ -1847,15 +1833,15 @@ Event object passed to the listeners of [`browserContext.on('page')`](#event-pag
#### pageEvent.page([options])
- `options` <[Object]>
- `timeout` <[number]> Maximum navigation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultNavigationTimeout(timeout)](#browsercontextsetdefaultnavigationtimeouttimeout), [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout), [page.setDefaultNavigationTimeout(timeout)](#pagesetdefaultnavigationtimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
- `waitUntil` <"commit"|"load"|"domcontentloaded"|"networkidle0"|"networkidle2"> When to consider the page to be loaded, defaults to `load`. Events can be either:
- `'commit'` - navigation is committed, new url is displayed in the browser address bar.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> When to consider the page to be loaded, defaults to `load`. Events can be either:
- `'nowait'` - navigation is committed, new url is displayed in the browser address bar.
- `'domcontentloaded'` - consider navigation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `'networkidle0'` - consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.
- `'networkidle2'` - consider navigation to be finished when there are no more than 2 network connections for at least `500` ms.
- returns: <[Promise]<[Page]>> Promise which resolves to the created page once it loads, according to `waitUntil` option.
This resolves when the page reaches a required load state, `load` by default. The earliest moment that page is available is when it has committed navigation to the initial url (corresponds to `{waitUntil: 'commit'}` option). For example, when opening a popup with `window.open('http://example.com')`, this method will wait until the network request to "http://example.com" is done and its response has started loading in the popup. Passing different `waitUntil` options will also wait for the particular load state to happen, e.g. default `load` waits until the load event fires.
This resolves when the page reaches a required load state, `load` by default. The earliest moment that page is available is when it has navigated to the initial url (corresponds to `{waitUntil: 'nowait'}` option). For example, when opening a popup with `window.open('http://example.com')`, this method will wait until the network request to "http://example.com" is done and its response has started loading in the popup. Passing different `waitUntil` options will also wait for the particular load state to happen, e.g. default `load` waits until the load event fires.
```js
const [, popup] = await Promise.all([
@ -2013,10 +1999,9 @@ Adds a `<link rel="stylesheet">` tag into the page with the desired url or a `<s
- is not moving (for example, waits until css transition finishes),
- receives pointer events at the action point (for example, waits until element becomes non-obscured by other elements).
Even if the action is forced, it will wait for the element matching selector to be in DOM. Defaults to `false`.
- `waitUntil` <"commit"|"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to `commit` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'commit'` - navigation is committed, new url is displayed in the browser address bar.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to fire `domcontentloaded` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'domcontentloaded'` - consider navigation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `'networkidle0'` - consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.
- `'networkidle2'` - consider navigation to be finished when there are no more than 2 network connections for at least `500` ms.
- `'nowait'` - do not wait.
@ -2044,10 +2029,9 @@ If there's no element matching `selector`, the method throws an error.
- is not moving (for example, waits until css transition finishes),
- receives pointer events at the action point (for example, waits until element becomes non-obscured by other elements).
Even if the action is forced, it will wait for the element matching selector to be in DOM. Defaults to `false`.
- `waitUntil` <"commit"|"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to `commit` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'commit'` - navigation is committed, new url is displayed in the browser address bar.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to fire `domcontentloaded` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'domcontentloaded'` - consider navigation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `'networkidle0'` - consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.
- `'networkidle2'` - consider navigation to be finished when there are no more than 2 network connections for at least `500` ms.
- `'nowait'` - do not wait.
@ -2076,10 +2060,9 @@ Gets the full HTML contents of the frame, including the doctype.
- is not moving (for example, waits until css transition finishes),
- receives pointer events at the action point (for example, waits until element becomes non-obscured by other elements).
Even if the action is forced, it will wait for the element matching selector to be in DOM. Defaults to `false`.
- `waitUntil` <"commit"|"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to `commit` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'commit'` - navigation is committed, new url is displayed in the browser address bar.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to fire `domcontentloaded` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'domcontentloaded'` - consider navigation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `'networkidle0'` - consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.
- `'networkidle2'` - consider navigation to be finished when there are no more than 2 network connections for at least `500` ms.
- `'nowait'` - do not wait.
@ -2154,10 +2137,9 @@ await resultHandle.dispose();
- `selector` <[string]> A selector to query page for.
- `value` <[string]> Value to fill for the `<input>`, `<textarea>` or `[contenteditable]` element.
- `options` <[Object]>
- `waitUntil` <"commit"|"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to `commit` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'commit'` - navigation is committed, new url is displayed in the browser address bar.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to fire `domcontentloaded` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'domcontentloaded'` - consider navigation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `'networkidle0'` - consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.
- `'networkidle2'` - consider navigation to be finished when there are no more than 2 network connections for at least `500` ms.
- `'nowait'` - do not wait.
@ -2193,10 +2175,9 @@ console.log(frame === contentFrame); // -> true
- `url` <[string]> URL to navigate frame to. The url should include scheme, e.g. `https://`.
- `options` <[Object]> Navigation parameters which might have the following properties:
- `timeout` <[number]> Maximum navigation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultNavigationTimeout(timeout)](#browsercontextsetdefaultnavigationtimeouttimeout), [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout), [page.setDefaultNavigationTimeout(timeout)](#pagesetdefaultnavigationtimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
- `waitUntil` <"commit"|"load"|"domcontentloaded"|"networkidle0"|"networkidle2"> When to consider navigation succeeded, defaults to `load`. Events can be either:
- `'commit'` - navigation is committed, new url is displayed in the browser address bar.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle0"|"networkidle2"> When to consider navigation succeeded, defaults to `load`. Events can be either:
- `'domcontentloaded'` - consider navigation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `'networkidle0'` - consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.
- `'networkidle2'` - consider navigation to be finished when there are no more than 2 network connections for at least `500` ms.
- `referer` <[string]> Referer header value. If provided it will take preference over the referer header value set by [page.setExtraHTTPHeaders()](#pagesetextrahttpheadersheaders).
@ -2257,10 +2238,9 @@ If the name is empty, returns the id attribute instead.
- `options` <[Object]>
- `text` <[string]> If specified, generates an input event with this text.
- `delay` <[number]> Time to wait between `keydown` and `keyup` in milliseconds. Defaults to 0.
- `waitUntil` <"commit"|"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to `commit` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'commit'` - navigation is committed, new url is displayed in the browser address bar.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to fire `domcontentloaded` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'domcontentloaded'` - consider navigation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `'networkidle0'` - consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.
- `'networkidle2'` - consider navigation to be finished when there are no more than 2 network connections for at least `500` ms.
- `'nowait'` - do not wait.
@ -2280,10 +2260,9 @@ If `key` is a single character and no modifier keys besides `Shift` are being he
- `label` <[string]> Matches by `option.label`.
- `index` <[number]> Matches by the index.
- `options` <[Object]>
- `waitUntil` <"commit"|"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to `commit` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'commit'` - navigation is committed, new url is displayed in the browser address bar.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to fire `domcontentloaded` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'domcontentloaded'` - consider navigation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `'networkidle0'` - consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.
- `'networkidle2'` - consider navigation to be finished when there are no more than 2 network connections for at least `500` ms.
- `'nowait'` - do not wait.
@ -2311,10 +2290,9 @@ frame.select('select#colors', { value: 'blue' }, { index: 2 }, 'red');
- `html` <[string]> HTML markup to assign to the page.
- `options` <[Object]> Parameters which might have the following properties:
- `timeout` <[number]> Maximum time in milliseconds for resources to load, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultNavigationTimeout(timeout)](#browsercontextsetdefaultnavigationtimeouttimeout), [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout), [page.setDefaultNavigationTimeout(timeout)](#pagesetdefaultnavigationtimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
- `waitUntil` <"commit"|"load"|"domcontentloaded"|"networkidle0"|"networkidle2"> When to consider navigation succeeded, defaults to `load`. Events can be either:
- `'commit'` - navigation is committed, new url is displayed in the browser address bar.
- `'load'` - consider setting content to be finished when the `load` event is fired.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle0"|"networkidle2"> When to consider navigation succeeded, defaults to `load`. Events can be either:
- `'domcontentloaded'` - consider setting content to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider setting content to be finished when the `load` event is fired.
- `'networkidle0'` - consider setting content to be finished when there are no more than 0 network connections for at least `500` ms.
- `'networkidle2'` - consider setting content to be finished when there are no more than 2 network connections for at least `500` ms.
- returns: <[Promise]>
@ -2336,10 +2314,9 @@ frame.select('select#colors', { value: 'blue' }, { index: 2 }, 'red');
- is not moving (for example, waits until css transition finishes),
- receives pointer events at the action point (for example, waits until element becomes non-obscured by other elements).
Even if the action is forced, it will wait for the element matching selector to be in DOM. Defaults to `false`.
- `waitUntil` <"commit"|"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to `commit` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'commit'` - navigation is committed, new url is displayed in the browser address bar.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to fire `domcontentloaded` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'domcontentloaded'` - consider navigation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `'networkidle0'` - consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.
- `'networkidle2'` - consider navigation to be finished when there are no more than 2 network connections for at least `500` ms.
- `'nowait'` - do not wait.
@ -2358,10 +2335,9 @@ Bear in mind that if the first or second click of the `tripleclick()` triggers a
- `text` <[string]> A text to type into a focused element.
- `options` <[Object]>
- `delay` <[number]> Time to wait between key presses in milliseconds. Defaults to 0.
- `waitUntil` <"commit"|"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to `commit` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'commit'` - navigation is committed, new url is displayed in the browser address bar.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to fire `domcontentloaded` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'domcontentloaded'` - consider navigation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `'networkidle0'` - consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.
- `'networkidle2'` - consider navigation to be finished when there are no more than 2 network connections for at least `500` ms.
- `'nowait'` - do not wait.
@ -2385,10 +2361,9 @@ await frame.type('#mytextarea', 'World', {delay: 100}); // Types slower, like a
- is not moving (for example, waits until css transition finishes),
- receives pointer events at the action point (for example, waits until element becomes non-obscured by other elements).
Even if the action is forced, it will wait for the element matching selector to be in DOM. Defaults to `false`.
- `waitUntil` <"commit"|"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to `commit` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'commit'` - navigation is committed, new url is displayed in the browser address bar.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to fire `domcontentloaded` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'domcontentloaded'` - consider navigation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `'networkidle0'` - consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.
- `'networkidle2'` - consider navigation to be finished when there are no more than 2 network connections for at least `500` ms.
- `'nowait'` - do not wait.
@ -2471,10 +2446,9 @@ await page.waitForFunction(selector => !!document.querySelector(selector), {}, s
- `options` <[Object]> Navigation parameters which might have the following properties:
- `timeout` <[number]> Maximum navigation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultNavigationTimeout(timeout)](#browsercontextsetdefaultnavigationtimeouttimeout), [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout), [page.setDefaultNavigationTimeout(timeout)](#pagesetdefaultnavigationtimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
- `url` <[string]|[RegExp]|[Function]> URL string, URL regex pattern or predicate receiving [URL] to match while waiting for the navigation.
- `waitUntil` <"commit"|"load"|"domcontentloaded"|"networkidle0"|"networkidle2"> When to consider navigation succeeded, defaults to `load`. Events can be either:
- `'commit'` - navigation is committed, new url is displayed in the browser address bar.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle0"|"networkidle2"> When to consider navigation succeeded, defaults to `load`. Events can be either:
- `'domcontentloaded'` - consider navigation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `'networkidle0'` - consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.
- `'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. In case of navigation to a different anchor or navigation due to History API usage, the navigation will resolve with `null`.
@ -2641,10 +2615,9 @@ This method returns the bounding box of the element (relative to the main frame)
- is not moving (for example, waits until css transition finishes),
- receives pointer events at the action point (for example, waits until element becomes non-obscured by other elements).
Even if the action is forced, it will wait for the element matching selector to be in DOM. Defaults to `false`.
- `waitUntil` <"commit"|"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to `commit` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'commit'` - navigation is committed, new url is displayed in the browser address bar.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to fire `domcontentloaded` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'domcontentloaded'` - consider navigation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `'networkidle0'` - consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.
- `'networkidle2'` - consider navigation to be finished when there are no more than 2 network connections for at least `500` ms.
- `'nowait'` - do not wait.
@ -2667,10 +2640,9 @@ If element is not already checked, it scrolls it into view if needed, and then u
- is not moving (for example, waits until css transition finishes),
- receives pointer events at the action point (for example, waits until element becomes non-obscured by other elements).
Even if the action is forced, it will wait for the element matching selector to be in DOM. Defaults to `false`.
- `waitUntil` <"commit"|"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to `commit` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'commit'` - navigation is committed, new url is displayed in the browser address bar.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to fire `domcontentloaded` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'domcontentloaded'` - consider navigation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `'networkidle0'` - consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.
- `'networkidle2'` - consider navigation to be finished when there are no more than 2 network connections for at least `500` ms.
- `'nowait'` - do not wait.
@ -2696,10 +2668,9 @@ If the element is detached from DOM, the method throws an error.
- is not moving (for example, waits until css transition finishes),
- receives pointer events at the action point (for example, waits until element becomes non-obscured by other elements).
Even if the action is forced, it will wait for the element matching selector to be in DOM. Defaults to `false`.
- `waitUntil` <"commit"|"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to `commit` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'commit'` - navigation is committed, new url is displayed in the browser address bar.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to fire `domcontentloaded` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'domcontentloaded'` - consider navigation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `'networkidle0'` - consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.
- `'networkidle2'` - consider navigation to be finished when there are no more than 2 network connections for at least `500` ms.
- `'nowait'` - do not wait.
@ -2716,10 +2687,9 @@ Bear in mind that if the first click of the `dblclick()` triggers a navigation e
#### elementHandle.fill(value[, options])
- `value` <[string]> Value to set for the `<input>`, `<textarea>` or `[contenteditable]` element.
- `options` <[Object]>
- `waitUntil` <"commit"|"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to `commit` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'commit'` - navigation is committed, new url is displayed in the browser address bar.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to fire `domcontentloaded` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'domcontentloaded'` - consider navigation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `'networkidle0'` - consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.
- `'networkidle2'` - consider navigation to be finished when there are no more than 2 network connections for at least `500` ms.
- `'nowait'` - do not wait.
@ -2759,10 +2729,9 @@ If the element is detached from DOM, the method throws an error.
- `options` <[Object]>
- `text` <[string]> If specified, generates an input event with this text.
- `delay` <[number]> Time to wait between `keydown` and `keyup` in milliseconds. Defaults to 0.
- `waitUntil` <"commit"|"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to `commit` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'commit'` - navigation is committed, new url is displayed in the browser address bar.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to fire `domcontentloaded` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'domcontentloaded'` - consider navigation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `'networkidle0'` - consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.
- `'networkidle2'` - consider navigation to be finished when there are no more than 2 network connections for at least `500` ms.
- `'nowait'` - do not wait.
@ -2800,10 +2769,9 @@ Throws when ```elementHandle``` does not point to an element [connected](https:/
- `label` <[string]> Matches by `option.label`.
- `index` <[number]> Matches by the index.
- `options` <[Object]>
- `waitUntil` <"commit"|"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to `commit` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'commit'` - navigation is committed, new url is displayed in the browser address bar.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to fire `domcontentloaded` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'domcontentloaded'` - consider navigation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `'networkidle0'` - consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.
- `'networkidle2'` - consider navigation to be finished when there are no more than 2 network connections for at least `500` ms.
- `'nowait'` - do not wait.
@ -2854,10 +2822,9 @@ Sets the value of the file input to these file paths or files. If some of the `
- is not moving (for example, waits until css transition finishes),
- receives pointer events at the action point (for example, waits until element becomes non-obscured by other elements).
Even if the action is forced, it will wait for the element matching selector to be in DOM. Defaults to `false`.
- `waitUntil` <"commit"|"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to `commit` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'commit'` - navigation is committed, new url is displayed in the browser address bar.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to fire `domcontentloaded` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'domcontentloaded'` - consider navigation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `'networkidle0'` - consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.
- `'networkidle2'` - consider navigation to be finished when there are no more than 2 network connections for at least `500` ms.
- `'nowait'` - do not wait.
@ -2875,10 +2842,9 @@ Bear in mind that if the first or second click of the `tripleclick()` triggers a
- `text` <[string]> A text to type into a focused element.
- `options` <[Object]>
- `delay` <[number]> Time to wait between key presses in milliseconds. Defaults to 0.
- `waitUntil` <"commit"|"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to `commit` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'commit'` - navigation is committed, new url is displayed in the browser address bar.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to fire `domcontentloaded` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'domcontentloaded'` - consider navigation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `'networkidle0'` - consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.
- `'networkidle2'` - consider navigation to be finished when there are no more than 2 network connections for at least `500` ms.
- `'nowait'` - do not wait.
@ -2908,10 +2874,9 @@ await elementHandle.press('Enter');
- is not moving (for example, waits until css transition finishes),
- receives pointer events at the action point (for example, waits until element becomes non-obscured by other elements).
Even if the action is forced, it will wait for the element matching selector to be in DOM. Defaults to `false`.
- `waitUntil` <"commit"|"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to `commit` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'commit'` - navigation is committed, new url is displayed in the browser address bar.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `waitUntil` <"load"|"domcontentloaded"|"networkidle0"|"networkidle2"|"nowait"> Actions that cause navigations are waiting for those navigations to fire `domcontentloaded` by default. This behavior can be changed to either wait for another load phase or to omit the waiting altogether using `nowait`:
- `'domcontentloaded'` - consider navigation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider navigation to be finished when the `load` event is fired.
- `'networkidle0'` - consider navigation to be finished when there are no more than 0 network connections for at least `500` ms.
- `'networkidle2'` - consider navigation to be finished when there are no more than 2 network connections for at least `500` ms.
- `'nowait'` - do not wait.

View file

@ -98,10 +98,10 @@ export class FrameManager {
}
}
async waitForNavigationsCreatedBy<T>(action: () => Promise<T>, options?: types.NavigatingActionWaitOptions, input?: boolean): Promise<T> {
if (options && options.waitUntil === 'nowait')
async waitForNavigationsCreatedBy<T>(action: () => Promise<T>, options: types.NavigatingActionWaitOptions = {}, input?: boolean): Promise<T> {
if (options.waitUntil === 'nowait')
return action();
const barrier = new PendingNavigationBarrier(options);
const barrier = new PendingNavigationBarrier({ waitUntil: 'domcontentloaded', ...options });
this._pendingNavigationBarriers.add(barrier);
try {
const result = await action();
@ -170,7 +170,6 @@ export class FrameManager {
return;
const hasDOMContentLoaded = frame._firedLifecycleEvents.has('domcontentloaded');
const hasLoad = frame._firedLifecycleEvents.has('load');
frame._firedLifecycleEvents.add('commit');
frame._firedLifecycleEvents.add('domcontentloaded');
frame._firedLifecycleEvents.add('load');
for (const watcher of this._lifecycleWatchers)
@ -196,7 +195,6 @@ export class FrameManager {
clearFrameLifecycle(frame: Frame) {
frame._firedLifecycleEvents.clear();
frame._firedLifecycleEvents.add('commit');
// Keep the current navigation request if any.
frame._inflightRequests = new Set(Array.from(frame._inflightRequests).filter(request => request._documentId === frame._lastDocumentId));
this._stopNetworkIdleTimer(frame, 'networkidle0');

View file

@ -115,12 +115,12 @@ export class PageEvent {
return page;
}
async page(options: types.NavigateOptions = {}): Promise<Page> {
async page(options: types.TimeoutOptions & { waitUntil?: types.LifecycleEvent | 'nowait' } = {}): Promise<Page> {
const {
timeout = this._browserContext._timeoutSettings.navigationTimeout(),
waitUntil = 'load',
} = options;
const lifecyclePromise = this._lifecyclePromises.get(waitUntil);
const lifecyclePromise = waitUntil === 'nowait' ? this._pageOrError : this._lifecyclePromises.get(waitUntil);
if (!lifecyclePromise)
throw new Error(`Unsupported waitUntil option ${String(waitUntil)}`);
const pageOrError = await helper.waitWithTimeout(lifecyclePromise, `"${waitUntil}"`, timeout);

View file

@ -45,8 +45,8 @@ export type WaitForElementOptions = TimeoutOptions & { waitFor?: 'attached' | 'd
export type Polling = 'raf' | 'mutation' | number;
export type WaitForFunctionOptions = TimeoutOptions & { polling?: Polling };
export type LifecycleEvent = 'commit' | 'load' | 'domcontentloaded' | 'networkidle0' | 'networkidle2';
export const kLifecycleEvents: Set<LifecycleEvent> = new Set(['commit', 'load', 'domcontentloaded', 'networkidle0', 'networkidle2']);
export type LifecycleEvent = 'load' | 'domcontentloaded' | 'networkidle0' | 'networkidle2';
export const kLifecycleEvents: Set<LifecycleEvent> = new Set(['load', 'domcontentloaded', 'networkidle0', 'networkidle2']);
export type NavigateOptions = TimeoutOptions & {
waitUntil?: LifecycleEvent,

View file

@ -506,7 +506,7 @@ module.exports.describe = function({testRunner, expect, playwright, CHROMIUM, FF
});
it('should report initialized pages', async({browser, server}) => {
const context = await browser.newContext();
const pagePromise = context.waitForEvent('page').then(e => e.page({ waitUntil: 'commit' }));
const pagePromise = context.waitForEvent('page').then(e => e.page({ waitUntil: 'nowait' }));
context.newPage();
const newPage = await pagePromise;
expect(newPage.url()).toBe('about:blank');
@ -555,7 +555,7 @@ module.exports.describe = function({testRunner, expect, playwright, CHROMIUM, FF
const context = await browser.newContext();
const events = [];
context.on('page', async event => {
const page = await event.page({ waitUntil: 'commit' });
const page = await event.page({ waitUntil: 'nowait' });
events.push('CREATED: ' + page.url());
page.on('close', () => events.push('DESTROYED: ' + page.url()));
});

View file

@ -792,7 +792,7 @@ module.exports.describe = function({testRunner, expect, playwright, MAC, WIN, FF
});
it('should work for cross-process navigations', async({page, server}) => {
await page.goto(server.EMPTY_PAGE);
const waitPromise = page.waitForNavigation({waitUntil: 'commit'});
const waitPromise = page.waitForNavigation({waitUntil: 'domcontentloaded'});
const url = server.CROSS_PROCESS_PREFIX + '/empty.html';
const gotoPromise = page.goto(url);
const response = await waitPromise;
@ -808,37 +808,42 @@ module.exports.describe = function({testRunner, expect, playwright, MAC, WIN, FF
const messages = [];
server.setRoute('/empty.html', async (req, res) => {
messages.push('route');
res.end('done');
res.setHeader('Content-Type', 'text/html');
res.end(`<link rel='stylesheet' href='./one-style.css'>`);
});
await page.setContent(`<a href="${server.EMPTY_PAGE}">empty.html</a>`);
await Promise.all([
page.click('a').then(() => messages.push('click')),
page.waitForNavigation({ waitUntil: 'commit' }).then(() => messages.push('waitForNavigation'))
page.waitForNavigation({ waitUntil: 'domcontentloaded' }).then(() => messages.push('domcontentloaded')),
page.waitForNavigation({ waitUntil: 'load' }).then(() => messages.push('load')),
]);
expect(messages.join('|')).toBe('route|waitForNavigation|click');
expect(messages.join('|')).toBe('route|domcontentloaded|click|load');
});
it('clicking anchor should await cross-process navigation', async({page, server}) => {
const messages = [];
server.setRoute('/empty.html', async (req, res) => {
messages.push('route');
res.end('done');
res.setHeader('Content-Type', 'text/html');
res.end(`<link rel='stylesheet' href='./one-style.css'>`);
});
await page.setContent(`<a href="${server.CROSS_PROCESS_PREFIX + '/empty.html'}">empty.html</a>`);
await Promise.all([
page.click('a').then(() => messages.push('click')),
page.waitForNavigation({ waitUntil: 'commit' }).then(() => messages.push('waitForNavigation'))
page.waitForNavigation({ waitUntil: 'domcontentloaded' }).then(() => messages.push('domcontentloaded')),
page.waitForNavigation({ waitUntil: 'load' }).then(() => messages.push('load')),
]);
expect(messages.join('|')).toBe('route|waitForNavigation|click');
expect(messages.join('|')).toBe('route|domcontentloaded|click|load');
});
it('should await form-get on click', async({page, server}) => {
const messages = [];
server.setRoute('/empty.html?foo=bar', async (req, res) => {
messages.push('route');
res.end('done');
res.setHeader('Content-Type', 'text/html');
res.end(`<link rel='stylesheet' href='./one-style.css'>`);
});
await page.setContent(`
@ -849,15 +854,17 @@ module.exports.describe = function({testRunner, expect, playwright, MAC, WIN, FF
await Promise.all([
page.click('input[type=submit]').then(() => messages.push('click')),
page.waitForNavigation({ waitUntil: 'commit' }).then(() => messages.push('waitForNavigation'))
page.waitForNavigation({ waitUntil: 'domcontentloaded' }).then(() => messages.push('domcontentloaded')),
page.waitForNavigation({ waitUntil: 'load' }).then(() => messages.push('load')),
]);
expect(messages.join('|')).toBe('route|waitForNavigation|click');
expect(messages.join('|')).toBe('route|domcontentloaded|click|load');
});
it('should await form-post on click', async({page, server}) => {
const messages = [];
server.setRoute('/empty.html', async (req, res) => {
messages.push('route');
res.end('done');
res.setHeader('Content-Type', 'text/html');
res.end(`<link rel='stylesheet' href='./one-style.css'>`);
});
await page.setContent(`
@ -868,23 +875,26 @@ module.exports.describe = function({testRunner, expect, playwright, MAC, WIN, FF
await Promise.all([
page.click('input[type=submit]').then(() => messages.push('click')),
page.waitForNavigation({ waitUntil: 'commit' }).then(() => messages.push('waitForNavigation'))
page.waitForNavigation({ waitUntil: 'domcontentloaded' }).then(() => messages.push('domcontentloaded')),
page.waitForNavigation({ waitUntil: 'load' }).then(() => messages.push('load')),
]);
expect(messages.join('|')).toBe('route|waitForNavigation|click');
expect(messages.join('|')).toBe('route|domcontentloaded|click|load');
});
it('assigning location should await navigation', async({page, server}) => {
const messages = [];
server.setRoute('/empty.html', async (req, res) => {
messages.push('route');
res.end('done');
res.setHeader('Content-Type', 'text/html');
res.end(`<link rel='stylesheet' href='./one-style.css'>`);
});
await Promise.all([
page.evaluate(`window.location.href = "${server.EMPTY_PAGE}"`).then(() => messages.push('evaluate')),
page.waitForNavigation({ waitUntil: 'commit' }).then(() => messages.push('waitForNavigation')),
page.waitForNavigation({ waitUntil: 'domcontentloaded' }).then(() => messages.push('domcontentloaded')),
page.waitForNavigation({ waitUntil: 'load' }).then(() => messages.push('load')),
]);
expect(messages.join('|')).toBe('route|waitForNavigation|evaluate');
expect(messages.join('|')).toBe('route|domcontentloaded|evaluate|load');
});
it.skip(CHROMIUM)('assigning location twice should await navigation', async({page, server}) => {
it.fail(CHROMIUM)('assigning location twice should await navigation', async({page, server}) => {
const messages = [];
server.setRoute('/empty.html?cancel', async (req, res) => { res.end('done'); });
server.setRoute('/empty.html?override', async (req, res) => { messages.push('routeoverride'); res.end('done'); });
@ -899,17 +909,26 @@ module.exports.describe = function({testRunner, expect, playwright, MAC, WIN, FF
it('evaluating reload should await navigation', async({page, server}) => {
const messages = [];
await page.goto(server.EMPTY_PAGE);
server.setRoute('/empty.html', async (req, res) => { messages.push('route'); res.end('done'); });
server.setRoute('/empty.html', async (req, res) => {
messages.push('route');
res.setHeader('Content-Type', 'text/html');
res.end(`<link rel='stylesheet' href='./one-style.css'>`);
});
await Promise.all([
page.evaluate(`window.location.reload()`).then(() => messages.push('evaluate')),
page.waitForNavigation({ waitUntil: 'commit' }).then(() => messages.push('waitForNavigation')),
page.waitForNavigation({ waitUntil: 'domcontentloaded' }).then(() => messages.push('domcontentloaded')),
page.waitForNavigation({ waitUntil: 'load' }).then(() => messages.push('load')),
]);
expect(messages.join('|')).toBe('route|waitForNavigation|evaluate');
expect(messages.join('|')).toBe('route|domcontentloaded|evaluate|load');
});
it('should await navigating specified target', async({page, server}) => {
const messages = [];
server.setRoute('/empty.html', async (req, res) => { messages.push('route'); res.end('done'); });
server.setRoute('/empty.html', async (req, res) => {
messages.push('route');
res.setHeader('Content-Type', 'text/html');
res.end(`<link rel='stylesheet' href='./one-style.css'>`);
});
await page.setContent(`
<a href="${server.EMPTY_PAGE}" target=target>empty.html</a>
@ -918,19 +937,42 @@ module.exports.describe = function({testRunner, expect, playwright, MAC, WIN, FF
const frame = page.frame({ name: 'target' });
await Promise.all([
page.click('a').then(() => messages.push('click')),
frame.waitForNavigation({ waitUntil: 'commit' }).then(() => messages.push('waitForNavigation'))
frame.waitForNavigation({ waitUntil: 'domcontentloaded' }).then(() => messages.push('domcontentloaded')),
frame.waitForNavigation({ waitUntil: 'load' }).then(() => messages.push('load')),
]);
expect(frame.url()).toBe(server.EMPTY_PAGE);
expect(messages.join('|')).toBe('route|waitForNavigation|click');
expect(messages.join('|')).toBe('route|domcontentloaded|click|load');
});
it('nowait', async({page, server}) => {
it('waitUntil: nowait', async({page, server}) => {
const messages = [];
server.setRoute('/empty.html', async (req, res) => {
res.setHeader('Content-Type', 'text/html');
res.end(`<link rel='stylesheet' href='./one-style.css'>`);
});
await page.setContent(`<a href="${server.EMPTY_PAGE}">empty.html</a>`);
await Promise.all([
page.click('a', { waitUntil: 'nowait' }).then(() => messages.push('click')),
page.waitForNavigation({ waitUntil: 'commit' }).then(() => messages.push('waitForNavigation'))
page.waitForNavigation({ waitUntil: 'domcontentloaded' }).then(() => messages.push('domcontentloaded')),
page.waitForNavigation({ waitUntil: 'load' }).then(() => messages.push('load')),
]);
expect(messages.join('|')).toBe('click|waitForNavigation');
expect(messages.join('|')).toBe('click|domcontentloaded|load');
});
it('waitUntil: load', async({page, server}) => {
const messages = [];
server.setRoute('/empty.html', async (req, res) => {
messages.push('route');
res.setHeader('Content-Type', 'text/html');
res.end(`<link rel='stylesheet' href='./one-style.css'>`);
});
await page.setContent(`<a href="${server.EMPTY_PAGE}">empty.html</a>`);
await Promise.all([
page.click('a', { waitUntil: 'load' }).then(() => messages.push('click')),
page.waitForNavigation({ waitUntil: 'domcontentloaded' }).then(() => messages.push('domcontentloaded')),
page.waitForNavigation({ waitUntil: 'load' }).then(() => messages.push('load')),
]);
expect(messages.join('|')).toBe('route|domcontentloaded|load|click');
});
});
@ -975,7 +1017,7 @@ module.exports.describe = function({testRunner, expect, playwright, MAC, WIN, FF
server.setRoute('/one-style.css', (req, res) => response = res);
await Promise.all([
server.waitForRequest('/one-style.css'),
page.goto(server.PREFIX + '/one-style.html', {waitUntil: 'commit'}),
page.goto(server.PREFIX + '/one-style.html', {waitUntil: 'domcontentloaded'}),
]);
const waitPromise = page.mainFrame()._waitForLoadState();
response.statusCode = 404;
@ -984,7 +1026,7 @@ module.exports.describe = function({testRunner, expect, playwright, MAC, WIN, FF
});
it('should respect timeout', async({page, server}) => {
server.setRoute('/one-style.css', (req, res) => response = res);
await page.goto(server.PREFIX + '/one-style.html', {waitUntil: 'commit'});
await page.goto(server.PREFIX + '/one-style.html', {waitUntil: 'domcontentloaded'});
const error = await page.mainFrame()._waitForLoadState({ timeout: 1 }).catch(e => e);
expect(error.message).toBe('Navigation timeout of 1 ms exceeded');
});
@ -995,7 +1037,7 @@ module.exports.describe = function({testRunner, expect, playwright, MAC, WIN, FF
it('should resolve immediately if load state matches', async({page, server}) => {
await page.goto(server.EMPTY_PAGE);
server.setRoute('/one-style.css', (req, res) => response = res);
await page.goto(server.PREFIX + '/one-style.html', {waitUntil: 'commit'});
await page.goto(server.PREFIX + '/one-style.html', {waitUntil: 'domcontentloaded'});
await page.mainFrame()._waitForLoadState({ waitUntil: 'domcontentloaded' });
});
it('should work with pages that have loaded before being connected to', async({page, context, server}) => {

View file

@ -283,7 +283,7 @@ module.exports.describe = function({testRunner, expect, playwright, CHROMIUM, WE
const context = await browser.newContext();
const page = await context.newPage();
const [popup] = await Promise.all([
page.waitForEvent('popup').then(e => e.page({ waitUntil: 'commit' })),
page.waitForEvent('popup').then(e => e.page({ waitUntil: 'nowait' })),
page.evaluate(() => window.__popup = window.open('')),
]);
expect(await page.evaluate(() => !!window.opener)).toBe(false);