@@ -46,18 +46,22 @@ class SeleniumBiDiHarRecorder {
4646
4747 this . bidi = await this . _driver . getBidi ( ) ;
4848
49+ await this . bidi . subscribe (
50+ "browsingContext.contextCreated" ,
51+ this . _browsingContextIds ,
52+ ) ;
4953 await this . bidi . subscribe (
5054 "browsingContext.domContentLoaded" ,
51- this . _browsingContextIds
55+ this . _browsingContextIds ,
5256 ) ;
5357 await this . bidi . subscribe ( "browsingContext.load" , this . _browsingContextIds ) ;
5458 await this . bidi . subscribe (
5559 "network.beforeRequestSent" ,
56- this . _browsingContextIds
60+ this . _browsingContextIds ,
5761 ) ;
5862 await this . bidi . subscribe (
5963 "network.responseCompleted" ,
60- this . _browsingContextIds
64+ this . _browsingContextIds ,
6165 ) ;
6266
6367 this . ws = await this . bidi . socket ;
@@ -76,21 +80,25 @@ class SeleniumBiDiHarRecorder {
7680 async stopRecording ( ) {
7781 this . ws . off ( "message" , this . _onMessage ) ;
7882
83+ await this . bidi . unsubscribe (
84+ "browsingContext.contextCreated" ,
85+ this . _browsingContextIds ,
86+ ) ;
7987 await this . bidi . unsubscribe (
8088 "browsingContext.domContentLoaded" ,
81- this . _browsingContextIds
89+ this . _browsingContextIds ,
8290 ) ;
8391 await this . bidi . unsubscribe (
8492 "browsingContext.load" ,
85- this . _browsingContextIds
93+ this . _browsingContextIds ,
8694 ) ;
8795 await this . bidi . unsubscribe (
8896 "network.beforeRequestSent" ,
89- this . _browsingContextIds
97+ this . _browsingContextIds ,
9098 ) ;
9199 await this . bidi . unsubscribe (
92100 "network.responseCompleted" ,
93- this . _browsingContextIds
101+ this . _browsingContextIds ,
94102 ) ;
95103
96104 const lastPageUrl = await this . _getPageUrl ( ) ;
@@ -108,13 +116,13 @@ class SeleniumBiDiHarRecorder {
108116 try {
109117 const browsingContextId = this . _browsingContextIds [ 0 ] ;
110118 const params = {
111- method : ' browsingContext.getTree' ,
119+ method : " browsingContext.getTree" ,
112120 params : {
113121 root : browsingContextId ,
114122 } ,
115- }
123+ } ;
116124
117- const response = await this . bidi . send ( params )
125+ const response = await this . bidi . send ( params ) ;
118126 pageUrl = response . result . contexts [ 0 ] . url ;
119127 } catch ( e ) {
120128 // Could not fetch page url.
0 commit comments