targetcreated event not firing when 1st parameter of window.open() is empty string
See original GitHub issueThe targetcreated event is not firing when window.open() is called.
Steps to reproduce
Tell us about your environment:
- Puppeteer version: 1.5.0
- Platform / OS version: Windows 10.0.17134
- Node.js version: 8.11.2
What steps will reproduce the problem?
const newPagePromise = new Promise(x => browser.on('targetCreated', target => x(target.page())));
await page.click("#bReport"); //Makes popup
const popup = await newPagePromise; //Hangs here
In the website, the button is rigged to call
var report=window.open("","Schedule","menubar=0,scrollbars=1,resizable=1");
before adding content via an AJAX call.
What is the expected result? The popup should appear in a new window, with the variable pointing at the new page created by window.open()
What happens instead? The popup does appear, but the promise hangs. I have no way to validate the contents of the popup.
This may be a duplicate of #1992. I’m making a new issue to increase visibility and hopefully find a solution.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:19 (3 by maintainers)
Top Results From Across the Web
Window.open() - Web APIs - MDN Web Docs
A string indicating the URL or path of the resource to be loaded. If an empty string ( "" ) is specified or...
Read more >Puppeteer documentation - DevDocs
event : 'targetcreated'. <Target>. Emitted when a new target is created inside the browser context, for example when a new page is opened...
Read more >Target domain - Chrome DevTools Protocol - GitHub Pages
Creates a new page. parameters. url: string. The initial URL the page will be navigated to. An empty string indicates about:blank ...
Read more >sending custom parameters with window.open() but its not ...
But its not working as I want. I have tried the following ways 1. window.open("http://localhost:8080/login ...
Read more >How to set User-Agent header with Puppeteer JS and not fail
Firefox, Internet Explorer, Edge … gives empty string; oscpu: only Firefox ... Website can check if we are messing around with window.open() 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
… so I’ve managed to force
targetcreated
event inbrowser
after openingabout:blank
new window by running this function:I needed to force some random url there just to be different than empty string
''
.Careful though, if you have uninitialised targets for a reason you might run into troubles there. And make sure you don’t need that url that is now obviously wrong.
I would give myself a thumbs down for this solution but it helped and maybe will help someone else too. At least until it’s fixed in puppeteer/dtp.
The
'targetcreated'
event is spelled with all-small letters; you have a capital ‘C’.A rule of a thumb is that all pptr literals are small-case.