selenium-webdriver 4.6.1 → 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 CHANGED
@@ -1,3 +1,28 @@
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
+
15
+ ## v4.7.0
16
+
17
+ #### :rocket: New Feature
18
+
19
+ * Add support for Selenium Manager to work with IE Driver
20
+
21
+ #### :nail_care: Polish
22
+
23
+ * Adding CDP files for v108 and removing v105
24
+ * Improve error handling for Selenium Manager
25
+
1
26
  ## v4.6.1
2
27
 
3
28
  #### :bug: Bug Fix
Binary file
Binary file
Binary file
@@ -76,12 +76,12 @@ function driverLocation(browser) {
76
76
  result = execSync(args.join(' ')).toString()
77
77
  } catch (e) {
78
78
  throw new Error(
79
- `Error executing command with ${args} : Error ${e.stderr.toString()}`
79
+ `Error executing command with ${args}\n${e.stdout.toString()}${e.stderr.toString()}`
80
80
  )
81
81
  }
82
82
 
83
83
  if (!result.startsWith('INFO\t')) {
84
- throw new Error(`Unsuccessful command executed ${args}}`)
84
+ throw new Error(`Unsuccessful command executed: ${args}\n${result}`)
85
85
  }
86
86
 
87
87
  return result.replace('INFO\t', '').trim()
package/ie.js CHANGED
@@ -35,6 +35,7 @@ const remote = require('./remote')
35
35
  const webdriver = require('./lib/webdriver')
36
36
  const { Browser, Capabilities } = require('./lib/capabilities')
37
37
  const error = require('./lib/error')
38
+ const { driverLocation } = require('./common/seleniumManager')
38
39
 
39
40
  const IEDRIVER_EXE = 'IEDriverServer.exe'
40
41
  const OPTIONS_CAPABILITY_KEY = 'se:ieOptions'
@@ -399,6 +400,18 @@ function createServiceFromCapabilities(capabilities) {
399
400
  }
400
401
 
401
402
  let exe = locateSynchronously()
403
+ if (!exe) {
404
+ console.log(
405
+ `The ${IEDRIVER_EXE} executable could not be found on the current PATH, trying Selenium Manager`
406
+ )
407
+
408
+ try {
409
+ exe = driverLocation(Browser.INTERNET_EXPLORER)
410
+ } catch (err) {
411
+ console.log(`Unable to obtain driver using Selenium Manager: ${err}`)
412
+ }
413
+ }
414
+
402
415
  if (!exe || !fs.existsSync(exe)) {
403
416
  throw Error(
404
417
  `${IEDRIVER_EXE} could not be found on the current PATH. Please ` +
package/io/zip.js CHANGED
@@ -68,8 +68,8 @@ class Zip {
68
68
  * @param {string} dirPath path to the directory to add.
69
69
  * @param {string=} zipPath path to the folder in the archive to add the
70
70
  * directory contents to. Defaults to the root folder.
71
- * @return {!Promise<?>} returns a promise that will resolve when the
72
- * the operation is complete.
71
+ * @return {!Promise<?>} returns a promise that will resolve when
72
+ * the operation is complete.
73
73
  */
74
74
  addDir(dirPath, zipPath = '') {
75
75
  return io.walkDir(dirPath).then((entries) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "selenium-webdriver",
3
- "version": "4.6.1",
3
+ "version": "4.7.1",
4
4
  "description": "The official WebDriver JavaScript bindings from the Selenium project",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -28,18 +28,18 @@
28
28
  "ws": ">=8.7.0"
29
29
  },
30
30
  "devDependencies": {
31
- "eslint": "^8.16.0",
31
+ "eslint": "^8.27.0",
32
32
  "eslint-config-prettier": "^8.5.0",
33
- "eslint-plugin-no-only-tests": "^2.6.0",
33
+ "eslint-plugin-no-only-tests": "^3.1.0",
34
34
  "eslint-plugin-node": "^11.1.0",
35
- "eslint-plugin-prettier": "^4.0.0",
36
- "express": "^4.17.1",
37
- "jasmine": "^3.8.0",
38
- "mocha": "^10.0.0",
35
+ "eslint-plugin-prettier": "^4.2.0",
36
+ "express": "^4.18.2",
37
+ "jasmine": "^4.5.0",
38
+ "mocha": "^10.1.0",
39
39
  "multer": "^1.4.5-lts.1",
40
- "prettier": "^2.6.1",
40
+ "prettier": "^2.7.1",
41
41
  "serve-index": "^1.9.1",
42
- "sinon": "^10.0.0"
42
+ "sinon": "^14.0.2"
43
43
  },
44
44
  "scripts": {
45
45
  "lint": "eslint --ignore-pattern node_modules --ignore-pattern generator --fix --ext js lib/http.js \"**/*.js\"",
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
- var serverUrl = url.format({
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
- return jvmArgs.concat('-jar', jar, '-port', port).concat(args)
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
- let java = 'java'
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
+ }