page.waitForNavigation never resolves
See original GitHub issueSteps to reproduce
Tell us about your environment:
- Puppeteer version: 1.8.0
- Platform / OS version: MacOSX High Sierra
- URLs (if applicable):
- Node.js version: 10.0.0
What steps will reproduce the problem?
const http = require('http')
const puppeteer = require('puppeteer')
const PORT = 3000
/**
* Dummy HTTP Server
*/
http.createServer((req, res) => {
if (req.url === '/there') {
console.log('Responded')
res.writeHead(200, { 'content-type': 'text/plain' })
res.end('reached there')
} else {
res.writeHead(200, { 'content-type': 'text/html' })
res.end(`
<a href="/there"> Redirect </a>
`)
}
}).listen(PORT)
/**
* Puppeteer script
*/
async function run () {
const browser = await puppeteer.launch()
const page = await browser.newPage()
await page.goto('http://localhost:3000')
await page.click('a')
await page.waitForNavigation()
const text = await page.evaluate(() => document.body.innerText)
console.log(text)
}
run().then(console.log).catch(console.log)
What is the expected result?
To see the text
on console
What happens instead?
page.waitForNavigation
is stuck and then times out after 30 seconds
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (4 by maintainers)
Top Results From Across the Web
waitForNavigation hanging, even though page was loaded
According to Puppeteer documentation proper pattern for clicking on submit and waiting for navigation is like this: await Promise.all([ page ...
Read more >puppeteer.Page.waitForNavigation JavaScript and Node.js ...
Promise which resolves to a new Page object. Page.goto. Navigates to a URL. Browser.close. Closes browser with all the pages (if any were...
Read more >Navigating & waiting - Checkly
You can use Puppeteer's page.waitForNavigation() method here to explicitly wait for this event to happen and then continue your script.
Read more >Page.waitForNavigation() method - Puppeteer
A Promise which resolves to the main resource response. In case of multiple redirects, the navigation will resolve with the response of the...
Read more >How to make puppeteer wait for page to load - Urlbox
waitForNavigation and wait for these events to fire. waitUntil: domcontentloaded. The domcontentloaded option will fire the earliest, and is the ...
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
You’re experiencing a race condition. Try using the example code instead:
Or you can use this way: