@@ -26,7 +26,7 @@ const path = require('path')
2626const fs = require ( 'fs' )
2727const spawnSync = require ( 'child_process' ) . spawnSync
2828
29- let debugMessagePrinted = { } ;
29+ let debugMessagePrinted = false ;
3030
3131/**
3232 * Determines the path of the correct Selenium Manager binary
@@ -51,6 +51,11 @@ function getBinary() {
5151 throw new Error ( `Unable to obtain Selenium Manager` )
5252 }
5353
54+ if ( ! debugMessagePrinted ) {
55+ console . debug ( `Selenium Manager binary found at ${ filePath } ` )
56+ debugMessagePrinted = true ; // Set the flag to true after printing the debug message
57+ }
58+
5459 return filePath
5560}
5661
@@ -61,15 +66,6 @@ function getBinary() {
6166 */
6267
6368function driverLocation ( options ) {
64- const browserName = options . getBrowserName ( ) . toLocaleLowerCase ( ) ;
65-
66- if ( ! debugMessagePrinted [ browserName ] ) {
67- console . debug (
68- `Applicable driver not found for ${ browserName } ; attempting to install with Selenium Manager (Beta)`
69- )
70- debugMessagePrinted [ browserName ] = true ; // Set the flag to true after printing the debug message
71- }
72-
7369 let args = [ '--browser' , options . getBrowserName ( ) , '--output' , 'json' ]
7470
7571 if ( options . getBrowserVersion ( ) && options . getBrowserVersion ( ) !== '' ) {
@@ -111,6 +107,7 @@ function driverLocation(options) {
111107 if ( spawnResult . stdout . toString ( ) ) {
112108 try {
113109 output = JSON . parse ( spawnResult . stdout . toString ( ) )
110+ logOutput ( output )
114111 errorMessage = output . result . message
115112 } catch ( e ) {
116113 errorMessage = e . toString ( )
@@ -122,19 +119,27 @@ function driverLocation(options) {
122119 }
123120 try {
124121 output = JSON . parse ( spawnResult . stdout . toString ( ) )
122+ console . log ( output )
125123 } catch ( e ) {
126124 throw new Error (
127125 `Error executing command for ${ smBinary } with ${ args } : ${ e . toString ( ) } `
128126 )
129127 }
130128
129+ logOutput ( output )
130+
131+ return output . result . message
132+ }
133+
134+ function logOutput ( output ) {
131135 for ( const key in output . logs ) {
132136 if ( output . logs [ key ] . level === 'WARN' ) {
133137 console . warn ( `${ output . logs [ key ] . message } ` )
134138 }
139+ if ( [ 'DEBUG' , 'INFO' ] . includes ( output . logs [ key ] . level ) ) {
140+ console . debug ( `${ output . logs [ key ] . message } ` )
141+ }
135142 }
136-
137- return output . result . message
138143}
139144
140145// PUBLIC API
0 commit comments