selenium-webdriver 4.17.0 → 4.18.0

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.
Files changed (59) hide show
  1. package/CHANGES.md +236 -196
  2. package/bidi/addInterceptParameters.js +86 -0
  3. package/bidi/browsingContext.js +144 -37
  4. package/bidi/browsingContextInspector.js +13 -40
  5. package/bidi/evaluateResult.js +4 -10
  6. package/bidi/filterBy.js +2 -6
  7. package/bidi/index.js +31 -29
  8. package/bidi/input.js +1 -4
  9. package/bidi/interceptPhase.js +24 -0
  10. package/bidi/logInspector.js +15 -20
  11. package/bidi/network.js +178 -0
  12. package/bidi/networkInspector.js +8 -2
  13. package/bidi/networkTypes.js +22 -49
  14. package/bidi/protocolType.js +3 -9
  15. package/bidi/protocolValue.js +6 -25
  16. package/bidi/realmInfo.js +2 -10
  17. package/bidi/scriptManager.js +20 -59
  18. package/bidi/urlPattern.js +58 -0
  19. package/bin/linux/selenium-manager +0 -0
  20. package/bin/macos/selenium-manager +0 -0
  21. package/bin/windows/selenium-manager.exe +0 -0
  22. package/chrome.js +1 -8
  23. package/chromium.js +27 -109
  24. package/common/driverFinder.js +1 -1
  25. package/common/seleniumManager.js +9 -18
  26. package/devtools/CDPConnection.js +1 -3
  27. package/edge.js +1 -3
  28. package/example/chrome_android.js +2 -5
  29. package/example/chrome_mobile_emulation.js +2 -4
  30. package/example/google_search.js +1 -3
  31. package/example/headless.js +4 -10
  32. package/example/logging.js +3 -9
  33. package/firefox.js +55 -109
  34. package/http/index.js +7 -10
  35. package/ie.js +5 -15
  36. package/index.js +7 -29
  37. package/io/exec.js +1 -2
  38. package/io/index.js +3 -3
  39. package/io/zip.js +8 -30
  40. package/lib/by.js +2 -9
  41. package/lib/capabilities.js +3 -9
  42. package/lib/command.js +3 -3
  43. package/lib/error.js +2 -9
  44. package/lib/http.js +34 -131
  45. package/lib/input.js +10 -34
  46. package/lib/logging.js +3 -11
  47. package/lib/promise.js +2 -7
  48. package/lib/select.js +3 -9
  49. package/lib/until.js +28 -49
  50. package/lib/util.js +1 -4
  51. package/lib/virtual_authenticator.js +4 -22
  52. package/lib/webdriver.js +118 -297
  53. package/lib/webelement.js +1 -5
  54. package/net/index.js +1 -4
  55. package/package.json +2 -1
  56. package/remote/index.js +9 -24
  57. package/remote/util.js +6 -19
  58. package/safari.js +3 -8
  59. package/testing/index.js +6 -11
package/lib/webelement.js CHANGED
@@ -33,11 +33,7 @@ const ELEMENT_ID_KEY = 'element-6066-11e4-a52e-4f735466cecf'
33
33
  * @return {boolean} whether the object is a valid encoded WebElement ID.
34
34
  */
35
35
  function isId(obj) {
36
- return (
37
- isObject(obj) &&
38
- (typeof obj[ELEMENT_ID_KEY] === 'string' ||
39
- typeof obj[LEGACY_ELEMENT_ID_KEY] === 'string')
40
- )
36
+ return isObject(obj) && (typeof obj[ELEMENT_ID_KEY] === 'string' || typeof obj[LEGACY_ELEMENT_ID_KEY] === 'string')
41
37
  }
42
38
 
