#!/usr/bin/env node
// vim: set noexpandtab tabstop=2:
const puppeteer = require('puppeteer')
const browserURL = 'http://127.0.0.1:9222'
let browser;
(async () => {
// const browser = await puppeteer.launch({headless: false});
browser = await puppeteer.connect({browserURL})
const page = await browser.newPage()
await page.goto('https://httpbin.org')
})()
.catch(err => console.error(err))
.finally(() => browser?.disconnect())
Suppose that I connect an existing browser process in the above way and exit, then I want to start another node js program to access the same page. It seems me that puppeteer may not support this readily. But it must be possible to do so with the underlying Chrome Devtools Protocol, as CDP is just ws connection. But it would be difficult to figure all raw CDP message as I used wireshark to decipher the ws messages, there are too many to understand. So I still want to do so in puppeteer if possible.
How can I achieve this in puppeteer?
1