Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting Browsers in Puppeteer

Is it possible to connect a browser to puppeteer without instantiating it in puppeteer? For example, running an instance of chromium like a regular user and then connecting that to an instance of puppeteer in code?

like image 913
Jak Avatar asked Mar 11 '19 07:03

Jak


People also ask

Can puppeteer use Chrome instead of Chromium?

(However, it is possible to force Puppeteer to use a separately-installed version Chrome instead of Chromium via the executablePath option to puppeteer. launch .

Does puppeteer work with Chrome?

Puppeteer is a Node library which provides a high-level API to control headless Chrome or Chromium over the DevTools Protocol. It can also be configured to use full (non-headless) Chrome or Chromium.

How do I change my browser puppeteer?

Default runtime settings To use Puppeteer with a different version of Chrome or Chromium, pass in the executable's path when creating a Browser instance: const browser = await puppeteer.launch({executablePath: '/path/to/Chrome'}); You can also use Puppeteer with Firefox Nightly (experimental support).


1 Answers

The answer is Yes and No.

You can connect to an existing using the connect function:

const browserURL = 'http://127.0.0.1:21222';
const browser = await puppeteer.connect({browserURL});

But, if you want to use those 2 lines you need to launch Chrome with the "--remote-debugging-port=21222 argument.

like image 98
hardkoded Avatar answered Sep 28 '22 10:09

hardkoded