@@ -146,10 +146,15 @@ export class SeleniumService {
146146 ) ;
147147
148148 const seleniumServerBaseUrl = `http://${ containerName } :${ dockerizedConfig . seleniumPort } ` ;
149- await this . waitForSeleniumServer (
150- seleniumServerBaseUrl ,
151- dockerizedConfig . startupTimeoutMs ,
152- ) ;
149+ try {
150+ await this . waitForSeleniumServer (
151+ seleniumServerBaseUrl ,
152+ dockerizedConfig . startupTimeoutMs ,
153+ ) ;
154+ } catch ( err ) {
155+ await this . dockerService . removeContainer ( containerName ) ;
156+ throw err ;
157+ }
153158
154159 return await this . buildDockerizedDriver (
155160 browser ,
@@ -322,11 +327,29 @@ export class SeleniumService {
322327 value ?: { ready ?: boolean } ;
323328 } ;
324329 if ( body . value ?. ready === true ) {
330+ console . log (
331+ 'Dockerized Selenium server ' +
332+ seleniumServerBaseUrl +
333+ ' is ready' ,
334+ ) ;
325335 return ;
336+ } else {
337+ console . warn (
338+ `Selenium server at ${ seleniumServerBaseUrl } responded but is not ready yet, retrying...` ,
339+ ) ;
340+ console . warn ( 'Response body:' , body ) ;
326341 }
342+ } else {
343+ console . warn (
344+ `Selenium server responded with status ${ response . status } , retrying...` ,
345+ ) ;
346+ console . warn ( 'Response body:' , await response . text ( ) ) ;
327347 }
328- } catch {
329- // Selenium is still booting, retry until timeout.
348+ } catch ( error ) {
349+ console . warn (
350+ 'Failed to connect to dockerized Selenium, retrying...' ,
351+ error ,
352+ ) ;
330353 }
331354 await new Promise ( resolve => setTimeout ( resolve , 1000 ) ) ;
332355 }
0 commit comments