@appium/base-driver 10.3.0 → 10.4.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 (58) hide show
  1. package/build/lib/basedriver/capabilities.d.ts +4 -0
  2. package/build/lib/basedriver/capabilities.d.ts.map +1 -1
  3. package/build/lib/basedriver/capabilities.js +4 -0
  4. package/build/lib/basedriver/capabilities.js.map +1 -1
  5. package/build/lib/basedriver/commands/execute.js +5 -16
  6. package/build/lib/basedriver/commands/execute.js.map +1 -1
  7. package/build/lib/basedriver/core.d.ts +24 -24
  8. package/build/lib/basedriver/core.d.ts.map +1 -1
  9. package/build/lib/basedriver/core.js +29 -29
  10. package/build/lib/basedriver/core.js.map +1 -1
  11. package/build/lib/basedriver/driver.d.ts.map +1 -1
  12. package/build/lib/basedriver/driver.js +7 -2
  13. package/build/lib/basedriver/driver.js.map +1 -1
  14. package/build/lib/basedriver/extension-core.d.ts +1 -1
  15. package/build/lib/basedriver/extension-core.d.ts.map +1 -1
  16. package/build/lib/basedriver/extension-core.js +1 -1
  17. package/build/lib/basedriver/extension-core.js.map +1 -1
  18. package/build/lib/basedriver/helpers.d.ts.map +1 -1
  19. package/build/lib/basedriver/helpers.js +2 -2
  20. package/build/lib/basedriver/helpers.js.map +1 -1
  21. package/build/lib/helpers/levenshtein-match.d.ts +27 -0
  22. package/build/lib/helpers/levenshtein-match.d.ts.map +1 -0
  23. package/build/lib/helpers/levenshtein-match.js +61 -0
  24. package/build/lib/helpers/levenshtein-match.js.map +1 -0
  25. package/build/lib/jsonwp-proxy/protocol-converter.d.ts +1 -1
  26. package/build/lib/jsonwp-proxy/protocol-converter.d.ts.map +1 -1
  27. package/build/lib/jsonwp-proxy/protocol-converter.js +3 -3
  28. package/build/lib/jsonwp-proxy/protocol-converter.js.map +1 -1
  29. package/build/lib/jsonwp-proxy/proxy.d.ts +9 -9
  30. package/build/lib/jsonwp-proxy/proxy.d.ts.map +1 -1
  31. package/build/lib/jsonwp-proxy/proxy.js +13 -13
  32. package/build/lib/jsonwp-proxy/proxy.js.map +1 -1
  33. package/build/lib/protocol/errors.d.ts +45 -45
  34. package/build/lib/protocol/errors.d.ts.map +1 -1
  35. package/build/lib/protocol/errors.js +162 -162
  36. package/build/lib/protocol/errors.js.map +1 -1
  37. package/build/lib/protocol/protocol.d.ts +35 -0
  38. package/build/lib/protocol/protocol.d.ts.map +1 -1
  39. package/build/lib/protocol/protocol.js +105 -77
  40. package/build/lib/protocol/protocol.js.map +1 -1
  41. package/build/lib/protocol/routes.d.ts +6 -0
  42. package/build/lib/protocol/routes.d.ts.map +1 -1
  43. package/build/lib/protocol/routes.js +6 -0
  44. package/build/lib/protocol/routes.js.map +1 -1
  45. package/lib/basedriver/capabilities.ts +4 -0
  46. package/lib/basedriver/commands/execute.ts +5 -17
  47. package/lib/basedriver/core.ts +34 -34
  48. package/lib/basedriver/driver.ts +9 -2
  49. package/lib/basedriver/extension-core.ts +1 -1
  50. package/lib/basedriver/helpers.ts +21 -21
  51. package/lib/helpers/levenshtein-match.ts +74 -0
  52. package/lib/jsonwp-proxy/protocol-converter.ts +4 -4
  53. package/lib/jsonwp-proxy/proxy.ts +16 -16
  54. package/lib/protocol/errors.ts +281 -246
  55. package/lib/protocol/protocol.ts +121 -93
  56. package/lib/protocol/routes.ts +6 -0
  57. package/package.json +7 -7
  58. package/tsconfig.json +6 -0
@@ -45,10 +45,10 @@ class BaseError extends Error {
45
45
  }
46
46
  // base error class for all of our errors
