def save_har(self, driver, name_override=None, *args, **kwargs):
        self._validate_mode(*args, **kwargs)

        if self._active_har:
            # Record the most recent pages timings
            self._record_page_timings(driver)
            timings = self._page_timings

            # Get the har contents from the proxy
            har = self.proxy.har

            # Record the timings from the pages
            for index, _timing in enumerate(timings):
                nav_start = timings[index]['navigationStart']
                dom_content_loaded_event_end = timings[index]['domContentLoadedEventEnd']
                load_event_end = timings[index]['loadEventEnd']
                har['log']['pages'][index]['pageTimings']['onContentLoad'] = dom_content_loaded_event_end - nav_start
                har['log']['pages'][index]['pageTimings']['onLoad'] = load_event_end - nav_start

            har_file = os.path.join(
                os.environ.get('BOK_CHOY_HAR_DIR', ''),
                '{}.har'.format(self.har_name(name_override)))
            with open(har_file, 'w') as output_file:
                json.dump(har, output_file)
                output_file.close()

            # Set this to false so that a new har will be started if new_page is called again
            self._active_har = False
Save a HAR file.
dataset/ETHPy150Open edx/bok-choy/bok_choy/performance.py/HarCapturer.save_har