Currently, I am using HAR Export XPI to capture the network traffic data of the pages being accessed via Selenium. To achieve this, I have added the XPI extension to Firefox version 46 since it is not compatible with newer versions. The profile settings I have configured are as follows -
profile.setPreference("app.update.enabled", false);
profile.setPreference("extensions.netmonitor.har.enableAutomation", true);
profile.setPreference("extensions.netmonitor.har.contentAPIToken", "true");
profile.setPreference("extensions.netmonitor.har.autoConnect", true);
profile.setPreference("devtools.netmonitor.enabled", true);
profile.setPreference("devtools.netmonitor.har.pageLoadedTimeout", "50000");
profile.setPreference("devtools.netmonitor.har.defaultLogDir", "FOLDER_ON_SYSTEM");
profile.setPreference("devtools.netmonitor.har.enableAutoExportToFile", false);
To extract the HAR file, I am injecting the following JavaScript code.
function triggerExport() {
var options = {
token: "true",
getData: true,
fileName: "Export_%y%m%d_%H%M%S"
};
HAR.triggerExport(options).then(result => {
console.log(result);
});
};
if (typeof HAR === 'undefined')
{
console.log("Calling Undefined");
addEventListener('har-api-ready', event => {
console.log("har api ready");
console.log(event);
triggerExport();
}, false);
}
else
{
console.log("Calling defined");
triggerExport();
}
However, I am encountering an issue where the HAR file is not being generated. I also noticed that typing 'HAR' in the Firefox console returns 'undefined', causing the function to fail.
I'm seeking guidance on any additional settings or steps that may be required to resolve this problem.
Thank you for your assistance!