47
47
  class ProtocolError extends BaseError {
48
- _stacktrace;
49
48
  jsonwpCode;
50
49
  error;
51
50
  w3cStatus;
51
+ _stacktrace;
52
52
  constructor(msg, jsonwpCode, w3cStatus, w3cErrorSignature, cause) {
53
53
  super(msg, cause);
54
54
  this.jsonwpCode = jsonwpCode ?? UnknownError.code();
@@ -86,6 +86,9 @@ exports.ProtocolError = ProtocolError;
86
86
  // https://github.com/SeleniumHQ/selenium/issues/5562#issuecomment-370379470
87
87
  // https://w3c.github.io/webdriver/webdriver-spec.html#dfn-error-code
88
88
  class NoSuchDriverError extends ProtocolError {
89
+ constructor(message = '', cause) {
90
+ super(message || 'A session is either terminated or not started', NoSuchDriverError.code(), NoSuchDriverError.w3cStatus(), NoSuchDriverError.error(), cause);
91
+ }
89
92
  static code() {
90
93
  return 6;
91
94
  }
@@ -96,12 +99,13 @@ class NoSuchDriverError extends ProtocolError {
96
99
  static error() {
97
100
  return 'invalid session id';
98
101
  }
99
- constructor(message = '', cause) {
100
- super(message || 'A session is either terminated or not started', NoSuchDriverError.code(), NoSuchDriverError.w3cStatus(), NoSuchDriverError.error(), cause);
101
- }
102
102
  }
103
103
  exports.NoSuchDriverError = NoSuchDriverError;
104
104
  class NoSuchElementError extends ProtocolError {
105
+ constructor(message = '', cause) {
106
+ super(message ||
107
+ 'An element could not be located on the page using the given ' + 'search parameters.', NoSuchElementError.code(), NoSuchElementError.w3cStatus(), NoSuchElementError.error(), cause);
108
+ }
105
109
  static code() {
106
110
  return 7;
107
111
  }
@@ -111,13 +115,14 @@ class NoSuchElementError extends ProtocolError {
111
115
  static error() {
112
116
  return 'no such element';
113
117
  }
114
- constructor(message = '', cause) {
115
- super(message ||
116
- 'An element could not be located on the page using the given ' + 'search parameters.', NoSuchElementError.code(), NoSuchElementError.w3cStatus(), NoSuchElementError.error(), cause);
117
- }
118
118
  }
119
119
  exports.NoSuchElementError = NoSuchElementError;
120
120
  class NoSuchFrameError extends ProtocolError {
121
+ constructor(message = '', cause) {
122
+ super(message ||
123
+ 'A request to switch to a frame could not be satisfied because ' +
124
+ 'the frame could not be found.', NoSuchFrameError.code(), NoSuchFrameError.w3cStatus(), NoSuchFrameError.error(), cause);
125
+ }
121
126
  static code() {
122
127
  return 8;
123
128
  }
@@ -127,14 +132,15 @@ class NoSuchFrameError extends ProtocolError {
127
132
  static w3cStatus() {
128
133
  return http_status_codes_1.StatusCodes.NOT_FOUND;
129
134
  }
130
- constructor(message = '', cause) {
131
- super(message ||
132
- 'A request to switch to a frame could not be satisfied because ' +
133
- 'the frame could not be found.', NoSuchFrameError.code(), NoSuchFrameError.w3cStatus(), NoSuchFrameError.error(), cause);
134
- }
135
135
  }
136
136
  exports.NoSuchFrameError = NoSuchFrameError;
137
137
  class UnknownCommandError extends ProtocolError {
138
+ constructor(message = '', cause) {
139
+ super(message ||
140
+ 'The requested resource could not be found, or a request was ' +
141
+ 'received using an HTTP method that is not supported by the mapped ' +
142
+ 'resource.', UnknownCommandError.code(), UnknownCommandError.w3cStatus(), UnknownCommandError.error(), cause);
143
+ }
138
144
  static code() {
139
145
  return 9;
140
146
  }
@@ -144,15 +150,14 @@ class UnknownCommandError extends ProtocolError {
144
150
  static error() {
145
151
  return 'unknown command';
146
152
  }
147
- constructor(message = '', cause) {
148
- super(message ||
149
- 'The requested resource could not be found, or a request was ' +
150
- 'received using an HTTP method that is not supported by the mapped ' +
151
- 'resource.', UnknownCommandError.code(), UnknownCommandError.w3cStatus(), UnknownCommandError.error(), cause);
152
- }
153
153
  }
154
154
  exports.UnknownCommandError = UnknownCommandError;
155
155
  class StaleElementReferenceError extends ProtocolError {
156
+ constructor(message = '', cause) {
157
+ super(message ||
158
+ 'An element command failed because the referenced element is no ' +
159
+ 'longer attached to the DOM.', StaleElementReferenceError.code(), StaleElementReferenceError.w3cStatus(), StaleElementReferenceError.error(), cause);
160
+ }
156
161
  static code() {
157
162
  return 10;
158
163
  }
@@ -162,14 +167,14 @@ class StaleElementReferenceError extends ProtocolError {
162
167
  static error() {
163
168
  return 'stale element reference';
164
169
  }
165
- constructor(message = '', cause) {
166
- super(message ||
167
- 'An element command failed because the referenced element is no ' +
168
- 'longer attached to the DOM.', StaleElementReferenceError.code(), StaleElementReferenceError.w3cStatus(), StaleElementReferenceError.error(), cause);
169
- }
170
170
  }
171
171
  exports.StaleElementReferenceError = StaleElementReferenceError;
172
172
  class ElementNotVisibleError extends ProtocolError {
173
+ constructor(message = '', cause) {
174
+ super(message ||
175
+ 'An element command could not be completed because the element is ' +
176
+ 'not visible on the page.', ElementNotVisibleError.code(), ElementNotVisibleError.w3cStatus(), ElementNotVisibleError.error(), cause);
177
+ }
173
178
  static code() {
174
179
  return 11;
175
180
  }
@@ -179,14 +184,14 @@ class ElementNotVisibleError extends ProtocolError {
179
184
  static error() {
180
185
  return 'element not visible';
181
186
  }
187
+ }
188
+ exports.ElementNotVisibleError = ElementNotVisibleError;
189
+ class InvalidElementStateError extends ProtocolError {
182
190
  constructor(message = '', cause) {
183
191
  super(message ||
184
192
  'An element command could not be completed because the element is ' +
185
- 'not visible on the page.', ElementNotVisibleError.code(), ElementNotVisibleError.w3cStatus(), ElementNotVisibleError.error(), cause);
193
+ 'in an invalid state (e.g. attempting to click a disabled element).', InvalidElementStateError.code(), InvalidElementStateError.w3cStatus(), InvalidElementStateError.error(), cause);
186
194
  }
187
- }
188
- exports.ElementNotVisibleError = ElementNotVisibleError;
189
- class InvalidElementStateError extends ProtocolError {
190
195
  static code() {
191
196
  return 12;
192
197
  }
@@ -196,14 +201,12 @@ class InvalidElementStateError extends ProtocolError {
196
201
  static error() {
197
202
  return 'invalid element state';
198
203
  }
199
- constructor(message = '', cause) {
200
- super(message ||
201
- 'An element command could not be completed because the element is ' +
202
- 'in an invalid state (e.g. attempting to click a disabled element).', InvalidElementStateError.code(), InvalidElementStateError.w3cStatus(), InvalidElementStateError.error(), cause);
203
- }
204
204
  }
205
205
  exports.InvalidElementStateError = InvalidElementStateError;
206
206
  class UnknownError extends ProtocolError {
207
+ constructor(message = '', cause) {
208
+ super(message || 'An unknown server-side error occurred while processing the command.', UnknownError.code(), UnknownError.w3cStatus(), UnknownError.error(), cause);
209
+ }
207
210
  static code() {
208
211
  return 13;
209
212
  }
@@ -213,12 +216,13 @@ class UnknownError extends ProtocolError {
213
216
  static error() {
214
217
  return 'unknown error';
215
218
  }
216
- constructor(message = '', cause) {
217
- super(message || 'An unknown server-side error occurred while processing the command.', UnknownError.code(), UnknownError.w3cStatus(), UnknownError.error(), cause);
218
- }
219
219
  }
220
220
  exports.UnknownError = UnknownError;
221
221
  class UnknownMethodError extends ProtocolError {
222
+ constructor(message = '', cause) {
223
+ super(message ||
224
+ 'The requested command matched a known URL but did not match an method for that URL', UnknownMethodError.code(), UnknownMethodError.w3cStatus(), UnknownMethodError.error(), cause);
225
+ }
222
226
  static code() {
223
227
  return 405;
224
228
  }
@@ -228,13 +232,12 @@ class UnknownMethodError extends ProtocolError {
228
232
  static error() {
229
233
  return 'unknown method';
230
234
  }
231
- constructor(message = '', cause) {
232
- super(message ||
233
- 'The requested command matched a known URL but did not match an method for that URL', UnknownMethodError.code(), UnknownMethodError.w3cStatus(), UnknownMethodError.error(), cause);
234
- }
235
235
  }
236
236
  exports.UnknownMethodError = UnknownMethodError;
237
237
  class UnsupportedOperationError extends ProtocolError {
238
+ constructor(message = '', cause) {
239
+ super(message || 'A server-side error occurred. Command cannot be supported.', UnsupportedOperationError.code(), UnsupportedOperationError.w3cStatus(), UnsupportedOperationError.error(), cause);
240
+ }
238
241
  static code() {
239
242
  return 405;
240
243
  }
@@ -244,12 +247,12 @@ class UnsupportedOperationError extends ProtocolError {
244
247
  static error() {
245
248
  return 'unsupported operation';
246
249
  }
247
- constructor(message = '', cause) {
248
- super(message || 'A server-side error occurred. Command cannot be supported.', UnsupportedOperationError.code(), UnsupportedOperationError.w3cStatus(), UnsupportedOperationError.error(), cause);
249
- }
250
250
  }
251
251
  exports.UnsupportedOperationError = UnsupportedOperationError;
252
252
  class ElementIsNotSelectableError extends ProtocolError {
253
+ constructor(message = '', cause) {
254
+ super(message || 'An attempt was made to select an element that cannot be selected.', ElementIsNotSelectableError.code(), ElementIsNotSelectableError.w3cStatus(), ElementIsNotSelectableError.error(), cause);
255
+ }
253
256
  static code() {
254
257
  return 15;
255
258
  }
@@ -259,12 +262,14 @@ class ElementIsNotSelectableError extends ProtocolError {
259
262
  static w3cStatus() {
260
263
  return http_status_codes_1.StatusCodes.BAD_REQUEST;
261
264
  }
262
- constructor(message = '', cause) {
263
- super(message || 'An attempt was made to select an element that cannot be selected.', ElementIsNotSelectableError.code(), ElementIsNotSelectableError.w3cStatus(), ElementIsNotSelectableError.error(), cause);
264
- }
265
265
  }
266
266
  exports.ElementIsNotSelectableError = ElementIsNotSelectableError;
267
267
  class ElementClickInterceptedError extends ProtocolError {
268
+ constructor(message = '', cause) {
269
+ super(message ||
270
+ 'The Element Click command could not be completed because the element receiving ' +
271
+ 'the events is obscuring the element that was requested clicked', ElementClickInterceptedError.code(), ElementClickInterceptedError.w3cStatus(), ElementClickInterceptedError.error(), cause);
272
+ }
268
273
  static code() {
269
274
  return 64;
270
275
  }
@@ -274,14 +279,13 @@ class ElementClickInterceptedError extends ProtocolError {
274
279
  static w3cStatus() {
275
280
  return http_status_codes_1.StatusCodes.BAD_REQUEST;
276
281
  }
277
- constructor(message = '', cause) {
278
- super(message ||
279
- 'The Element Click command could not be completed because the element receiving ' +
280
- 'the events is obscuring the element that was requested clicked', ElementClickInterceptedError.code(), ElementClickInterceptedError.w3cStatus(), ElementClickInterceptedError.error(), cause);
281
- }
282
282
  }
283
283
  exports.ElementClickInterceptedError = ElementClickInterceptedError;
284
284
  class ElementNotInteractableError extends ProtocolError {
285
+ constructor(message = '', cause) {
286
+ super(message ||
287
+ 'A command could not be completed because the element is not pointer- or keyboard interactable', ElementNotInteractableError.code(), ElementNotInteractableError.w3cStatus(), ElementNotInteractableError.error(), cause);
288
+ }
285
289
  static code() {
286
290
  return 60;
287
291
  }
@@ -291,26 +295,25 @@ class ElementNotInteractableError extends ProtocolError {
291
295
  static w3cStatus() {
292
296
  return http_status_codes_1.StatusCodes.BAD_REQUEST;
293
297
  }
294
- constructor(message = '', cause) {
295
- super(message ||
296
- 'A command could not be completed because the element is not pointer- or keyboard interactable', ElementNotInteractableError.code(), ElementNotInteractableError.w3cStatus(), ElementNotInteractableError.error(), cause);
297
- }
298
298
  }
299
299
  exports.ElementNotInteractableError = ElementNotInteractableError;
300
300
  class InsecureCertificateError extends ProtocolError {
301
+ constructor(message = '', cause) {
302
+ super(message ||
303
+ 'Navigation caused the user agent to hit a certificate warning, which is usually the result of an expired or invalid TLS certificate', UnknownError.code(), InsecureCertificateError.w3cStatus(), InsecureCertificateError.error(), cause);
304
+ }
301
305
  static error() {
302
306
  return 'insecure certificate';
303
307
  }
304
308
  static w3cStatus() {
305
309
  return http_status_codes_1.StatusCodes.BAD_REQUEST;
306
310
  }
307
- constructor(message = '', cause) {
308
- super(message ||
309
- 'Navigation caused the user agent to hit a certificate warning, which is usually the result of an expired or invalid TLS certificate', UnknownError.code(), InsecureCertificateError.w3cStatus(), InsecureCertificateError.error(), cause);
310
- }
311
311
  }
312
312
  exports.InsecureCertificateError = InsecureCertificateError;
313
313
  class JavaScriptError extends ProtocolError {
314
+ constructor(message = '', cause) {
315
+ super(message || 'An error occurred while executing user supplied JavaScript.', JavaScriptError.code(), JavaScriptError.w3cStatus(), JavaScriptError.error(), cause);
316
+ }
314
317
  static code() {
315
318
  return 17;
316
319
  }
@@ -320,12 +323,12 @@ class JavaScriptError extends ProtocolError {
320
323
  static error() {
321
324
  return 'javascript error';
322
325
  }
323
- constructor(message = '', cause) {
324
- super(message || 'An error occurred while executing user supplied JavaScript.', JavaScriptError.code(), JavaScriptError.w3cStatus(), JavaScriptError.error(), cause);
325
- }
326
326
  }
327
327
  exports.JavaScriptError = JavaScriptError;
328
328
  class XPathLookupError extends ProtocolError {
329
+ constructor(message = '', cause) {
330
+ super(message || 'An error occurred while searching for an element by XPath.', XPathLookupError.code(), XPathLookupError.w3cStatus(), XPathLookupError.error(), cause);
331
+ }
329
332
  static code() {
330
333
  return 19;
331
334
  }
@@ -335,12 +338,12 @@ class XPathLookupError extends ProtocolError {
335
338
  static error() {
336
339
  return 'invalid selector';
337
340
  }
338
- constructor(message = '', cause) {
339
- super(message || 'An error occurred while searching for an element by XPath.', XPathLookupError.code(), XPathLookupError.w3cStatus(), XPathLookupError.error(), cause);
340
- }
341
341
  }
342
342
  exports.XPathLookupError = XPathLookupError;
343
343
  class TimeoutError extends ProtocolError {
344
+ constructor(message = '', cause) {
345
+ super(message || 'An operation did not complete before its timeout expired.', TimeoutError.code(), TimeoutError.w3cStatus(), TimeoutError.error(), cause);
346
+ }
344
347
  static code() {
345
348
  return 21;
346
349
  }
@@ -350,12 +353,14 @@ class TimeoutError extends ProtocolError {
350
353
  static error() {
351
354
  return 'timeout';
352
355
  }
353
- constructor(message = '', cause) {
354
- super(message || 'An operation did not complete before its timeout expired.', TimeoutError.code(), TimeoutError.w3cStatus(), TimeoutError.error(), cause);
355
- }
356
356
  }
357
357
  exports.TimeoutError = TimeoutError;
358
358
  class NoSuchWindowError extends ProtocolError {
359
+ constructor(message = '', cause) {
360
+ super(message ||
361
+ 'A request to switch to a different window could not be satisfied ' +
362
+ 'because the window could not be found.', NoSuchWindowError.code(), NoSuchWindowError.w3cStatus(), NoSuchWindowError.error(), cause);
363
+ }
359
364
  static code() {
360
365
  return 23;
361
366
  }
@@ -365,14 +370,12 @@ class NoSuchWindowError extends ProtocolError {
365
370
  static w3cStatus() {
366
371
  return http_status_codes_1.StatusCodes.NOT_FOUND;
367
372
  }
368
- constructor(message = '', cause) {
369
- super(message ||
370
- 'A request to switch to a different window could not be satisfied ' +
371
- 'because the window could not be found.', NoSuchWindowError.code(), NoSuchWindowError.w3cStatus(), NoSuchWindowError.error(), cause);
372
- }
373
373
  }
374
374
  exports.NoSuchWindowError = NoSuchWindowError;
375
375
  class InvalidArgumentError extends ProtocolError {
376
+ constructor(message = '', cause) {
377
+ super(message || 'The arguments passed to the command are either invalid or malformed', InvalidArgumentError.code(), InvalidArgumentError.w3cStatus(), InvalidArgumentError.error(), cause);
378
+ }
376
379
  static code() {
377
380
  return 61;
378
381
  }
@@ -382,12 +385,14 @@ class InvalidArgumentError extends ProtocolError {
382
385
  static w3cStatus() {
383
386
  return http_status_codes_1.StatusCodes.BAD_REQUEST;
384
387
  }
385
- constructor(message = '', cause) {
386
- super(message || 'The arguments passed to the command are either invalid or malformed', InvalidArgumentError.code(), InvalidArgumentError.w3cStatus(), InvalidArgumentError.error(), cause);
387
- }
388
388
  }
389
389
  exports.InvalidArgumentError = InvalidArgumentError;
390
390
  class InvalidCookieDomainError extends ProtocolError {
391
+ constructor(message = '', cause) {
392
+ super(message ||
393
+ 'An illegal attempt was made to set a cookie under a different ' +
394
+ 'domain than the current page.', InvalidCookieDomainError.code(), InvalidCookieDomainError.w3cStatus(), InvalidCookieDomainError.error(), cause);
395
+ }
391
396
  static code() {
392
397
  return 24;
393
398
  }
@@ -397,14 +402,13 @@ class InvalidCookieDomainError extends ProtocolError {
397
402
  static w3cStatus() {
398
403
  return http_status_codes_1.StatusCodes.BAD_REQUEST;
399
404
  }
400
- constructor(message = '', cause) {
401
- super(message ||
402
- 'An illegal attempt was made to set a cookie under a different ' +
403
- 'domain than the current page.', InvalidCookieDomainError.code(), InvalidCookieDomainError.w3cStatus(), InvalidCookieDomainError.error(), cause);
404
- }
405
405
  }
406
406
  exports.InvalidCookieDomainError = InvalidCookieDomainError;
407
407
  class NoSuchCookieError extends ProtocolError {
408
+ constructor(message = '', cause) {
409
+ super(message ||
410
+ 'No cookie matching the given path name was found amongst the associated cookies of the current browsing context’s active document', NoSuchCookieError.code(), NoSuchCookieError.w3cStatus(), NoSuchCookieError.error(), cause);
411
+ }
408
412
  static code() {
409
413
  return 62;
410
414
  }
@@ -414,13 +418,12 @@ class NoSuchCookieError extends ProtocolError {
414
418
  static error() {
415
419
  return 'no such cookie';
416
420
  }
417
- constructor(message = '', cause) {
418
- super(message ||
419
- 'No cookie matching the given path name was found amongst the associated cookies of the current browsing context’s active document', NoSuchCookieError.code(), NoSuchCookieError.w3cStatus(), NoSuchCookieError.error(), cause);
420
- }
421
421
  }
422
422
  exports.NoSuchCookieError = NoSuchCookieError;
423
423
  class UnableToSetCookieError extends ProtocolError {
424
+ constructor(message = '', cause) {
425
+ super(message || "A request to set a cookie's value could not be satisfied.", UnableToSetCookieError.code(), UnableToSetCookieError.w3cStatus(), UnableToSetCookieError.error(), cause);
426
+ }
424
427
  static code() {
425
428
  return 25;
426
429
  }
@@ -430,12 +433,12 @@ class UnableToSetCookieError extends ProtocolError {
430
433
  static error() {
431
434
  return 'unable to set cookie';
432
435
  }
433
- constructor(message = '', cause) {
434
- super(message || "A request to set a cookie's value could not be satisfied.", UnableToSetCookieError.code(), UnableToSetCookieError.w3cStatus(), UnableToSetCookieError.error(), cause);
435
- }
436
436
  }
437
437
  exports.UnableToSetCookieError = UnableToSetCookieError;
438
438
  class UnexpectedAlertOpenError extends ProtocolError {
439
+ constructor(message = '', cause) {
440
+ super(message || 'A modal dialog was open, blocking this operation', UnexpectedAlertOpenError.code(), UnexpectedAlertOpenError.w3cStatus(), UnexpectedAlertOpenError.error(), cause);
441
+ }
439
442
  static code() {
440
443
  return 26;
441
444
  }
@@ -445,12 +448,12 @@ class UnexpectedAlertOpenError extends ProtocolError {
445
448
  static error() {
446
449
  return 'unexpected alert open';
447
450
  }
448
- constructor(message = '', cause) {
449
- super(message || 'A modal dialog was open, blocking this operation', UnexpectedAlertOpenError.code(), UnexpectedAlertOpenError.w3cStatus(), UnexpectedAlertOpenError.error(), cause);
450
- }
451
451
  }
452
452
  exports.UnexpectedAlertOpenError = UnexpectedAlertOpenError;
453
453
  class NoAlertOpenError extends ProtocolError {
454
+ constructor(message = '', cause) {
455
+ super(message || 'An attempt was made to operate on a modal dialog when one was not open.', NoAlertOpenError.code(), NoAlertOpenError.w3cStatus(), NoAlertOpenError.error(), cause);
456
+ }
454
457
  static code() {
455
458
  return 27;
456
459
  }
@@ -460,15 +463,15 @@ class NoAlertOpenError extends ProtocolError {
460
463
  static error() {
461
464
  return 'no such alert';
462
465
  }
463
- constructor(message = '', cause) {
464
- super(message || 'An attempt was made to operate on a modal dialog when one was not open.', NoAlertOpenError.code(), NoAlertOpenError.w3cStatus(), NoAlertOpenError.error(), cause);
465
- }
466
466
  }
467
467
  exports.NoAlertOpenError = NoAlertOpenError;
468
468
  class NoSuchAlertError extends NoAlertOpenError {
469
469
  }
470
470
  exports.NoSuchAlertError = NoSuchAlertError;
471
471
  class ScriptTimeoutError extends ProtocolError {
472
+ constructor(message = '', cause) {
473
+ super(message || 'A script did not complete before its timeout expired.', ScriptTimeoutError.code(), ScriptTimeoutError.w3cStatus(), ScriptTimeoutError.error(), cause);
474
+ }
472
475
  static code() {
473
476
  return 28;
474
477
  }
@@ -478,12 +481,12 @@ class ScriptTimeoutError extends ProtocolError {
478
481
  static error() {
479
482
  return 'script timeout';
480
483
  }
481
- constructor(message = '', cause) {
482
- super(message || 'A script did not complete before its timeout expired.', ScriptTimeoutError.code(), ScriptTimeoutError.w3cStatus(), ScriptTimeoutError.error(), cause);
483
- }
484
484
  }
485
485
  exports.ScriptTimeoutError = ScriptTimeoutError;
486
486
  class InvalidElementCoordinatesError extends ProtocolError {
487
+ constructor(message = '', cause) {
488
+ super(message || 'The coordinates provided to an interactions operation are invalid.', InvalidElementCoordinatesError.code(), InvalidElementCoordinatesError.w3cStatus(), InvalidElementCoordinatesError.error(), cause);
489
+ }
487
490
  static code() {
488
491
  return 29;
489
492
  }
@@ -493,15 +496,15 @@ class InvalidElementCoordinatesError extends ProtocolError {
493
496
  static error() {
494
497
  return 'invalid coordinates';
495
498
  }
496
- constructor(message = '', cause) {
497
- super(message || 'The coordinates provided to an interactions operation are invalid.', InvalidElementCoordinatesError.code(), InvalidElementCoordinatesError.w3cStatus(), InvalidElementCoordinatesError.error(), cause);
498
- }
499
499
  }
500
500
  exports.InvalidElementCoordinatesError = InvalidElementCoordinatesError;
501
501
  class InvalidCoordinatesError extends InvalidElementCoordinatesError {
502
502
  }
503
503
  exports.InvalidCoordinatesError = InvalidCoordinatesError;
504
504
  class IMENotAvailableError extends ProtocolError {
505
+ constructor(message = '', cause) {
506
+ super(message || 'IME was not available.', IMENotAvailableError.code(), IMENotAvailableError.w3cStatus(), IMENotAvailableError.error(), cause);
507
+ }
505
508
  static code() {
506
509
  return 30;
507
510
  }
@@ -511,12 +514,12 @@ class IMENotAvailableError extends ProtocolError {
511
514
  static error() {
512
515
  return 'unsupported operation';
513
516
  }
514
- constructor(message = '', cause) {
515
- super(message || 'IME was not available.', IMENotAvailableError.code(), IMENotAvailableError.w3cStatus(), IMENotAvailableError.error(), cause);
516
- }
517
517
  }
518
518
  exports.IMENotAvailableError = IMENotAvailableError;
519
519
  class IMEEngineActivationFailedError extends ProtocolError {
520
+ constructor(message = '', cause) {
521
+ super(message || 'An IME engine could not be started.', IMEEngineActivationFailedError.code(), IMEEngineActivationFailedError.w3cStatus(), IMEEngineActivationFailedError.error(), cause);
522
+ }
520
523
  static code() {
521
524
  return 31;
522
525
  }
@@ -526,12 +529,12 @@ class IMEEngineActivationFailedError extends ProtocolError {
526
529
  static error() {
527
530
  return 'unsupported operation';
528
531
  }
529
- constructor(message = '', cause) {
530
- super(message || 'An IME engine could not be started.', IMEEngineActivationFailedError.code(), IMEEngineActivationFailedError.w3cStatus(), IMEEngineActivationFailedError.error(), cause);
531
- }
532
532
  }
533
533
  exports.IMEEngineActivationFailedError = IMEEngineActivationFailedError;
534
534
  class InvalidSelectorError extends ProtocolError {
535
+ constructor(message = '', cause) {
536
+ super(message || 'Argument was an invalid selector (e.g. XPath/CSS).', InvalidSelectorError.code(), InvalidSelectorError.w3cStatus(), InvalidSelectorError.error(), cause);
537
+ }
535
538
  static code() {
536
539
  return 32;
537
540
  }
@@ -541,12 +544,12 @@ class InvalidSelectorError extends ProtocolError {
541
544
  static error() {
542
545
  return 'invalid selector';
543
546
  }
544
- constructor(message = '', cause) {
545
- super(message || 'Argument was an invalid selector (e.g. XPath/CSS).', InvalidSelectorError.code(), InvalidSelectorError.w3cStatus(), InvalidSelectorError.error(), cause);
546
- }
547
547
  }
548
548
  exports.InvalidSelectorError = InvalidSelectorError;
549
549
  class SessionNotCreatedError extends ProtocolError {
550
+ constructor(message = '', cause) {
551
+ super(`A new session could not be created.${message ? (' Details: ' + message) : ''}`, SessionNotCreatedError.code(), SessionNotCreatedError.w3cStatus(), SessionNotCreatedError.error(), cause);
552
+ }
550
553
  static code() {
551
554
  return 33;
552
555
  }
@@ -556,12 +559,12 @@ class SessionNotCreatedError extends ProtocolError {
556
559
  static error() {
557
560
  return 'session not created';
558
561
  }
559
- constructor(message = '', cause) {
560
- super(`A new session could not be created.${message ? (' Details: ' + message) : ''}`, SessionNotCreatedError.code(), SessionNotCreatedError.w3cStatus(), SessionNotCreatedError.error(), cause);
561
- }
562
562
  }
563
563
  exports.SessionNotCreatedError = SessionNotCreatedError;
564
564
  class MoveTargetOutOfBoundsError extends ProtocolError {
565
+ constructor(message = '', cause) {
566
+ super(message || 'Target provided for a move action is out of bounds.', MoveTargetOutOfBoundsError.code(), MoveTargetOutOfBoundsError.w3cStatus(), MoveTargetOutOfBoundsError.error(), cause);
567
+ }
565
568
  static code() {
566
569
  return 34;
567
570
  }
@@ -571,27 +574,24 @@ class MoveTargetOutOfBoundsError extends ProtocolError {
571
574
  static error() {
572
575
  return 'move target out of bounds';
573
576
  }
574
- constructor(message = '', cause) {
575
- super(message || 'Target provided for a move action is out of bounds.', MoveTargetOutOfBoundsError.code(), MoveTargetOutOfBoundsError.w3cStatus(), MoveTargetOutOfBoundsError.error(), cause);
576
- }
577
577
  }
578
578
  exports.MoveTargetOutOfBoundsError = MoveTargetOutOfBoundsError;
579
579
  class NoSuchContextError extends ProtocolError {
580
- static code() {
581
- return 35;
582
- }
583
580
  constructor(message = '', cause) {
584
581
  super(message || 'No such context found.', NoSuchContextError.code(), UnknownError.w3cStatus(), UnknownError.error(), cause);
585
582
  }
583
+ static code() {
584
+ return 35;
585
+ }
586
586
  }
587
587
  exports.NoSuchContextError = NoSuchContextError;
588
588
  class InvalidContextError extends ProtocolError {
589
- static code() {
590
- return 36;
591
- }
592
589
  constructor(message = '', cause) {
593
590
  super(message || 'That command could not be executed in the current context.', InvalidContextError.code(), UnknownError.w3cStatus(), UnknownError.error(), cause);
594
591
  }
592
+ static code() {
593
+ return 36;
594
+ }
595
595
  }
596
596
  exports.InvalidContextError = InvalidContextError;
597
597
  // Aliases to UnknownMethodError
@@ -608,6 +608,9 @@ class NotImplementedError extends UnknownMethodError {
608
608
  }
609
609
  exports.NotImplementedError = NotImplementedError;
610
610
  class UnableToCaptureScreen extends ProtocolError {
611
+ constructor(message = '', cause) {
612
+ super(message || 'A screen capture was made impossible', UnableToCaptureScreen.code(), UnableToCaptureScreen.w3cStatus(), UnableToCaptureScreen.error(), cause);
613
+ }
611
614
  static code() {
612
615
  return 63;
613
616
  }
@@ -617,39 +620,8 @@ class UnableToCaptureScreen extends ProtocolError {
617
620
  static error() {
618
621
  return 'unable to capture screen';
619
622
  }
620
- constructor(message = '', cause) {
621
- super(message || 'A screen capture was made impossible', UnableToCaptureScreen.code(), UnableToCaptureScreen.w3cStatus(), UnableToCaptureScreen.error(), cause);
622
- }
623
623
  }
624
624
  exports.UnableToCaptureScreen = UnableToCaptureScreen;
625
- function generateBadParametersMessage(paramRequirements, paramNames) {
626
- const toArray = function (x) {
627
- if (lodash_1.default.isUndefined(x)) {
628
- return [];
629
- }
630
- if (lodash_1.default.isArray(x)) {
631
- return x;
632
- }
633
- return [x];
634
- };
635
- const requiredParamNames = toArray(paramRequirements.required);
636
- const actualParamNames = toArray(paramNames);
637
- const missingRequiredParamNames = lodash_1.default.difference(requiredParamNames, actualParamNames);
638
- const resultLines = [];
639
- resultLines.push(lodash_1.default.isEmpty(missingRequiredParamNames)
640
- ? // This should not happen
641
- 'Some of the provided parameters are not known'
642
- : `The following required parameter${missingRequiredParamNames.length === 1 ? ' is' : 's are'} missing: ${JSON.stringify(missingRequiredParamNames)}`);
643
- if (!lodash_1.default.isEmpty(requiredParamNames)) {
644
- resultLines.push(`Known required parameters are: ${JSON.stringify(requiredParamNames)}`);
645
- }
646
- const optionalParamNames = lodash_1.default.difference(toArray(paramRequirements.optional), ['sessionId', 'id']);
647
- if (!lodash_1.default.isEmpty(optionalParamNames)) {
648
- resultLines.push(`Known optional parameters are: ${JSON.stringify(optionalParamNames)}`);
649
- }
650
- resultLines.push(`You have provided${lodash_1.default.isEmpty(actualParamNames) ? ' none' : ': ' + JSON.stringify(paramNames)}`);
651
- return resultLines.join('\n');
652
- }
653
625
  // Equivalent to W3C InvalidArgumentError
654
626
  class BadParametersError extends InvalidArgumentError {
655
627
  constructor(paramReqs, paramNames) {
@@ -681,16 +653,6 @@ class ProxyRequestError extends BaseError {
681
653
  this._jwpError = responseErrorObj;
682
654
  }
683
655
  }
684
- getActualError() {
685
- if (support_1.util.hasValue(this._jwpError?.status) && support_1.util.hasValue(this._jwpError?.value)) {
686
- // If it's MJSONWP error, returns actual error cause for request failure based on `jsonwp.status`
687
- return errorFromMJSONWPStatusCode(this._jwpError.status, this._jwpError.value);
688
- }
689
- if (support_1.util.hasValue(this._w3cError) && lodash_1.default.isNumber(this._w3cErrorStatus) && this._w3cErrorStatus >= 300) {
690
- return errorFromW3CJsonCode(this._w3cError.error, this._w3cError.message || this.message, this._w3cError.stacktrace || this.stack);
691
- }
692
- return new UnknownError(this.message, this.cause);
693
- }
694
656
  static _parseHttpResponse(data) {
695
657
  let responseErrorObj = support_1.util.safeJsonParse(data);
696
658
  if (!lodash_1.default.isPlainObject(responseErrorObj)) {
@@ -705,8 +667,46 @@ class ProxyRequestError extends BaseError {
705
667
  }
706
668
  return [responseErrorObj, errorMessage];
707
669
  }
670
+ getActualError() {
671
+ if (support_1.util.hasValue(this._jwpError?.status) && support_1.util.hasValue(this._jwpError?.value)) {
672
+ // If it's MJSONWP error, returns actual error cause for request failure based on `jsonwp.status`
673
+ return errorFromMJSONWPStatusCode(this._jwpError.status, this._jwpError.value);
674
+ }
675
+ if (support_1.util.hasValue(this._w3cError) && lodash_1.default.isNumber(this._w3cErrorStatus) && this._w3cErrorStatus >= 300) {
676
+ return errorFromW3CJsonCode(this._w3cError.error, this._w3cError.message || this.message, this._w3cError.stacktrace || this.stack);
677
+ }
678
+ return new UnknownError(this.message, this.cause);
679
+ }
708
680
  }
709
681
  exports.ProxyRequestError = ProxyRequestError;
682
+ function generateBadParametersMessage(paramRequirements, paramNames) {
683
+ const toArray = function (x) {
684
+ if (lodash_1.default.isUndefined(x)) {
685
+ return [];
686
+ }
687
+ if (lodash_1.default.isArray(x)) {
688
+ return x;
689
+ }
690
+ return [x];
691
+ };
692
+ const requiredParamNames = toArray(paramRequirements.required);
693
+ const actualParamNames = toArray(paramNames);
694
+ const missingRequiredParamNames = lodash_1.default.difference(requiredParamNames, actualParamNames);
695
+ const resultLines = [];
696
+ resultLines.push(lodash_1.default.isEmpty(missingRequiredParamNames)
697
+ ? // This should not happen
698
+ 'Some of the provided parameters are not known'
699
+ : `The following required parameter${missingRequiredParamNames.length === 1 ? ' is' : 's are'} missing: ${JSON.stringify(missingRequiredParamNames)}`);
700
+ if (!lodash_1.default.isEmpty(requiredParamNames)) {
701
+ resultLines.push(`Known required parameters are: ${JSON.stringify(requiredParamNames)}`);
702
+ }
703
+ const optionalParamNames = lodash_1.default.difference(toArray(paramRequirements.optional), ['sessionId', 'id']);
704
+ if (!lodash_1.default.isEmpty(optionalParamNames)) {
705
+ resultLines.push(`Known optional parameters are: ${JSON.stringify(optionalParamNames)}`);
706
+ }
707
+ resultLines.push(`You have provided${lodash_1.default.isEmpty(actualParamNames) ? ' none' : ': ' + JSON.stringify(paramNames)}`);
708
+ return resultLines.join('\n');
709
+ }
710
710
  // map of error class name to error class
711
711
  exports.errors = {
712
712
  NotYetImplementedError,