browser.newPage never resolves when using `userDataDir`
See original GitHub issuebrowser.newPage()
never resolve when using userDataDir
in launch options.
Strangely, it only works when using headless: false
.
Steps to reproduce
Tell us about your environment:
- Puppeteer version: 1.4
- Platform / OS version: Windows 10
- URLs (if applicable):
- Node.js version: 10.0
What steps will reproduce the problem?
const browser = await puppeteer.launch({
// headless: false, // un-commenting this makes it works
userDataDir: 'test-profile-dir',
});
await browser.newPage();
// Never reaches here
console.log('If this logs, it worked!');
Please include code that reproduces the issue.
https://github.com/laggingreflex/puppeteer-userDataDir-hang
What is the expected result?
browser.newPage()
should resolve and above code should be able to reach console.log
statement
What happens instead?
It doesn’t
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:14 (1 by maintainers)
Top Results From Across the Web
Puppeteer: browser.newPage is not a function - Stack Overflow
Someone on Guilded helped me resolve this with a pretty simple fix. Basically both the puppeteer.launch({}); and browser.newPage(); return a ...
Read more >puppeteer-core@19.4.1 - jsDocs.io
A promise that resolves to true if the revision could be downloaded from the host. Remarks. This method is affected by the current...
Read more >node_modules/puppeteer/lib/types.d.ts - devtools ... - Google Git
The Browser class extends from Puppeteer's {@link EventEmitter} class and will ... @returns Promise which resolves to the first target found.
Read more >How to use the puppeteer.launch function in puppeteer - Snyk
launch(); const page = await browser.newPage(); // Catch + "forward" hashchange events from page to node puppeteer. await page.exposeFunction('onHashChange' ...
Read more >Web Scraping with a Headless Browser: A Puppeteer Tutorial
This method lets us run custom JavaScript code as if we were executing it in the DevTools console. Anything returned from that function...
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
It also seems to work when full path is provided:
__dirname + '/test-profile-dir'
Just for anyone’s reference, this issue still presents itself in version 1.20.0. When headless = true, then you must provide a full path instead of a relative one for userDataDir. In the case of headless = false, it works fine with both full and relative paths.