问题
Is it possible to reattach to an existing puppeteer ?
- open puppeteer chrome browser.
- node script ends without closing browser.
- new script attaches and continue with the same browser.
回答1:
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.
来源:https://stackoverflow.com/questions/45867611/attach-to-previously-opened-puppeteer-driver