【发布时间】:2018-02-01 10:52:37
【问题描述】:
我正在使用 puppeteer 启动一个新的 Chrome 浏览器窗口:
const util = require('util');
const puppeteer = require('puppeteer');
(async () => {
const b = await puppeteer.launch({
headless: false,
devtools: true, // open DevTools when window launches
args: ['--remote-debugging-port=9222']
});
console.log('browser:', util.inspect(b));
const c = await puppeteer.connect({
browserWSEndpoint: b._connection._url, //`ws://${host}:${port}/devtools/browser/<id>`,
ignoreHTTPSErrors: false
});
console.log('connection =>', c);
})();
我的问题是 - 我如何使用 websocket 连接 c 将 DevTools 协议消息发送到浏览器窗口?我想打开一个新标签,并执行一些其他操作。有人知道怎么做吗?
【问题讨论】:
标签: node.js google-chrome puppeteer