Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

attach to previously opened puppeteer driver

Tags:

puppeteer

Is it possible to reattach to an existing puppeteer ?

  1. open puppeteer chrome browser.
  2. node script ends without closing browser.
  3. new script attaches and continue with the same browser.
like image 850
user2081405 Avatar asked Aug 24 '17 17:08

user2081405


People also ask

How do you connect already existing Chrome Browser with puppeteer?

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.

Can puppeteer use Chrome instead of Chromium?

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.

Does puppeteer require Chrome?

Puppeteer is a Node. js library developed by Google that lets you control headless Chrome through the DevTools Protocol. It is a tool for automating testing in your application using headless Chrome or Chromebit devices, without requiring any browser extensions like Selenium Webdriver or PhantomJS.

Where does puppeteer install Chromium?

The default download path is node_modules/puppeteer/. local-chromium .


1 Answers

For those who stumble upon this, here's an example of how I've got it working:

const puppeteer = require('puppeteer');

puppeteer.connect({"browserWSEndpoint" : "ws://some_string"}).then(async browser => {
    console.log("bla bla");
    ...
});

The browser.wsEndpoint you can find from the previous session:

const endpoint = browser.wsEndpoint();

Browser websocket endpoint which can be used as an argument to puppeteer.connect.

like image 81
elena Avatar answered Nov 16 '22 23:11

elena