selenium-webdriver 4.19.0 → 4.21.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 (61) hide show
  1. package/CHANGES.md +21 -0
  2. package/README.md +1 -1
  3. package/bidi/addInterceptParameters.js +28 -2
  4. package/bidi/browser.js +17 -0
  5. package/bidi/browsingContext.js +206 -39
  6. package/bidi/browsingContextInspector.js +51 -0
  7. package/bidi/browsingContextTypes.js +31 -0
  8. package/bidi/captureScreenshotParameters.js +96 -0
  9. package/bidi/clipRectangle.js +127 -0
  10. package/bidi/continueRequestParameters.js +39 -0
  11. package/bidi/continueResponseParameters.js +40 -0
  12. package/bidi/cookieFilter.js +60 -0
  13. package/bidi/createContextParameters.js +73 -0
  14. package/bidi/evaluateResult.js +17 -0
  15. package/bidi/index.js +0 -1
  16. package/bidi/input.js +27 -3
  17. package/bidi/interceptPhase.js +4 -0
  18. package/bidi/logEntries.js +66 -0
  19. package/bidi/network.js +102 -0
  20. package/bidi/networkTypes.js +346 -1
  21. package/bidi/partialCookie.js +48 -0
  22. package/bidi/partitionDescriptor.js +33 -0
  23. package/bidi/partitionKey.js +17 -0
  24. package/bidi/protocolType.js +20 -0
  25. package/bidi/protocolValue.js +129 -2
  26. package/bidi/provideResponseParameters.js +40 -0
  27. package/bidi/realmInfo.js +27 -0
  28. package/bidi/resultOwnership.js +4 -0
  29. package/bidi/scriptManager.js +119 -1
  30. package/bidi/scriptTypes.js +36 -0
  31. package/bidi/storage.js +30 -0
  32. package/bidi/urlPattern.js +35 -0
  33. package/bin/linux/selenium-manager +0 -0
  34. package/bin/macos/selenium-manager +0 -0
  35. package/bin/windows/selenium-manager.exe +0 -0
  36. package/chromium.js +12 -9
  37. package/common/driverFinder.js +36 -4
  38. package/common/seleniumManager.js +7 -39
  39. package/eslint.config.js +107 -0
  40. package/firefox.js +20 -6
  41. package/http/index.js +6 -6
  42. package/ie.js +8 -4
  43. package/index.js +11 -0
  44. package/io/exec.js +1 -1
  45. package/io/index.js +3 -2
  46. package/io/zip.js +1 -1
  47. package/lib/atoms/find-elements.js +2 -2
  48. package/lib/http.js +5 -4
  49. package/lib/input.js +0 -1
  50. package/lib/pinnedScript.js +1 -1
  51. package/lib/select.js +102 -60
  52. package/lib/until.js +3 -3
  53. package/lib/util.js +1 -0
  54. package/lib/webdriver.js +2 -2
  55. package/net/index.js +1 -1
  56. package/net/portprober.js +1 -1
  57. package/package.json +13 -7
  58. package/remote/index.js +1 -1
  59. package/remote/util.js +2 -2
  60. package/safari.js +3 -3
  61. package/testing/index.js +12 -8
package/bidi/input.js CHANGED
@@ -20,6 +20,10 @@
20
20
  const { WebElement } = require('../lib/webdriver')
21
21
  const { RemoteReferenceType, ReferenceValue } = require('./protocolValue')
22
22
 
