MCPcopy Index your code
hub / github.com/SeleniumHQ/selenium / formatSpawnArgs

Function formatSpawnArgs

javascript/selenium-webdriver/remote/util.js:50–80  ·  view source on GitHub ↗

* @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)

Source from the content-addressed store, hash-verified

48 * @returns {Array.<string>}
49 */
50function 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
83module.exports = {

Callers 1

constructorMethod · 0.85

Calls 4

isSelenium3xFunction · 0.85
warningMethod · 0.80
getLoggerMethod · 0.80
fromMethod · 0.45

Tested by

no test coverage detected