@@ -26,7 +26,7 @@ const path = require('path')
26
26
const fs = require ( 'fs' )
27
27
const spawnSync = require ( 'child_process' ) . spawnSync
28
28
29
- let debugMessagePrinted = { } ;
29
+ let debugMessagePrinted = false ;
30
30
31
31
/**
32
32
* Determines the path of the correct Selenium Manager binary
@@ -51,6 +51,11 @@ function getBinary() {
51
51
throw new Error ( `Unable to obtain Selenium Manager` )
52
52
}
53
53
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
+
54
59
return filePath
55
60
}
56
61
@@ -61,15 +66,6 @@ function getBinary() {
61
66
*/
62
67
63
68
function 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
-
73
69
let args = [ '--browser' , options . getBrowserName ( ) , '--output' , 'json' ]
74
70
75
71
if ( options . getBrowserVersion ( ) && options . getBrowserVersion ( ) !== '' ) {
@@ -111,6 +107,7 @@ function driverLocation(options) {
111
107
if ( spawnResult . stdout . toString ( ) ) {
112
108
try {
113
109
output = JSON . parse ( spawnResult . stdout . toString ( ) )
110
+ logOutput ( output )
114
111
errorMessage = output . result . message
115
112
} catch ( e ) {
116
113
errorMessage = e . toString ( )
@@ -122,19 +119,27 @@ function driverLocation(options) {
122
119
}
123
120
try {
124
121
output = JSON . parse ( spawnResult . stdout . toString ( ) )
122
+ console . log ( output )
125
123
} catch ( e ) {
126
124
throw new Error (
127
125
`Error executing command for ${ smBinary } with ${ args } : ${ e . toString ( ) } `
128
126
)
129
127
}
130
128
129
+ logOutput ( output )
130
+
131
+ return output . result . message
132
+ }
133
+
134
+ function logOutput ( output ) {
131
135
for ( const key in output . logs ) {
132
136
if ( output . logs [ key ] . level === 'WARN' ) {
133
137
console . warn ( `${ output . logs [ key ] . message } ` )
134
138
}
139
+ if ( [ 'DEBUG' , 'INFO' ] . includes ( output . logs [ key ] . level ) ) {
140
+ console . debug ( `${ output . logs [ key ] . message } ` )
141
+ }
135
142
}
136
-
137
- return output . result . message
138
143
}
139
144
140
145
// PUBLIC API
0 commit comments