Reputation: 1333
I am using pyppeteer to trigger headless chrome and perform some actions. But first I want all the elements of the web page to load completely. The official documentation of pyppeteer suggests a waitUntil parameter which comes with more than 1 parameters.
My doubt is do i have to pass all the parameters or any one in particular is sufficient? Please suggest if following snippet helps in my case?
await page.goto(url, {'waitUntil' : ['load', 'domcontentloaded', 'networkidle0', 'networkidle2']})
Upvotes: 7
Views: 12551
Reputation: 8851
No, you don't have to pass all possible options to 'waitUntil'
. You can pick either of them, or more options at the same time if you like, but if you are:
then you are good to go with: 'domcontentloaded'
to wait for all the elements to be rendered on the page.
await page.goto(url, {'waitUntil' : 'domcontentloaded'})
The options in details:
load
: when load
event is fired.
domcontentloaded
: when the DOMContentLoaded
event is fired.
networkidle0
: when there are no more than 0 network connections
for at least 500 ms.
networkidle2
: when there are no more than 2 network connections
for at least 500 ms.
Note: of course it is true for the NodeJs puppeteer library as well, they work the same way in terms of waitUntil
.
Upvotes: 9