Open farooqrahman opened 6 years ago
@farooqrahman you might want to add these preferences to your session initalize flow:
{
args : [
'-devtools',
],
prefs: [
'devtools.netmonitor.persistlog': true,
'devtools.toolbox.selectedTool': 'netmonitor',
'devtools.toolbox.footer.height': 0,
]
}
You may need retry mechanism on your code side to work around this...at this moment. If the HAR API is not defined, wait for couple of seconds, then try it again.
Another possible way could be adding waitForPageLoad
command after each click
command on a button, then dump HAR after waitForPageLoad
command. This can make sure HAR API can be injected before you are trying to call it
I guess that HAR is not defined
error indicates that the DOM is not ready, while your code is trying to call HAR api to dump HAR. At that time, HAR API object may not be injected yet.
Good luck!
@leipreachan I am already using those options when dumping the HAR. Thanks for the suggestions.
@xmhubj yes, you are right somehow we need to wait for the page load to happen so that HAR object can be injected. I found one solution for this which fixes this problem. I check whether HAR object is available or not before dumping the HAR. Below is the pseudocode if HAR object available then use the HAR object else poll for the HAR object availability and use it once available.
Below is the javascript code I have used for this issue. Here I am polling for every 500ms to check the HAR object availability.
if (typeof HAR != \"undefined\" ) { dumpHAR(); }
else { var interval = setInterval(function() {
if(typeof HAR != \"undefined\") {
clearInterval(interval); dumpHAR();"
}
}, 500);"
}
Hi @janodvarko,
We successfully launched our product using har-export-triggerExport-0.6.1 and it's been used by our customers. All credit goes to you for providing this super cool new plugin which uses new WebExtension. But one of our customer's face this issue 'ReferenceError: HAR is not defined'. The environment in which this error reported is Firefox version: 61.0 har_export_trigger version: 0.6.1
All the HAR dump process happens during selenium java execution. We dump the HAR after every click action on the page. This dumping of the HAR happens instantly after button click. In one of the customer application page when the user clicks on a button we got this error. But if I delay the dumping of HAR say after 2 or 3 seconds then this error does not occur. Is there any event listener which we have used in the previous version of har-export-triggerExport-0.5.0-beta.7, where we specify the below code before dumping of HAR so that we can wait for the event before dumping of the HAR.
This is a very high priority bug for us can you please address this issue and give us a workaround.
Regards, Farooq.