File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed
Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -113,9 +113,32 @@ function _validateInteger(value) {
113113 ignoreHTTPSErrors : true ,
114114 } )
115115 . then ( async function ( browser ) {
116+ const MAX_WAITING_TIME_ACCESS_URL = 5000 ;
117+
116118 const page = await browser . newPage ( ) ;
117119 await page . setViewport ( viewportOptions ) ;
118- await page . goto ( options . url , { waitUntil : [ "networkidle2" ] } ) ;
120+ await page . goto ( options . url , { waitUntil : "networkidle2" } ) ;
121+
122+ if ( new URL ( options . url ) . pathname . startsWith ( "/go/" ) ) {
123+ console . log ( "Waiting for response" ) ;
124+ let responseEventOccurred = false ;
125+ const responseHandler = ( _event ) => ( responseEventOccurred = true ) ;
126+
127+ const responseWatcher = new Promise ( function ( resolve , _reject ) {
128+ setTimeout ( ( ) => {
129+ if ( ! responseEventOccurred ) {
130+ resolve ( ) ;
131+ } else {
132+ setTimeout ( ( ) => resolve ( ) , MAX_WAITING_TIME_ACCESS_URL ) ;
133+ }
134+ } , 500 ) ;
135+ } ) ;
136+
137+ page . on ( "response" , responseHandler ) ;
138+
139+ await Promise . race ( [ responseWatcher , page . waitForNavigation ( ) ] ) ;
140+ }
141+
119142 await page . focus ( "body" ) ;
120143 await page . screenshot ( screenshotOptions ) ;
121144
You can’t perform that action at this time.
0 commit comments