I am using har-export-trigger to capture har files, I have enabled automation by setting `"extensions.netmonitor.har.enableAutomation", true.`
我还在下面设置了偏好
("extensions.netmonitor.har.contentAPIToken", "test")
("devtools.netmonitor.har.includeResponseBodies", true)
("devtools.webconsole.persistlog", true)
使用以下脚本捕获har文件
var options = {
token: "test",
getData: true,
fileName: "testName_harfile-%y%m%d%H%M%S" // Name of the file
};
HAR.triggerExport(options).then(result => {
// The local file is available now, result.data is null since options.getData wasn't set.
});
在大多数情况下,会捕获har文件,但是当页面重定向到错误页面时,很少有请求丢失。