firefox-devtools / har-export-trigger

Trigger HAR export any time directly from within a page.
https://addons.mozilla.org/en-US/firefox/addon/har-export-trigger/
Mozilla Public License 2.0
56 stars 15 forks source link

js is not loaded if the site is unavailable #33

Open tempo810 opened 5 years ago

tempo810 commented 5 years ago

I am using the plugin with Selenium and Firefox 65 in python. The HAR harvest script is working if I am able to get any response from remote http server. However, if the site is unreachable such as experiencing gateway timeout then HAR.triggerExport() cannot be called. My goal is to continuous monitoring http accessibility for further analysis, so it's important to export HAR no matter if the site is reachable or not. May I know if it's possible to capture HAR in every situation?

Here is the trace when site is not available: /Users/Tempo/PycharmProjects/SeleniumTest/venv/bin/python /Users/Tempo/PycharmProjects/SeleniumTest/TimeOutTest.py Traceback (most recent call last): File "/Users/Tempo/PycharmProjects/SeleniumTest/TimeOutTest.py", line 51, in <module> har_dict['log'] = ast.literal_eval(browser.execute_script(HAR_HARVEST)) File "/Users/Tempo/PycharmProjects/SeleniumTest/venv/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 636, in execute_script 'args': converted_args})['value'] File "/Users/Tempo/PycharmProjects/SeleniumTest/venv/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response) File "/Users/Tempo/PycharmProjects/SeleniumTest/venv/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.JavascriptException: Message: ReferenceError: HAR is not defined