23
+ /**
24
+ * Represents commands and events related to the Input module (simulated user input).
25
+ * Described in https://w3c.github.io/webdriver-bidi/#module-input.
26
+ */
23
27
  class Input {
24
28
  constructor(driver) {
25
29
  this._driver = driver
@@ -33,6 +37,13 @@ class Input {
33
37
  this.bidi = await this._driver.getBidi()
34
38
  }
35
39
 
40
+ /**
41
+ * Performs the specified actions on the given browsing context.
42
+ *
43
+ * @param {string} browsingContextId - The ID of the browsing context.
44
+ * @param {Array} actions - The actions to be performed.
45
+ * @returns {Promise} A promise that resolves with the response from the server.
46
+ */
36
47
  async perform(browsingContextId, actions) {
37
48
  const _actions = await updateActions(actions)
38
49
 
@@ -44,11 +55,15 @@ class Input {
44
55
  },
45
56
  }
46
57
 
47
- let response = await this.bidi.send(command)
48
-
49
- return response
58
+ return await this.bidi.send(command)
50
59
  }
51
60
 
61
+ /**
62
+ * Resets the input state in the specified browsing context.
63
+ *
64
+ * @param {string} browsingContextId - The ID of the browsing context.
65
+ * @returns {Promise} A promise that resolves when the release actions are sent.
66
+ */
52
67
  async release(browsingContextId) {
53
68
  const command = {
54
69
  method: 'input.releaseActions',
@@ -59,6 +74,15 @@ class Input {
59
74
  return await this.bidi.send(command)
60
75
  }
61
76
 
77
+ /**
78
+ * Sets the files property of a given input element.
79
+ *
80
+ * @param {string} browsingContextId - The ID of the browsing context.
81
+ * @param {string | ReferenceValue} element - The ID of the element or a ReferenceValue object representing the element.
82
+ * @param {string | string[]} files - The file path or an array of file paths to be set.
83
+ * @throws {Error} If the element is not a string or a ReferenceValue.
84
+ * @returns {Promise<void>} A promise that resolves when the files are set.
85
+ */
62
86
  async setFiles(browsingContextId, element, files) {
63
87
  if (typeof element !== 'string' && !(element instanceof ReferenceValue)) {
64
88
  throw Error(`Pass in a WebElement id as a string or a ReferenceValue. Received: ${element}`)
@@ -15,6 +15,10 @@
15
15
  // specific language governing permissions and limitations
16
16
  // under the License.
17
17
 
18
+ /**
19
+ * Represents the different phases of intercepting network requests and responses.
20
+ * @enum {string}
21
+ */
18
22
  const InterceptPhase = {
19
23
  BEFORE_REQUEST_SENT: 'beforeRequestSent',
20
24
  RESPONSE_STARTED: 'responseStarted',
@@ -17,7 +17,18 @@
17
17
 
18
18
  'use strict'
19
19
 
20
+ /**
21
+ * Represents a base log entry.
22
+ * Desribed in https://w3c.github.io/webdriver-bidi/#types-log-logentry.
23
+ */
20
24
  class BaseLogEntry {
25
+ /**
26
+ * Creates a new instance of BaseLogEntry.
27
+ * @param {string} level - The log level.
28
+ * @param {string} text - The log text.
29
+ * @param {number} timeStamp - The log timestamp.
30
+ * @param {string} stackTrace - The log stack trace.
31
+ */
21
32
  constructor(level, text, timeStamp, stackTrace) {
22
33
  this._level = level
23
34
  this._text = text
@@ -25,34 +36,72 @@ class BaseLogEntry {
25
36
  this._stackTrace = stackTrace
26
37
  }
27
38
 
39
+ /**
40
+ * Gets the log level.
41
+ * @returns {string} The log level.
42
+ */
28
43
  get level() {
29
44
  return this._level
30
45
  }
31
46
 
47
+ /**
48
+ * Gets the log text.
49
+ * @returns {string} The log text.
50
+ */
32
51
  get text() {
33
52
  return this._text
34
53
  }
35
54
 
55
+ /**
56
+ * Gets the log timestamp.
57
+ * @returns {number} The log timestamp.
58
+ */
36
59
  get timeStamp() {
37
60
  return this._timeStamp
38
61
  }
39
62
 
63
+ /**
64
+ * Gets the log stack trace.
65
+ * @returns {string} The log stack trace.
66
+ */
40
67
  get stackTrace() {
41
68
  return this._stackTrace
42
69
  }
43
70
  }
44
71
 
72
+ /**
73
+ * Represents a generic log entry.
74
+ * @class
75
+ * @extends BaseLogEntry
76
+ */
45
77
  class GenericLogEntry extends BaseLogEntry {
78
+ /**
79
+ * Creates an instance of GenericLogEntry.
80
+ * @param {string} level - The log level.
81
+ * @param {string} text - The log text.
82
+ * @param {Date} timeStamp - The log timestamp.
83
+ * @param {string} type - The log type.
84
+ * @param {string} stackTrace - The log stack trace.
85
+ */
46
86
  constructor(level, text, timeStamp, type, stackTrace) {
47
87
  super(level, text, timeStamp, stackTrace)
48
88
  this._type = type
49
89
  }
50
90
 
91
+ /**
92
+ * Gets the log type.
93
+ * @returns {string} The log type.
94
+ */
51
95
  get type() {
52
96
  return this._type
53
97
  }
54
98
  }
55
99
 
100
+ /**
101
+ * Represents a log entry for console logs.
102
+ * @class
103
+ * @extends GenericLogEntry
104
+ */
56
105
  class ConsoleLogEntry extends GenericLogEntry {
57
106
  constructor(level, text, timeStamp, type, method, realm, args, stackTrace) {
58
107
  super(level, text, timeStamp, type, stackTrace)
@@ -61,19 +110,36 @@ class ConsoleLogEntry extends GenericLogEntry {
61
110
  this._args = args
62
111
  }
63
112
 
113
+ /**
114
+ * Gets the method associated with the log entry.
115
+ * @returns {string} The method associated with the log entry.
116
+ */
64
117
  get method() {
65
118
  return this._method
66
119
  }
67
120
 
121
+ /**
122
+ * Gets the realm associated with the log entry.
123
+ * @returns {string} The realm associated with the log entry.
124
+ */
68
125
  get realm() {
69
126
  return this._realm
70
127
  }
71
128
 
129
+ /**
130
+ * Gets the arguments associated with the log entry.
131
+ * @returns {Array} The arguments associated with the log entry.
132
+ */
72
133
  get args() {
73
134
  return this._args
74
135
  }
75
136
  }
76
137
 
138
+ /**
139
+ * Represents a log entry for JavaScript logs.
140
+ * @class
141
+ * @extends GenericLogEntry
142
+ */
77
143
  class JavascriptLogEntry extends GenericLogEntry {
78
144
  constructor(level, text, timeStamp, type, stackTrace) {
79
145
  super(level, text, timeStamp, type, stackTrace)
package/bidi/network.js CHANGED
@@ -21,7 +21,17 @@ const { ContinueResponseParameters } = require('./continueResponseParameters')
21
21
  const { ContinueRequestParameters } = require('./continueRequestParameters')
22
22
  const { ProvideResponseParameters } = require('./provideResponseParameters')
23
23
 
24
+ /**
25
+ * Represents all commands and events of Network module.
26
+ * Described in https://w3c.github.io/webdriver-bidi/#module-network.
27
+ */
24
28
  class Network {
29
+ /**
30
+ * Represents a Network object.
31
+ * @constructor
32
+ * @param {Driver} driver - The driver to fetch the BiDi connection.
33
+ * @param {Array} browsingContextIds - An array of browsing context IDs that the network events will be subscribed to.
34
+ */
25
35
  constructor(driver, browsingContextIds) {
26
36
  this._driver = driver
27
37
  this._browsingContextIds = browsingContextIds
@@ -31,22 +41,52 @@ class Network {
31
41
  this.bidi = await this._driver.getBidi()
32
42
  }
33
43
 
44
+ /**
45
+ * Subscribes to the 'network.beforeRequestSent' event and handles it with the provided callback.
46
+ *
47
+ * @param {Function} callback - The callback function to handle the event.
48
+ * @returns {Promise<void>} - A promise that resolves when the subscription is successful.
49
+ */
34
50
  async beforeRequestSent(callback) {
35
51
  await this.subscribeAndHandleEvent('network.beforeRequestSent', callback)
36
52
  }
37
53
 
54
+ /**
55
+ * Subscribes to the 'network.responseStarted' event and handles it with the provided callback.
56
+ *
57
+ * @param {Function} callback - The callback function to handle the event.
58
+ * @returns {Promise<void>} - A promise that resolves when the subscription is successful.
59
+ */
38
60
  async responseStarted(callback) {
39
61
  await this.subscribeAndHandleEvent('network.responseStarted', callback)
40
62
  }
41
63
 
64
+ /**
65
+ * Subscribes to the 'network.responseCompleted' event and handles it with the provided callback.
66
+ *
67
+ * @param {Function} callback - The callback function to handle the event.
68
+ * @returns {Promise<void>} - A promise that resolves when the subscription is successful.
69
+ */
42
70
  async responseCompleted(callback) {
43
71
  await this.subscribeAndHandleEvent('network.responseCompleted', callback)
44
72
  }
45
73
 
74
+ /**
75
+ * Subscribes to the 'network.authRequired' event and handles it with the provided callback.
76
+ *
77
+ * @param {Function} callback - The callback function to handle the event.
78
+ * @returns {Promise<void>} - A promise that resolves when the subscription is successful.
79
+ */
46
80
  async authRequired(callback) {
47
81
  await this.subscribeAndHandleEvent('network.authRequired', callback)
48
82
  }
49
83
 
84
+ /**
85
+ * Subscribes to the 'network.fetchError' event and handles it with the provided callback.
86
+ *
87
+ * @param {Function} callback - The callback function to handle the event.
88
+ * @returns {Promise<void>} - A promise that resolves when the subscription is successful.
89
+ */
50
90
  async fetchError(callback) {
51
91
  await this.subscribeAndHandleEvent('network.fetchError', callback)
52
92
  }
@@ -99,6 +139,13 @@ class Network {
99
139
  })
100
140
  }
101
141
 
142
+ /**
143
+ * Adds a network intercept.
144
+ *
145
+ * @param {AddInterceptParameters} params - The parameters for the network intercept.
146
+ * @returns {Promise<string>} - A promise that resolves to the added intercept's id.
147
+ * @throws {Error} - If params is not an instance of AddInterceptParameters.
148
+ */
102
149
  async addIntercept(params) {
103
150
  if (!(params instanceof AddInterceptParameters)) {
104
151
  throw new Error(`Params must be an instance of AddInterceptParameters. Received:'${params}'`)
@@ -114,6 +161,12 @@ class Network {
114
161
  return response.result.intercept
115
162
  }
116
163
 
164
+ /**
165
+ * Removes an intercept.
166
+ *
167
+ * @param {string} interceptId - The ID of the intercept to be removed.
168
+ * @returns {Promise<void>} - A promise that resolves when the intercept is successfully removed.
169
+ */
117
170
  async removeIntercept(interceptId) {
118
171
  const command = {
119
172
  method: 'network.removeIntercept',
@@ -123,6 +176,13 @@ class Network {
123
176
  await this.bidi.send(command)
124
177
  }
125
178
 
179
+ /**
180
+ * Continues the network request with authentication credentials.
181
+ * @param {string} requestId - The ID of the request to continue.
182
+ * @param {string} username - The username for authentication.
183
+ * @param {string} password - The password for authentication.
184
+ * @returns {Promise<void>} - A promise that resolves when the command is sent.
185
+ */
126
186
  async continueWithAuth(requestId, username, password) {
127
187
  const command = {
128
188
  method: 'network.continueWithAuth',
@@ -139,6 +199,12 @@ class Network {
139
199
  await this.bidi.send(command)
140
200
  }
141
201
 
202
+ /**
203
+ * Fails a network request.
204
+ *
205
+ * @param {number} requestId - The ID of the request to fail.
206
+ * @returns {Promise<void>} - A promise that resolves when the command is sent.
207
+ */
142
208
  async failRequest(requestId) {
143
209
  const command = {
144
210
  method: 'network.failRequest',
@@ -149,6 +215,11 @@ class Network {
149
215
  await this.bidi.send(command)
150
216
  }
151
217
 
218
+ /**
219
+ * Continues the network request with authentication but without providing credentials.
220
+ * @param {string} requestId - The ID of the request to continue with authentication.
221
+ * @returns {Promise<void>} - A promise that resolves when the command is sent.
222
+ */
152
223
  async continueWithAuthNoCredentials(requestId) {
153
224
  const command = {
154
225
  method: 'network.continueWithAuth',
@@ -160,6 +231,12 @@ class Network {
160
231
  await this.bidi.send(command)
161
232
  }
162
233
 
234
+ /**
235
+ * Cancels the authentication for a specific request.
236
+ *
237
+ * @param {string} requestId - The ID of the request to cancel authentication for.
238
+ * @returns {Promise<void>} - A promise that resolves when the command is sent.
239
+ */
163
240
  async cancelAuth(requestId) {
164
241
  const command = {
165
242
  method: 'network.continueWithAuth',
@@ -171,6 +248,13 @@ class Network {
171
248
  await this.bidi.send(command)
172
249
  }
173
250
 
251
+ /**
252
+ * Continues the network request with the provided parameters.
253
+ *
254
+ * @param {ContinueRequestParameters} params - The parameters for continuing the request.
255
+ * @throws {Error} If params is not an instance of ContinueRequestParameters.
256
+ * @returns {Promise<void>} A promise that resolves when the command is sent.
257
+ */
174
258
  async continueRequest(params) {
175
259
  if (!(params instanceof ContinueRequestParameters)) {
176
260
  throw new Error(`Params must be an instance of ContinueRequestParameters. Received:'${params}'`)
@@ -184,6 +268,13 @@ class Network {
184
268
  await this.bidi.send(command)
185
269
  }
186
270
 
271
+ /**
272
+ * Continues the network response with the given parameters.
273
+ *
274
+ * @param {ContinueResponseParameters} params - The parameters for continuing the response.
275
+ * @throws {Error} If params is not an instance of ContinueResponseParameters.
276
+ * @returns {Promise<void>} A promise that resolves when the command is sent.
277
+ */
187
278
  async continueResponse(params) {
188
279
  if (!(params instanceof ContinueResponseParameters)) {
189
280
  throw new Error(`Params must be an instance of ContinueResponseParameters. Received:'${params}'`)
@@ -197,6 +288,13 @@ class Network {
197
288
  await this.bidi.send(command)
198
289
  }
199
290
 
291
+ /**
292
+ * Provides a response for the network.
293
+ *
294
+ * @param {ProvideResponseParameters} params - The parameters for providing the response.
295
+ * @throws {Error} If params is not an instance of ProvideResponseParameters.
296
+ * @returns {Promise<void>} A promise that resolves when the command is sent.
297
+ */
200
298
  async provideResponse(params) {
201
299
  if (!(params instanceof ProvideResponseParameters)) {
202
300
  throw new Error(`Params must be an instance of ProvideResponseParameters. Received:'${params}'`)
@@ -210,6 +308,10 @@ class Network {
210
308
  await this.bidi.send(command)
211
309
  }
212
310
 
311
+ /**
312
+ * Unsubscribes from network events for all browsing contexts.
313
+ * @returns {Promise<void>} A promise that resolves when the network connection is closed.
314
+ */
213
315
  async close() {
214
316
  await this.bidi.unsubscribe(
215
317
  'network.beforeRequestSent',