selenium-webdriver 4.5.0 → 4.6.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.
package/CHANGES.md CHANGED
@@ -1,3 +1,21 @@
1
+ ## v4.6.0
2
+
3
+ #### :rocket: New Feature
4
+
5
+ * [grid] Add ability to use Enter key to confirm (#11178)
6
+ * [grid][ui] Add search field for running sessions (#11197)
7
+ * Add support for selenium manager (#11189)
8
+
9
+ #### :bug: Bug Fix
10
+
11
+ * isPromise() thenable fix (#11048)
12
+ * Fix: making methods static (#11182)
13
+
14
+ #### :nail_care: Polish
15
+
16
+ * fix a tiny typo in chromium.js (#11073)
17
+ * Adding CDP files for v107 and removing v104
18
+
1
19
  ## v4.5.0
2
20
 
3
21
  #### :rocket: New Feature
Binary file
Binary file
Binary file
package/chrome.js CHANGED
@@ -130,6 +130,7 @@
130
130
  const io = require('./io')
131
131
  const { Browser } = require('./lib/capabilities')
132
132
  const chromium = require('./chromium')
133
+ const { driverLocation } = require('./common/seleniumManager')
133
134
 
134
135
  /**
135
136
  * Name of the ChromeDriver executable.
@@ -150,20 +151,35 @@ class ServiceBuilder extends chromium.ServiceBuilder {
150
151
  /**
151
152
  * @param {string=} opt_exe Path to the server executable to use. If omitted,
152
153
  * the builder will attempt to locate the chromedriver on the current
153
- * PATH.
154
+ * PATH. If the chromedriver is not available in path, selenium-manager will
155
+ * download the chromedriver
154
156
  * @throws {Error} If provided executable does not exist, or the chromedriver
155
157
  * cannot be found on the PATH.
156
158
  */
157
159
  constructor(opt_exe) {
158
160
  let exe = opt_exe || locateSynchronously()
161
+
162
+ if (!exe) {
163
+ console.log(
164
+ ` The ChromeDriver could not be found on the current PATH, trying Selenium Manager`
165
+ )
166
+
167
+ try {
168
+ exe = driverLocation(Browser.CHROME)
169
+ } catch (err) {
170
+ console.log(`Unable to obtain driver using Selenium Manager: ${err}`)
171
+ }
172
+ }
173
+
159
174
  if (!exe) {
160
175
  throw Error(
161
- `The ChromeDriver could not be found on the current PATH. Please ` +
162
- `download the latest version of the ChromeDriver from ` +
163
- `http://chromedriver.storage.googleapis.com/index.html and ensure ` +
164
- `it can be found on your PATH.`
176
+ `The ChromeDriver could not be found on the current PATH.
177
+ Please download the latest version of the ChromeDriver
178
+ from http://chromedriver.storage.googleapis.com/index.html
179
+ and ensure it can be found on your PATH.`
165
180
  )
166
181
  }
182
+
167
183
  super(exe)
168
184
  }
169
185
  }
package/chromium.js CHANGED
@@ -706,7 +706,7 @@ class Driver extends webdriver.WebDriver {
706
706
  /**
707
707
  * Schedules a command to get Chromium network emulation settings.
708
708
  * @return {!Promise} A promise that will be resolved when network
709
- * emulation settings are retrievied.
709
+ * emulation settings are retrieved.
710
710
  */
711
711
  getNetworkConditions() {
712
712
  return this.execute(new command.Command(Command.GET_NETWORK_CONDITIONS))
@@ -0,0 +1,91 @@
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
+ /**
19
+ * This implementation is still in beta, and may change.
20
+ *
21
+ * Wrapper for getting information from the Selenium Manager binaries
22
+ */
23
+
24
+ const { platform } = require('process')
25
+ const path = require('path')
26
+ const fs = require('fs')
27
+ const execSync = require('child_process').execSync
28
+
29
+ /**
30
+ * currently supported browsers for selenium-manager
31
+ * @type {string[]}
32
+ */
33
+ const Browser = ['chrome', 'firefox', 'edge']
34
+
35
+ /**
36
+ * Determines the path of the correct Selenium Manager binary
37
+ * @returns {string}
38
+ */
39
+ function getBinary() {
40
+ const directory = {
41
+ darwin: 'macos',
42
+ win32: 'windows',
43
+ cygwin: 'windows',
44
+ linux: 'linux',
45
+ }[platform]
46
+
47
+ const file =
48
+ directory === 'windows' ? 'selenium-manager.exe' : 'selenium-manager'
49
+
50
+ const filePath = path.join(__dirname, '..', '/bin', directory, file)
51
+
52
+ if (!fs.existsSync(filePath)) {
53
+ throw new Error(`Unable to obtain Selenium Manager`)
54
+ }
55
+
56
+ return filePath
57
+ }
58
+
59
+ /**
60
+ * Determines the path of the correct driver
61
+ * @param {Browser|string} browser name to fetch the driver
62
+ * @returns {string} path of the driver location
63
+ */
64
+
65
+ function driverLocation(browser) {
66
+ if (!Browser.includes(browser.toLocaleString())) {
67
+ throw new Error(
68
+ `Unable to locate driver associated with browser name: ${browser}`
69
+ )
70
+ }
71
+
72
+ let args = [getBinary(), '--browser', browser]
73
+ let result
74
+
75
+ try {
76
+ result = execSync(args.join(' ')).toString()
77
+ } catch (e) {
78
+ throw new Error(
79
+ `Error executing command with ${args} : Error ${e.stderr.toString()}`
80
+ )
81
+ }
82
+
83
+ if (!result.startsWith('INFO\t')) {
84
+ throw new Error(`Unsuccessful command executed ${args}}`)
85
+ }
86
+
87
+ return result.replace('INFO\t', '').trim()
88
+ }
89
+
90
+ // PUBLIC API
91
+ module.exports = { driverLocation }
package/edge.js CHANGED
@@ -80,6 +80,7 @@
80
80
  const { Browser } = require('./lib/capabilities')
81
81
  const io = require('./io')
82
82
  const chromium = require('./chromium')
83
+ const { driverLocation } = require('./common/seleniumManager')
83
84
 
84
85
  /**
85
86
  * Name of the EdgeDriver executable.
@@ -106,6 +107,19 @@ class ServiceBuilder extends chromium.ServiceBuilder {
106
107
  */
107
108
  constructor(opt_exe) {
108
109
  let exe = opt_exe || locateSynchronously()
110
+
111
+ if (!exe) {
112
+ console.log(
113
+ `The WebDriver for Edge could not be found on the current PATH, trying Selenium Manager`
114
+ )
115
+
116
+ try {
117
+ exe = driverLocation('edge')
118
+ } catch (err) {
119
+ console.log(`Unable to obtain driver using Selenium Manager: ${err}`)
120
+ }
121
+ }
122
+
109
123
  if (!exe) {
110
124
  throw Error(
111
125
  `The WebDriver for Edge could not be found on the current PATH. Please download the ` +
@@ -114,6 +128,7 @@ class ServiceBuilder extends chromium.ServiceBuilder {
114
128
  `and ensure it can be found on your PATH.`
115
129
  )
116
130
  }
131
+
117
132
  super(exe)
118
133
  this.setLoopback(true)
119
134
  }
package/firefox.js CHANGED
@@ -127,6 +127,7 @@ const webdriver = require('./lib/webdriver')
127
127
  const zip = require('./io/zip')
128
128
  const { Browser, Capabilities } = require('./lib/capabilities')
129
129
  const { Zip } = require('./io/zip')
130
+ const { driverLocation } = require('./common/seleniumManager')
130
131
 
131
132
  /**
132
133
  * Thrown when there an add-on is malformed.
@@ -459,16 +460,27 @@ function locateSynchronously() {
459
460
  */
460
461
  function findGeckoDriver() {
461
462
  let exe = locateSynchronously()
463
+
464
+ if (!exe) {
465
+ console.log(
466
+ `The ${GECKO_DRIVER_EXE} executable could not be found on the current PATH, trying Selenium Manager`
467
+ )
468
+
469
+ try {
470
+ exe = driverLocation(Browser.FIREFOX)
471
+ } catch (err) {
472
+ console.log(`Unable to obtain driver using Selenium Manager: ${err}`)
473
+ }
474
+ }
475
+
462
476
  if (!exe) {
463
477
  throw Error(
464
- 'The ' +
465
- GECKO_DRIVER_EXE +
466
- ' executable could not be found on the current ' +
467
- 'PATH. Please download the latest version from ' +
468
- 'https://github.com/mozilla/geckodriver/releases/ ' +
469
- 'and ensure it can be found on your PATH.'
478
+ `The ${GECKO_DRIVER_EXE} executable could not be found on the current PATH.
479
+ Please download the latest version from https://github.com/mozilla/geckodriver/releases/
480
+ and ensure it can be found on your PATH.`
470
481
  )
471
482
  }
483
+
472
484
  return exe
473
485
  }
474
486
 
package/lib/util.js CHANGED
@@ -34,7 +34,16 @@ function isObject(value) {
34
34
  * @return {boolean} Whether the value is a promise.
35
35
  */
36
36
  function isPromise(value) {
37
- return Object.prototype.toString.call(value) === '[object Promise]'
37
+ try {
38
+ // Use array notation so the Closure compiler does not obfuscate away our
39
+ // contract.
40
+ return (
41
+ (typeof value === 'object' || typeof value === 'function') &&
42
+ typeof value['then'] === 'function'
43
+ )
44
+ } catch (ex) {
45
+ return false
46
+ }
38
47
  }
39
48
 
40
49
  module.exports = {
@@ -169,24 +169,34 @@ class Credential {
169
169
  * @param userHandle userHandle associated to the credential. Must be Base64 encoded string.
170
170
  * @param privateKey Base64 encoded PKCS
171
171
  * @param signCount initial value for a signature counter.
172
+ * @deprecated This method has been made static. Call it with class name. Example, Credential.createResidentCredential()
172
173
  * @returns A resident credential
173
174
  */
174
175
  createResidentCredential(id, rpId, userHandle, privateKey, signCount) {
175
176
  return new Credential(id, true, rpId, userHandle, privateKey, signCount)
176
177
  }
177
178
 
179
+ static createResidentCredential(id, rpId, userHandle, privateKey, signCount) {
180
+ return new Credential(id, true, rpId, userHandle, privateKey, signCount)
181
+ }
182
+
178
183
  /**
179
184
  * Creates a non-resident (i.e. stateless) credential.
180
185
  * @param id Unique base64 encoded string.
181
186
  * @param rpId Relying party identifier.
182
187
  * @param privateKey Base64 encoded PKCS
183
188
  * @param signCount initial value for a signature counter.
189
+ * @deprecated This method has been made static. Call it with class name. Example, Credential.createNonResidentCredential()
184
190
  * @returns A non-resident credential
185
191
  */
186
192
  createNonResidentCredential(id, rpId, privateKey, signCount) {
187
193
  return new Credential(id, false, rpId, null, privateKey, signCount)
188
194
  }
189
195
 
196
+ static createNonResidentCredential(id, rpId, privateKey, signCount) {
197
+ return new Credential(id, false, rpId, null, privateKey, signCount)
198
+ }
199
+
190
200
  toDict() {
191
201
  let credentialData = {
192
202
  credentialId: Buffer.from(this._id).toString('base64url'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "selenium-webdriver",
3
- "version": "4.5.0",
3
+ "version": "4.6.0",
4
4
  "description": "The official WebDriver JavaScript bindings from the Selenium project",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [