puppeteer: targetcreated event not firing when 1st parameter of window.open() is empty string
The 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.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 2
- Comments: 19 (3 by maintainers)
… 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.