43
39
  /**
package/net/index.js CHANGED
@@ -48,10 +48,7 @@ function getIPAddress(loopback, family) {
48
48
  }
49
49
 
50
50
  for (let ipAddress of interfaces[key]) {
51
- if (
52
- (ipAddress.family === family || `IPv${ipAddress.family}` === family) &&
53
- ipAddress.internal === loopback
54
- ) {
51
+ if ((ipAddress.family === family || `IPv${ipAddress.family}` === family) && ipAddress.internal === loopback) {
55
52
  return ipAddress.address
56
53
  }
57
54
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "selenium-webdriver",
3
- "version": "4.17.0",
3
+ "version": "4.18.0",
4
4
  "description": "The official WebDriver JavaScript bindings from the Selenium project",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -42,6 +42,7 @@
42
42
  },
43
43
  "scripts": {
44
44
  "lint": "eslint --ignore-pattern node_modules --ignore-pattern generator --ext js lib/http.js \"**/*.js\"",
45
+ "lint:fix": "eslint --ignore-pattern node_modules --ignore-pattern generator --ext js lib/http.js \"**/*.js\" --fix",
45
46
  "test": "npm run lint && mocha -t 600000 --recursive test",
46
47
  "test-jasmine": "bazel test //javascript/node/selenium-webdriver:tests"
47
48
  },
package/remote/index.js CHANGED
@@ -242,9 +242,7 @@ class DriverService {
242
242
 
243
243
  let hostname = self.hostname_
244
244
  if (!hostname) {
245
- hostname =
246
- (!self.loopbackOnly_ && net.getAddress()) ||
247
- net.getLoopbackAddress()
245
+ hostname = (!self.loopbackOnly_ && net.getAddress()) || net.getLoopbackAddress()
248
246
  }
249
247
 
250
248
  const serverUrl = url.format({
@@ -255,9 +253,7 @@ class DriverService {
255
253
  })
256
254
 
257
255
  return new Promise((fulfill, reject) => {
258
- let cancelToken = earlyTermination.catch((e) =>
259
- reject(Error(e.message))
260
- )
256
+ let cancelToken = earlyTermination.catch((e) => reject(Error(e.message)))
261
257
 
262
258
  httpUtil.waitForServer(serverUrl, timeout, cancelToken).then(
263
259
  (_) => fulfill(serverUrl),
@@ -267,11 +263,11 @@ class DriverService {
267
263
  } else {
268
264
  reject(err)
269
265
  }
270
- }
266
+ },
271
267
  )
272
268
  })
273
269
  })
274
- })
270
+ }),
275
271
  )
276
272
  })
277
273
 
