firefox - 在 Puppeteer 中对 Firefox 的 setRequestInterception 支持
问题描述
setRequestInterception
在 Puppeteer 上适用于 Firefox 吗?
在我的测试中,每当使用 Firefox 启动时,我都会得到:
Protocol error (Fetch.enable): Fetch.enable RemoteAgentError@chrome://remote/content/Error.jsm:25:5
上await page.setRequestInterception(true);
我知道目前 Firefox 处于 Puppeteer 的实验模式。所以我预计这个功能可能不被支持。在 Firefox 上运行时,有没有其他方法可以处理请求(如更改请求、模拟响应)?
这就是我启动浏览器的方式(我可以看到 Firefox 窗口,并且所有其他测试都通过了):
browser = await puppeteer.launch({
product: "firefox",
headless: false,
slowMo: 50,
});
解决方案
Firefox 的 Puppeteer 尚不支持setRequestInterception
。您可以在https://puppeteer.github.io/ispuppeteerfirefoxready/跟踪通过测试
以下是我们启动 Firefox 的方式:
在安装过程中,选择 Puppeteer 版本 ^3.0.0
PUPPETEER_PRODUCT=firefox npm install
选项:
puppeteerOptions: {
args: args,
//ignoreDefaultArgs: ['--enable-automation'],
headless: false,
//slowMo: 17,
//executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
executablePath: './node_modules/puppeteer/.local-firefox/mac-79.0a1/Firefox Nightly.app/Contents/MacOS/firefox'
},
推荐阅读
- scala - akka-quartz-scheduler - “没有为调度找到匹配的石英配置” - QuartzSchedulerExtension 在两个参与者之间共享
- sql - 创建参考表
- flutter - 如何使用 textPainter 执行昂贵的计算
- java - 用java更改数据库日期
- android - MediaRecorder 冻结 UI 线程
- html - CSS - 多宽,是否太宽?20000px 的宽度会导致任何网络浏览器/设备出现问题吗?
- android - 如何减少数字选择器对话框的活动大小框
- node.js - kafka 客户端正在向代理失败的分区发送请求
- javascript - how to search for a regex object
- android - 如何将二维数组设置为单选按钮?