Valip
Valip

Reputation: 4620

How to fix 'page.target is not a function' in puppeteer?

I'm trying to use the Devtools Protocol with Puppeteer, but it throws the following error:

TypeError: page.target is not a function

This is my code:

const puppeteer = require('puppeteer');

(async() => {
  // Use Puppeteer to launch a browser and open a page.
  const browser = await puppeteer.launch({headless: true});
  const page = await browser.newPage();

  // Create a raw DevTools protocol session to talk to the page.
  const session = await page.target().createCDPSession();
  await page.goto('https://www.google.com');
})();

Am I missing something?

Upvotes: 1

Views: 2125

Answers (1)

Arthur Attout
Arthur Attout

Reputation: 2916

Make sure you're using the latest version of Puppeteer.

"dependencies": {
    "puppeteer": "latest"
}

Upvotes: 2

Related Questions