Skip to content

Commit 9d08a5c

Browse files
committed
[javascript] Display info about SM activity
JS part of #11385
1 parent 778cf32 commit 9d08a5c

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

javascript/node/selenium-webdriver/common/driverFinder.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function getPath(service, capabilities) {
3434
throw Error(
3535
`Unable to obtain browser driver.
3636
For more information on how to install drivers see
37-
https://www.selenium.dev/documentation/webdriver/getting_started/install_drivers/. ${e}`
37+
https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location/. ${e}`
3838
)
3939
}
4040
}

javascript/node/selenium-webdriver/common/seleniumManager.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const path = require('path')
2626
const fs = require('fs')
2727
const 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

6368
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-
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

Comments
 (0)