@@ -302,9 +298,7 @@ class DriverService {
302
298
  */
303
299
  function resolveCommandLineFlags(args) {
304
300
  // Resolve the outer array, then the individual flags.
305
- return Promise.resolve(args).then(
306
- /** !Array<CommandLineFlag> */ (args) => Promise.all(args)
307
- )
301
+ return Promise.resolve(args).then(/** !Array<CommandLineFlag> */ (args) => Promise.all(args))
308
302
  }
309
303
 
310
304
  /**
@@ -478,18 +472,12 @@ class SeleniumServer extends DriverService {
478
472
  }
479
473
 
480
474
  let port = options.port || portprober.findFreePort()
481
- let args = Promise.all([
482
- port,
483
- options.jvmArgs || [],
484
- options.args || [],
485
- ]).then((resolved) => {
475
+ let args = Promise.all([port, options.jvmArgs || [], options.args || []]).then((resolved) => {
486
476
  let port = resolved[0]
487
477
  let jvmArgs = resolved[1]
488
478
  let args = resolved[2]
489
479
 
490
- const fullArgsList = jvmArgs
491
- .concat('-jar', jar, '-port', port)
492
- .concat(args)
480
+ const fullArgsList = jvmArgs.concat('-jar', jar, '-port', port).concat(args)
493
481
 
494
482
  return formatSpawnArgs(jar, fullArgsList)
495
483
  })
@@ -608,10 +596,7 @@ class FileDetector extends input.FileDetector {
608
596
  .then(() => zip.toBuffer())
609
597
  .then((buf) => buf.toString('base64'))
610
598
  .then((encodedZip) => {
611
- let command = new cmd.Command(cmd.Name.UPLOAD_FILE).setParameter(
612
- 'file',
613
- encodedZip
614
- )
599
+ let command = new cmd.Command(cmd.Name.UPLOAD_FILE).setParameter('file', encodedZip)
615
600
  return driver.execute(command)
616
601
  })
617
602
  },
@@ -620,7 +605,7 @@ class FileDetector extends input.FileDetector {
620
605
  return file // Not a file; return original input.
621
606
  }
622
607
  throw err
623
- }
608
+ },
624
609
  )
625
610
  }
626
611
  }
package/remote/util.js CHANGED
@@ -26,9 +26,7 @@ const logging = require('../lib/logging')
26
26
  * @returns {string}
27
27
  */
28
28
  function getJavaPath() {
29
- return process.env['JAVA_HOME']
30
- ? path.join(process.env['JAVA_HOME'], 'bin/java')
31
- : 'java'
29
+ return process.env['JAVA_HOME'] ? path.join(process.env['JAVA_HOME'], 'bin/java') : 'java'
32
30
  }
33
31
 
34
32
  /**
@@ -38,11 +36,7 @@ function getJavaPath() {
38
36
  function isSelenium3x(seleniumStandalonePath) {
39
37
  const javaPath = getJavaPath()
40
38
 
41
- const execRes = cp.execFileSync(javaPath, [
42
- '-jar',
43
- seleniumStandalonePath,
44
- '--version',
45
- ])
39
+ const execRes = cp.execFileSync(javaPath, ['-jar', seleniumStandalonePath, '--version'])
46
40
 
47
41
  return execRes.toString().trim().startsWith('Selenium server version: 3')
48
42
  }
@@ -57,9 +51,7 @@ function formatSpawnArgs(seleniumStandalonePath, args) {
57
51
  if (isSelenium3x(seleniumStandalonePath)) {
58
52
  logging
59
53
  .getLogger(logging.Type.SERVER)
60
- .warning(
61
- 'Deprecation: Support for Standalone Server 3.x will be removed soon. Please update to version 4.x',
62
- )
54
+ .warning('Deprecation: Support for Standalone Server 3.x will be removed soon. Please update to version 4.x')
63
55
  return args
64
56
  }
65
57
 
@@ -69,12 +61,8 @@ function formatSpawnArgs(seleniumStandalonePath, args) {
69
61
 
70
62
  let formattedArgs = Array.from(args)
71
63
 
72
- const standaloneArgIndex = formattedArgs.findIndex(
73
- (arg) => arg === seleniumStandalonePath
74
- )
75
- const v3portArgFormat = formattedArgs.findIndex(
76
- (arg) => arg === port3xArgFormat
77
- )
64
+ const standaloneArgIndex = formattedArgs.findIndex((arg) => arg === seleniumStandalonePath)
65
+ const v3portArgFormat = formattedArgs.findIndex((arg) => arg === port3xArgFormat)
78
66
 
79
67
  // old v3x port arg format was -port, new v4x port arg format is --port
80
68
  if (v3portArgFormat !== -1) {
@@ -83,8 +71,7 @@ function formatSpawnArgs(seleniumStandalonePath, args) {
83
71
 
84
72
  // 'standalone' arg should be right after jar file path
85
73
  // in case if it is already in place - returns args
86
- if (formattedArgs[standaloneArgIndex + 1] === standaloneArg)
87
- return formattedArgs
74
+ if (formattedArgs[standaloneArgIndex + 1] === standaloneArg) return formattedArgs
88
75
 
89
76
  // insert 'standalone' right after jar file path
90
77
  formattedArgs.splice(standaloneArgIndex + 1, 0, standaloneArg)
package/safari.js CHANGED
@@ -95,8 +95,7 @@ function useTechnologyPreview(o) {
95
95
  return false
96
96
  }
97
97
 
98
- const SAFARIDRIVER_TECHNOLOGY_PREVIEW_EXE =
99
- '/Applications/Safari Technology Preview.app/Contents/MacOS/safaridriver'
98
+ const SAFARIDRIVER_TECHNOLOGY_PREVIEW_EXE = '/Applications/Safari Technology Preview.app/Contents/MacOS/safaridriver'
100
99
 
101
100
  /**
102
101
  * A WebDriver client for Safari. This class should never be instantiated
@@ -126,13 +125,9 @@ class Driver extends webdriver.WebDriver {
126
125
  if (!service.getExecutable()) {
127
126
  service.setExecutable(getPath(caps).driverPath)
128
127
  }
129
- let executor = new http.Executor(
130
- service.start().then((url) => new http.HttpClient(url))
131
- )
128
+ let executor = new http.Executor(service.start().then((url) => new http.HttpClient(url)))
132
129
 
133
- return /** @type {!Driver} */ (
134
- super.createSession(executor, caps, () => service.kill())
135
- )
130
+ return /** @type {!Driver} */ (super.createSession(executor, caps, () => service.kill()))
136
131
  }
