Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event' in Page.select()

See original GitHub issue
  • Puppeteer version: 0.12.0
  • Platform / OS version: Ubuntu 16.04.3

When I do:

page.select('[name="resource_id"]', '25');

I get an error:

TypeError: Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'.

If I comment both dispatchEvent lines in select(), I get no error. Both fail.

The element exists and is a <select> and the selection works. Only the event dispatching does not work.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
rudiedirkxcommented, Oct 28, 2017

Ooooooh, I might know what it is, but that’s unexpected (for me, for you it’s obvious). My very old JS lib overrides window.Event, so it’s not a native Event anymore. This is unexpected for me, and obvious for you, because I didn’t know the stringified version of the this.$eval callback function is called inside the page’s context, not in Puppeteer/node context.

element.dispatchEvent(new Event('input', { 'bubbles': true }));

That’s browser JS, not NodeJS… Ah.

I now see I can reproduce this exact error in Real Chrome:

$0.dispatchEvent(new Event('input', { 'bubbles': true }));

VM1042:1 Uncaught TypeError: Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'.
    at <anonymous>:1:4
(anonymous) @ VM1042:1

So, yes, my JS is definitely too hacky. Sorry!

0reactions
yaakovyitzchakcommented, Mar 27, 2019

Hey guys, I have a a question regarding this:

I’m trying to attempt to get the direct link for a google drive video. To do that, I first navigate to the drive embed-video URL, then click on the play button (There are many of them), then wait for the iframe containing a video element to appear, then get the video element in the iframe, then I’m trying to get the source of the video, but it appears to be null, so I tried getting the outerHTML, and this is what I got in the console:

<video tabindex="-1" class="video-stream html5-main-video" controlslist="nodownload" style="width: 800px; height: 450px; left: 0px; top: 75px;"></video>

Seemingly it hasn’t been loaded yet, but I’m not sure what event to wait for, I waited for a timeout of 15 seconds but still got the same result, here’s my code:

var puppeteer = require("puppeteer");

    (async() => {
        var browser = await puppeteer.launch();
        console.log("Got browser", browser);
        var page = await browser.newPage();
        console.log(page,"got page");
     
        await page.goto("https://docs.google.com/file/d/1Cyuh41yNfYZU_zL-MHLf_EPJCYnlT7oJ/preview?enablejsapi=1&playerapiid=player4");
        console.log("went to page..");
        
      
      
        var clickEl = ".ndfHFb-c4YZDc-aTv5jf-bVEB4e-RJLb9c";
        var newClickID = ".ndfHFb-c4YZDc-aTv5jf-NziyQe-LgbsSe";
        var clicker = await page.waitForSelector(newClickID);
        console.log(clicker,"got clicker");
    
        await page.click(clickEl);
        console.log("clicked")
    
        var frame = await page.waitForSelector("iframe[id=drive-viewer-video-player-object-0]");
        console.log(frame, "got video frame");
        
        
    
        
        var cf = await frame.contentFrame();
        console.log(cf, "got content frame");
        await cf.waitFor(15000);
        var video = await cf.$("video");
        var src = await cf.evaluate(
            v => v.outerHTML,
            video
        );
        console.log("$$###VIDEO SOURCE::", src);
        await browser.close();
    })();

Any ideas, am I doing something wron? why is the “src” attribute not showing up on the video element? [1]: https://github.com/GoogleChrome/puppeteer/blob/v1.13.0/docs/api.md#elementhandleselector-1

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - dispatchEvent Causes error failed to execute ...
failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'. I have tried everything, and found out that this will...
Read more >
TypeError: parameter 1 is not of type 'Event'
TypeError: Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'. This is the code I have, you would use ......
Read more >
Failed to execute 'dispatchEvent' on 'EventTarget' - DataTables
I'm trying to implement export buttons at my Datatable, but when I try to click ... on 'EventTarget': parameter 1 is not of...
Read more >
EventTarget.dispatchEvent() - Web APIs | MDN
The dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected EventListeners in the ...
Read more >
Typeerror: Failed To Execute 'Dispatchevent' On 'Eventtarget'
Typeerror: Failed To Execute 'Dispatchevent' On 'Eventtarget': Parameter 1 Is Not Of Type 'Event' ... Create and dispatch events in a component's JavaScript...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found