mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
Rename navigation option 'waitFor' into 'waitUntil'.
This patch renames navigation option 'waitFor' into 'waitUntil' to avoid confusion with 'page.waitFor' call. References #39.
This commit is contained in:
parent
76415e1be5
commit
34a96a8462
@ -232,11 +232,11 @@ Page is guaranteed to have a main frame which persists during navigations.
|
||||
- `url` <[string]> URL to navigate page to
|
||||
- `options` <[Object]> Navigation parameters which might have the following properties:
|
||||
- `maxTime` <[number]> Maximum navigation time in milliseconds, defaults to 30 seconds.
|
||||
- `waitFor` <[string]> When to consider navigation succeeded, defaults to `load`. Could be either:
|
||||
- `waitUntil` <[string]> When to consider navigation succeeded, defaults to `load`. Could be either:
|
||||
- `load` - consider navigation to be finished when the `load` event is fired.
|
||||
- `networkidle` - consider navigation to be finished when the network activity stays "idle" for at least `networkIdleTimeout`ms.
|
||||
- `networkIdleInflight` <[number]> Maximum amount of inflight requests which are considered "idle". Takes effect only with `waitFor: 'networkidle'` parameter.
|
||||
- `networkIdleTimeout` <[number]> A timeout to wait before completing navigation. Takes effect only with `waitFor: 'networkidle'` parameter.
|
||||
- `networkIdleInflight` <[number]> Maximum amount of inflight requests which are considered "idle". Takes effect only with `waitUntil: 'networkidle'` parameter.
|
||||
- `networkIdleTimeout` <[number]> A timeout to wait before completing navigation. Takes effect only with `waitUntil: 'networkidle'` parameter.
|
||||
- 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.
|
||||
|
||||
The `page.navigate` will throw an error if:
|
||||
|
@ -28,9 +28,9 @@ class Navigator {
|
||||
this._maxTime = typeof options['maxTime'] === 'number' ? options['maxTime'] : 30000;
|
||||
this._idleTime = typeof options['networkIdleTimeout'] === 'number' ? options['networkIdleTimeout'] : 1000;
|
||||
this._idleInflight = typeof options['networkIdleInflight'] === 'number' ? options['networkIdleInflight'] : 2;
|
||||
this._waitFor = typeof options['waitFor'] === 'string' ? options['waitFor'] : 'load';
|
||||
this._waitUntil = typeof options['waitUntil'] === 'string' ? options['waitUntil'] : 'load';
|
||||
|
||||
console.assert(this._waitFor === 'load' || this._waitFor === 'networkidle', 'Unknown value for options.waitFor: ' + this._waitFor);
|
||||
console.assert(this._waitUntil === 'load' || this._waitUntil === 'networkidle', 'Unknown value for options.waitUntil: ' + this._waitUntil);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -52,7 +52,7 @@ class Navigator {
|
||||
throw e;
|
||||
}
|
||||
|
||||
const error = await Promise.race([certificateError, watchdog, this._waitFor === 'load' ? loadEventFired : networkIdle]);
|
||||
const error = await Promise.race([certificateError, watchdog, this._waitUntil === 'load' ? loadEventFired : networkIdle]);
|
||||
this._cleanup();
|
||||
if (error)
|
||||
throw error;
|
||||
|
@ -274,7 +274,7 @@ describe('Puppeteer', function() {
|
||||
// Navigate to a page which loads immediately and then does a bunch of
|
||||
// requests via javascript's fetch method.
|
||||
let navigationPromise = page.navigate(PREFIX + '/networkidle.html', {
|
||||
waitFor: 'networkidle',
|
||||
waitUntil: 'networkidle',
|
||||
networkIdleTimeout: 100,
|
||||
networkIdleInflight: 0, // Only be idle when there are 0 inflight requests
|
||||
});
|
||||
@ -324,7 +324,7 @@ describe('Puppeteer', function() {
|
||||
// Navigate to a page which loads immediately and then opens a bunch of
|
||||
// websocket connections and then a fetch request.
|
||||
let navigationPromise = page.navigate(PREFIX + '/websocket.html', {
|
||||
waitFor: 'networkidle',
|
||||
waitUntil: 'networkidle',
|
||||
networkIdleTimeout: 100,
|
||||
networkIdleInflight: 0, // Only be idle when there are 0 inflight requests/connections
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user