#NEWLINE# def save_har( self , driver , name_override = None , * args , **kwargs ) : #NEWLINE# #INDENT# '\n        Save a HAR file.\n\n        The location of the har file can be configured\n        by the environment variable `BOK_CHOY_HAR_DIR`.  If not set,\n        this defaults to the current working directory.\n\n        Returns:\n            None\n        ' #NEWLINE# self . _validate_mode ( * args , ** kwargs ) #NEWLINE# if self . _active_har : #NEWLINE# #INDENT# self . _record_page_timings ( driver ) #NEWLINE# timings = self . _page_timings #NEWLINE# har = self . proxy . har #NEWLINE# for ( index , _timing ) in enumerate ( timings ) : #NEWLINE# #INDENT# nav_start = timings [ index ] [ 'navigationStart' ] #NEWLINE# dom_content_loaded_event_end = timings [ index ] [ 'domContentLoadedEventEnd' ] #NEWLINE# load_event_end = timings [ index ] [ 'loadEventEnd' ] #NEWLINE# har [ 'log' ] [ 'pages' ] [ index ] [ 'pageTimings' ] [ 'onContentLoad' ] = ( dom_content_loaded_event_end - nav_start ) #NEWLINE# har [ 'log' ] [ 'pages' ] [ index ] [ 'pageTimings' ] [ 'onLoad' ] = ( load_event_end - nav_start ) #NEWLINE# #UNINDENT# har_file = os . path . join ( os . environ . get ( 'BOK_CHOY_HAR_DIR' , '' ) , '{}.har' . format ( self . har_name ( name_override ) ) ) #NEWLINE# with open ( har_file , 'w' ) as output_file : #NEWLINE# #INDENT# json . dump ( har , output_file ) #NEWLINE# output_file . close ( ) #NEWLINE# #UNINDENT# self . _active_har = False