* @param {string} seleniumStandalonePath path to standalone server * @param {Array. } args spawn arguments array * returns formatted args based on selenium standalone server version * @returns {Array. }
(seleniumStandalonePath, args)
| 48 | * @returns {Array.<string>} |
| 49 | */ |
| 50 | function formatSpawnArgs(seleniumStandalonePath, args) { |
| 51 | if (isSelenium3x(seleniumStandalonePath)) { |
| 52 | logging |
| 53 | .getLogger(logging.Type.SERVER) |
| 54 | .warning('Deprecation: Support for Standalone Server 3.x will be removed soon. Please update to version 4.x') |
| 55 | return args |
| 56 | } |
| 57 | |
| 58 | const standaloneArg = 'standalone' |
| 59 | const port3xArgFormat = '-port' |
| 60 | const port4xArgFormat = '--port' |
| 61 | |
| 62 | let formattedArgs = Array.from(args) |
| 63 | |
| 64 | const standaloneArgIndex = formattedArgs.findIndex((arg) => arg === seleniumStandalonePath) |
| 65 | const v3portArgFormat = formattedArgs.findIndex((arg) => arg === port3xArgFormat) |
| 66 | |
| 67 | // old v3x port arg format was -port, new v4x port arg format is --port |
| 68 | if (v3portArgFormat !== -1) { |
| 69 | formattedArgs[v3portArgFormat] = port4xArgFormat |
| 70 | } |
| 71 | |
| 72 | // 'standalone' arg should be right after jar file path |
| 73 | // in case if it is already in place - returns args |
| 74 | if (formattedArgs[standaloneArgIndex + 1] === standaloneArg) return formattedArgs |
| 75 | |
| 76 | // insert 'standalone' right after jar file path |
| 77 | formattedArgs.splice(standaloneArgIndex + 1, 0, standaloneArg) |
| 78 | |
| 79 | return formattedArgs |
| 80 | } |
| 81 | |
| 82 | // PUBLIC API |
| 83 | module.exports = { |
no test coverage detected