Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: expose page.on('networkidle0') and page.on('networkidle2') events #3083

Open
aslushnikov opened this issue Aug 13, 2018 · 4 comments
Labels
chromium Issues with Puppeteer-Chromium feature

Comments

@aslushnikov
Copy link
Contributor

This has been requested quite a few times on the bugtracker already.

As a workaround, network idleness can be emulated on the puppeteer-side.

@paulirish
Copy link
Collaborator

A few notes for anyone else impatient for these first-class events.

The can be emulated link above is useful if you need different idleness parameters (# of requests, ms of time).

Alternatively, if you want a basic page.on('networkidle0', fn) event, a hacky solution is to drop down to the protocol:

page._client.on('Page.lifecycleEvent', e => {
	// networkidle0 => 'networkIdle', networkidle2 => 'networkAlmostIdle'
    if (e.name === 'networkIdle') fn()
});

Standard disclaimers about using the protocol directly (this may break unexpectedly) apply.

@aslushnikov
Copy link
Contributor Author

@paulirish the lifecycle events are per frame, so the hacky way doesn't really work

@aslushnikov aslushnikov added the chromium Issues with Puppeteer-Chromium label Dec 6, 2018
aslushnikov added a commit to aslushnikov/puppeteer that referenced this issue Jan 11, 2019
This patch adds a new method - `Page.ensureNavigation` - that
completes once the last running navigation hits the conditions
defined in `waitUntil` clause.

This comes handy when awaiting loading of a pages spawned as a result
of ctrl-click and other events.

References puppeteer#3083
@rob4629
Copy link

rob4629 commented Apr 3, 2019

Any updates on this?

@tjenkinson
Copy link
Contributor

I opened this PR which should help with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chromium Issues with Puppeteer-Chromium feature
Projects
None yet
Development

No branches or pull requests

4 participants