question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot use `getEvenetListeners` in page.evaluate()

See original GitHub issue

Steps to reproduce

Tell us about your environment:

  • Puppeteer version:1.10.0
  • Platform / OS version:MacOS
  • URLs (if applicable):
  • Node.js version:11.3

What steps will reproduce the problem?

Please include code that reproduces the issue.

  1. Using getEventListeners in page.evaluate
  2. I get this error message (node:53503) UnhandledPromiseRejectionWarning: Error: Evaluation failed: ReferenceError: getEventListeners is not defined
  3. I thought getEventListeners is not the window / document property, could I enable something ( maybe DOMDebugger option? ) to make this property work?
  4. Or … Is there another way to debug document if elements attach some unexpected event type / event listener?

What is the expected result?

Get event listeners array.

What happens instead?

error message Error: Evaluation failed: ReferenceError: getEventListeners is not defined

related issue: https://github.com/GoogleChrome/puppeteer/issues/3349 https://github.com/GoogleChrome/puppeteer/issues/3166 https://github.com/GoogleChrome/puppeteer/issues/1919

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
aslushnikovcommented, Mar 5, 2019

For the hackers out there: you can get classes now from puppeteer/lib/api:

const {JSHandle} = require('puppeteer/lib/api');
1reaction
realdenniscommented, Mar 5, 2019

In puppeteer@1.13, we could not import (require) ElementHandle from ExecutionContext, I just replace ElementHandle with JSHandle, I am not sure this a good alternative solution.

Workaround for who need this method in the latest version.

  const { JSHandle } = require('puppeteer/lib/JSHandle');
  JSHandle.prototype.getEventListeners = function() {
    return this._client.send('DOMDebugger.getEventListeners', {
      objectId: this._remoteObject.objectId
    });
  };
Read more comments on GitHub >

github_iconTop Results From Across the Web

getEventListeners is not defined in PuppeteerSharp
How to use getEventListeners within puppeteerSharp? I found this for javascript: const cdp = await page.target().createCDPSession(); const ...
Read more >
puppeteer document is not defined - You.com | The AI Search ...
I was transforming my code with babel. Puppeteer page.evaluate calls autoScroll.toString() which results in an incomplete string when used with babel. Instead ...
Read more >
Variable not defined with page.evaluate in Puppeteer - YouTube
The 4 BEST Places to Get Contact Information · Web scraping with Javascript using Puppeteer and Node.js · The Only Puppeteer Tutorial You'll...
Read more >
Console tool utility functions and selectors - Microsoft Learn
Right-click the returned result and then select Reveal in Elements Panel to find it in the DOM, or Scroll in to View to...
Read more >
Node.js v19.3.0 Documentation
triggerAsyncId(); Using AsyncResource for a Worker thread pool ... CORS is never checked on the destination server; Cannot load non-network dependencies ...
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