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

page.setContent(html, {waitUntil: 'networkidle'}); #907

Closed
graingert opened this issue Sep 28, 2017 · 4 comments
Closed

page.setContent(html, {waitUntil: 'networkidle'}); #907

graingert opened this issue Sep 28, 2017 · 4 comments

Comments

@graingert
Copy link

I'd like to be able to wait for network idle in:

https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagesetcontenthtml

I'd like to be able to do:

await page.setContent('<img src="http://example.com/foo.jpg" />', {waitUntil: 'networkidle'});

because currently:

await page.setContent('<img src="http://example.com/foo.jpg" />');
const buff = await page.pdf(); // produces a blank PDF.
@graingert
Copy link
Author

my workaround is to use:

await page.goto(`data:text/html,${html}`, { waitUntil: 'networkidle' });

@graingert
Copy link
Author

graingert commented Sep 28, 2017

closing as duplicate of #728

@lukasvarkalis
Copy link

my workaround is to use:

await page.goto(`data:text/html,${html}`, { waitUntil: 'networkidle' });

Networkidle is no longer supported. You should use 'networkidle2' instead

@cosmith
Copy link

cosmith commented Mar 13, 2019

For anyone still using this workaround, now await page.setContent('<img src="http://example.com/foo.jpg" />', {waitUntil: 'networkidle0'}); works. (https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagesetcontenthtml-options)

Using page.goto(`data:text/html,${html}`) led to some issues with special characters for us, setContent is definitely a better solution!

simllll added a commit to simllll/penthouse that referenced this issue Mar 29, 2019
since puppeteer/puppeteer#907 is closed, it is possible to use setContent in a similar way. And as it seems that my workarund with "data:text/html;charset=UTF-8,<HTML CONTENT>" as url paremter stopped working with the latest updates, I looked for a way to integrate this with less effort.

By checking the "url" paremeter if it starts with data:text/html, we can easily check if we should use "setContent" or "goto".

All the best,
Simon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants