* Determines the path of the correct driver * @param {string[]} args arguments to invoke Selenium Manager * @returns {{browserPath: string, driverPath: string}} path of the driver and * browser location
(args)
| 68 | */ |
| 69 | |
| 70 | function binaryPaths(args) { |
| 71 | const smBinary = getBinary() |
| 72 | const spawnResult = spawnSync(smBinary, args) |
| 73 | let output |
| 74 | if (spawnResult.status) { |
| 75 | let errorMessage |
| 76 | if (spawnResult.stderr.toString()) { |
| 77 | errorMessage = spawnResult.stderr.toString() |
| 78 | } |
| 79 | if (spawnResult.stdout.toString()) { |
| 80 | try { |
| 81 | output = JSON.parse(spawnResult.stdout.toString()) |
| 82 | logOutput(output) |
| 83 | errorMessage = output.result.message |
| 84 | } catch (e) { |
| 85 | errorMessage = e.toString() |
| 86 | } |
| 87 | } |
| 88 | throw new Error(`Error executing command for ${smBinary} with ${args}: ${errorMessage}`) |
| 89 | } |
| 90 | try { |
| 91 | output = JSON.parse(spawnResult.stdout.toString()) |
| 92 | } catch (e) { |
| 93 | throw new Error(`Error executing command for ${smBinary} with ${args}: ${e.toString()}`, { cause: e }) |
| 94 | } |
| 95 | |
| 96 | logOutput(output) |
| 97 | return { |
| 98 | driverPath: output.result.driver_path, |
| 99 | browserPath: output.result.browser_path, |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | function logOutput(output) { |
| 104 | for (const key in output.logs) { |
no test coverage detected