137
132
  }
138
133
 
package/testing/index.js CHANGED
@@ -214,7 +214,7 @@ function init(force = false) {
214
214
  if (seleniumJar && seleniumUrl) {
215
215
  throw Error(
216
216
  'Ambiguous test configuration: both SELENIUM_REMOTE_URL' +
217
- ' && SELENIUM_SERVER_JAR environment variables are set'
217
+ ' && SELENIUM_SERVER_JAR environment variables are set',
218
218
  )
219
219
  }
220
220
 
@@ -223,14 +223,12 @@ function init(force = false) {
223
223
  throw Error(
224
224
  'Ambiguous test configuration: when either the SELENIUM_REMOTE_URL or' +
225
225
  ' SELENIUM_SERVER_JAR environment variable is set, the' +
226
- ' SELENIUM_BROWSER variable must also be set.'
226
+ ' SELENIUM_BROWSER variable must also be set.',
227
227
  )
228
228
  }
229
229
 
230
230
  targetBrowsers = envBrowsers.length > 0 ? envBrowsers : getAvailableBrowsers()
231
- info(
232
- `Running tests against [${targetBrowsers.map((b) => b.name).join(', ')}]`
233
- )
231
+ info(`Running tests against [${targetBrowsers.map((b) => b.name).join(', ')}]`)
234
232
 
235
233
  after(function () {
236
234
  if (seleniumServer) {
@@ -240,8 +238,7 @@ function init(force = false) {
240
238
  }
241
239
 
242
240
  const TARGET_MAP = /** !WeakMap<!Environment, !TargetBrowser> */ new WeakMap()
243
- const URL_MAP =
244
- /** !WeakMap<!Environment, ?(string|remote.SeleniumServer)> */ new WeakMap()
241
+ const URL_MAP = /** !WeakMap<!Environment, ?(string|remote.SeleniumServer)> */ new WeakMap()
245
242
 
246
243
  /**
247
244
  * Defines the environment a {@linkplain suite test suite} is running against.
@@ -254,9 +251,7 @@ class Environment {
254
251
  * Selenium server to test against.
255
252
  */
256
253
  constructor(browser, url = undefined) {
257
- browser = /** @type {!TargetBrowser} */ (
258
- Object.seal(Object.assign({}, browser))
259
- )
254
+ browser = /** @type {!TargetBrowser} */ (Object.seal(Object.assign({}, browser)))
260
255
 
261
256
  TARGET_MAP.set(this, browser)
262
257
  URL_MAP.set(this, url || null)
@@ -495,7 +490,7 @@ function getTestHook(name) {
495
490
  throw TypeError(
496
491
  `Expected global.${name} to be a function, but is ${type}.` +
497
492
  ' This can happen if you try using this module when running with' +
498
- ' node directly instead of using jasmine or mocha'
493
+ ' node directly instead of using jasmine or mocha',
499
494
  )
500
495
  }
501
496
  return fn