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

How to wait until all network activity on a particular page has stopped before continuing? #3063

Closed
saadahmad03 opened this issue Aug 10, 2018 · 4 comments

Comments

@saadahmad03
Copy link

saadahmad03 commented Aug 10, 2018

I was wondering if there is a way to wait until all network activity has become idle (without navigation, refreshing, or going to a new page) as the application I am writing tests for requires all API requests to complete first before some buttons become clickable etc.

I am currently doing stuff like await page.waitFor(10000) and so on but I don't think this is the best solution.

Is there any way I can write code that would act something like this:

await page.waitFor({ waitUntil: networkidle })

Any insight would be appreciated, thanks so much in advance!

@rogervanwile
Copy link

Hi @saadahmad03 ,

there is a options argument by calling page.goto. In these options you can set waitUntil to networkidle2.

await page.goto(url, {waitUntil: 'networkidle2'});

https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagegotourl-options

@saadahmad03
Copy link
Author

Hi @rogervanwile, thank you for your response. I was actually wondering if there was an option to do
{ waitUntil: 'networkidle2 } without having to go to a new page, and to perform this operation on the current page.

@aslushnikov
Copy link
Contributor

@saadahmad03 thanks for the clarification. This has been requested for a while already; filed a designated bug report for it: #3083. Feel free to upvote.

@ralyodio
Copy link

can i do this with await page.mouse.click(pos.x+pos.width/2, pos.y+pos.height/2);?

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