waitForNavigation doesn't work after evaluate fetch() or XMLHttpRequest()
See original GitHub issuePuppeteer version: 0.13.0 Platform / OS version: Win10x64 / Chromium 64.0.3264.0
const puppeteer = require('puppeteer');
(async() => {
const browser = await puppeteer.launch({headless:false,userDataDir:'test-profile-dir'});
const page = await browser.newPage();
await page.setRequestInterception(true);
await page.on('request', request => {
request.continue();
});
await page.goto("https://www.npmjs.com/",{waitUntil: ['networkidle0','load','domcontentloaded'],timeout:10000}).catch(error=>console.log(error));
await page.evaluate(async () => {fetch("https://www.npmjs.com/features").then( response => response.text() ).then( html => document.body.innerHTML=html )}).catch(error=>console.log(error));
await page.waitForNavigation({waitUntil: ['networkidle0','load','domcontentloaded'],timeout:10000}).catch(error=>console.log(error));
await page.goto("https://www.npmjs.com/pricing",{waitUntil: ['networkidle0','load','domcontentloaded'],timeout:10000}).catch(error=>console.log(error));
await browser.close();
})();
it returns the result as below
Error: Navigation Timeout Exceeded: 10000ms exceeded
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Puppeteer: page.evaluate not working after waitForNavigation ...
This resolves when the page navigates to a new URL or reloads. It never happens, so your code does not continue. You might...
Read more >Puppeteer documentation - DevDocs
Puppeteer 7.1.0 API documentation with instant search, offline support, keyboard shortcuts, mobile version, and more.
Read more >Dealing with Asynchrony when Writing End-To-End Tests with ...
In this article we present an overview on how to deal with asynchrony ... first getting the message using the evaluate() Puppeteer function....
Read more >Scraping dynamic content - Apify Documentation
Wait for dynamically loaded content when web scraping. See code examples and a detailed breakdown for setting timeouts and custom wait functions.
Read more >node_modules/puppeteer/lib/types.d.ts - devtools ... - Google Git
This won't share cookies/cache with other. * browser contexts. *. * @example. * ```js. * (async () => {. * const browser =...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had the same iussue and resolved using a recursive function that reset itself every request, and after a small time of idle network ( time parameter ) resolves.
use like this
@remorses use .once() instead of .on()