selenium-webdriver 4.7.0 → 4.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGES.md +14 -0
- package/package.json +1 -1
- package/remote/index.js +13 -7
- package/remote/util.js +93 -0
package/CHANGES.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## v4.7.1
|
|
2
|
+
|
|
3
|
+
#### :nail_care: Polish
|
|
4
|
+
|
|
5
|
+
* feat/deprecation message for standalone3x (#11422)
|
|
6
|
+
|
|
7
|
+
#### :bug: Bug Fix
|
|
8
|
+
|
|
9
|
+
* feat/fix spawn format for SeleniumServer, issue 11405 (#11412)
|
|
10
|
+
|
|
11
|
+
#### Committers: 1
|
|
12
|
+
|
|
13
|
+
- Potapov Dmitriy ([@potapovDim](https://github.com/potapovDim))
|
|
14
|
+
|
|
1
15
|
## v4.7.0
|
|
2
16
|
|
|
3
17
|
#### :rocket: New Feature
|
package/package.json
CHANGED
package/remote/index.js
CHANGED
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
'use strict'
|
|
19
19
|
|
|
20
20
|
const fs = require('fs')
|
|
21
|
-
const path = require('path')
|
|
22
21
|
const url = require('url')
|
|
23
22
|
|
|
24
23
|
const httpUtil = require('../http/util')
|
|
@@ -29,6 +28,9 @@ const cmd = require('../lib/command')
|
|
|
29
28
|
const input = require('../lib/input')
|
|
30
29
|
const net = require('../net')
|
|
31
30
|
const portprober = require('../net/portprober')
|
|
31
|
+
const logging = require('../lib/logging')
|
|
32
|
+
|
|
33
|
+
const { getJavaPath, formatSpawnArgs } = require('./util')
|
|
32
34
|
|
|
33
35
|
/**
|
|
34
36
|
* @typedef {(string|!Array<string|number|!stream.Stream|null|undefined>)}
|
|
@@ -118,6 +120,8 @@ class DriverService {
|
|
|
118
120
|
* @param {!ServiceOptions} options Configuration options for the service.
|
|
119
121
|
*/
|
|
120
122
|
constructor(executable, options) {
|
|
123
|
+
/** @private @const */
|
|
124
|
+
this.log_ = logging.getLogger('webdriver.DriverService')
|
|
121
125
|
/** @private {string} */
|
|
122
126
|
this.executable_ = executable
|
|
123
127
|
|
|
@@ -236,7 +240,7 @@ class DriverService {
|
|
|
236
240
|
net.getLoopbackAddress()
|
|
237
241
|
}
|
|
238
242
|
|
|
239
|
-
|
|
243
|
+
const serverUrl = url.format({
|
|
240
244
|
protocol: 'http',
|
|
241
245
|
hostname: hostname,
|
|
242
246
|
port: port + '',
|
|
@@ -479,13 +483,15 @@ class SeleniumServer extends DriverService {
|
|
|
479
483
|
let port = resolved[0]
|
|
480
484
|
let jvmArgs = resolved[1]
|
|
481
485
|
let args = resolved[2]
|
|
482
|
-
|
|
486
|
+
|
|
487
|
+
const fullArgsList = jvmArgs
|
|
488
|
+
.concat('-jar', jar, '-port', port)
|
|
489
|
+
.concat(args)
|
|
490
|
+
|
|
491
|
+
return formatSpawnArgs(jar, fullArgsList)
|
|
483
492
|
})
|
|
484
493
|
|
|
485
|
-
|
|
486
|
-
if (process.env['JAVA_HOME']) {
|
|
487
|
-
java = path.join(process.env['JAVA_HOME'], 'bin/java')
|
|
488
|
-
}
|
|
494
|
+
const java = getJavaPath()
|
|
489
495
|
|
|
490
496
|
super(java, {
|
|
491
497
|
loopback: options.loopback,
|
package/remote/util.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// Licensed to the Software Freedom Conservancy (SFC) under one
|
|
2
|
+
// or more contributor license agreements. See the NOTICE file
|
|
3
|
+
// distributed with this work for additional information
|
|
4
|
+
// regarding copyright ownership. The SFC licenses this file
|
|
5
|
+
// to you under the Apache License, Version 2.0 (the
|
|
6
|
+
// "License"); you may not use this file except in compliance
|
|
7
|
+
// with the License. You may obtain a copy of the License at
|
|
8
|
+
//
|
|
9
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
//
|
|
11
|
+
// Unless required by applicable law or agreed to in writing,
|
|
12
|
+
// software distributed under the License is distributed on an
|
|
13
|
+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
// KIND, either express or implied. See the License for the
|
|
15
|
+
// specific language governing permissions and limitations
|
|
16
|
+
// under the License.
|
|
17
|
+
|
|
18
|
+
'use strict'
|
|
19
|
+
|
|
20
|
+
const path = require('path')
|
|
21
|
+
const cp = require('child_process')
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* returns path to java or 'java' string if JAVA_HOME does not exist in env obj
|
|
25
|
+
* @returns {string}
|
|
26
|
+
*/
|
|
27
|
+
function getJavaPath() {
|
|
28
|
+
return process.env['JAVA_HOME']
|
|
29
|
+
? path.join(process.env['JAVA_HOME'], 'bin/java')
|
|
30
|
+
: 'java'
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @param {string} seleniumStandalonePath path to standalone server
|
|
35
|
+
* @returns {boolean}
|
|
36
|
+
*/
|
|
37
|
+
function isSelenium3x(seleniumStandalonePath) {
|
|
38
|
+
const javaPath = getJavaPath()
|
|
39
|
+
|
|
40
|
+
const execRes = cp.execSync(
|
|
41
|
+
`${javaPath} -jar ${seleniumStandalonePath} --version`
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
return execRes.toString().trim().startsWith('Selenium server version: 3')
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @param {string} seleniumStandalonePath path to standalone server
|
|
49
|
+
* @param {Array.<string>} args spawn arguments array
|
|
50
|
+
* returns formatted args based on selenium standalone server version
|
|
51
|
+
* @returns {Array.<string>}
|
|
52
|
+
*/
|
|
53
|
+
function formatSpawnArgs(seleniumStandalonePath, args) {
|
|
54
|
+
if (isSelenium3x(seleniumStandalonePath)) {
|
|
55
|
+
console.warn('Deprecation: Support for Standalone Server 3.x will be removed soon. Please update to version 4.x')
|
|
56
|
+
return args
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const standaloneArg = 'standalone'
|
|
60
|
+
const port3xArgFormat = '-port'
|
|
61
|
+
const port4xArgFormat = '--port'
|
|
62
|
+
|
|
63
|
+
let formattedArgs = Array.from(args)
|
|
64
|
+
|
|
65
|
+
const standaloneArgIndex = formattedArgs.findIndex(
|
|
66
|
+
(arg) => arg === seleniumStandalonePath
|
|
67
|
+
)
|
|
68
|
+
const v3portArgFormat = formattedArgs.findIndex(
|
|
69
|
+
(arg) => arg === port3xArgFormat
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
// old v3x port arg format was -port, new v4x port arg format is --port
|
|
73
|
+
if (v3portArgFormat !== -1) {
|
|
74
|
+
formattedArgs[v3portArgFormat] = port4xArgFormat
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// 'standalone' arg should be right after jar file path
|
|
78
|
+
// in case if it is already in place - returns args
|
|
79
|
+
if (formattedArgs[standaloneArgIndex + 1] === standaloneArg)
|
|
80
|
+
return formattedArgs
|
|
81
|
+
|
|
82
|
+
// insert 'standalone' right after jar file path
|
|
83
|
+
formattedArgs.splice(standaloneArgIndex + 1, 0, standaloneArg)
|
|
84
|
+
|
|
85
|
+
return formattedArgs
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// PUBLIC API
|
|
89
|
+
module.exports = {
|
|
90
|
+
getJavaPath,
|
|
91
|
+
isSelenium3x,
|
|
92
|
+
formatSpawnArgs,
|
|
93
|
+
}
|