selenium-webdriver 4.0.0-alpha.7 → 4.0.0-alpha.8

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.
@@ -15,16 +15,14 @@
15
15
  // specific language governing permissions and limitations
16
16
  // under the License.
17
17
 
18
- 'use strict';
18
+ 'use strict'
19
19
 
20
20
  /**
21
21
  * @fileoverview Defines types related to describing the capabilities of a
22
22
  * WebDriver session.
23
23
  */
24
24
 
25
- const proxy = require('./proxy');
26
- const Symbols = require('./symbols');
27
-
25
+ const Symbols = require('./symbols')
28
26
 
29
27
  /**
30
28
  * Recognized browser names.
@@ -37,8 +35,8 @@ const Browser = {
37
35
  IE: 'internet explorer',
38
36
  INTERNET_EXPLORER: 'internet explorer',
39
37
  SAFARI: 'safari',
40
- };
41
-
38
+ OPERA: 'opera',
39
+ }
42
40
 
43
41
  /**
44
42
  * Strategies for waiting for [document readiness] after a navigation
@@ -65,9 +63,8 @@ const PageLoadStrategy = {
65
63
  * Indicates WebDriver should wait for the document readiness state to
66
64
  * be "complete" after navigation. This is the default page loading strategy.
67
65
  */
68
- NORMAL: 'normal'
69
- };
70
-
66
+ NORMAL: 'normal',
67
+ }
71
68
 
72
69
  /**
73
70
  * Common platform names. These platforms are not explicitly defined by the
@@ -79,9 +76,8 @@ const PageLoadStrategy = {
79
76
  const Platform = {
80
77
  LINUX: 'linux',
81
78
  MAC: 'mac',
82
- WINDOWS: 'windows'
83
- };
84
-
79
+ WINDOWS: 'windows',
80
+ }
85
81
 
86
82
  /**
87
83
  * Record object defining the timeouts that apply to certain WebDriver actions.
@@ -95,14 +91,14 @@ function Timeouts() {}
95
91
  * {@linkplain ./webdriver.IWebDriver#executeScript evaluated}.
96
92
  * @type {number}
97
93
  */
98
- Timeouts.prototype.script;
94
+ Timeouts.prototype.script
99
95
 
100
96
  /**
101
97
  * The timeout, in milliseconds, to apply to navigation events along with the
102
98
  * {@link PageLoadStrategy}.
103
99
  * @type {number}
104
100
  */
105
- Timeouts.prototype.pageLoad;
101
+ Timeouts.prototype.pageLoad
106
102
 
107
103
  /**
108
104
  * The maximum amount of time, in milliseconds, to spend attempting to
@@ -110,8 +106,7 @@ Timeouts.prototype.pageLoad;
110
106
  * current page.
111
107
  * @type {number}
112
108
  */
113
- Timeouts.prototype.implicit;
114
-
109
+ Timeouts.prototype.implicit
115
110
 
116
111
  /**
117
112
  * The possible default actions a WebDriver session can take to respond to
@@ -136,9 +131,8 @@ const UserPromptHandler = {
136
131
  */
137
132
  DISMISS_AND_NOTIFY: 'dismiss and notify',
138
133
  /** All prompts should be left unhandled. */
139
- IGNORE: 'ignore'
140
- };
141
-
134
+ IGNORE: 'ignore',
135
+ }
142
136
 
143
137
  /**
144
138
  * The standard WebDriver capability keys.
@@ -147,7 +141,6 @@ const UserPromptHandler = {
147
141
  * @see <https://w3c.github.io/webdriver/webdriver-spec.html#capabilities>
148
142
  */
149
143
  const Capability = {
150
-
151
144
  /**
152
145
  * Indicates whether a WebDriver session implicitly trusts otherwise untrusted
153
146
  * and self-signed TLS certificates during navigation.
@@ -213,13 +206,12 @@ const Capability = {
213
206
  */
214
207
  UNHANDLED_PROMPT_BEHAVIOR: 'unhandledPromptBehavior',
215
208
 
216
- /**
217
- * Defines the current session’s strict file interactability.
218
- * Used to upload a file when strict file interactability is on
219
- */
220
- STRICT_FILE_INTERACTABILITY: 'strictFileInteractability',
221
- };
222
-
209
+ /**
210
+ * Defines the current session’s strict file interactability.
211
+ * Used to upload a file when strict file interactability is on
212
+ */
213
+ STRICT_FILE_INTERACTABILITY: 'strictFileInteractability',
214
+ }
223
215
 
224
216
  /**
225
217
  * Converts a generic hash object to a map.
@@ -227,16 +219,15 @@ const Capability = {
227
219
  * @return {!Map<string, ?>} The converted map.
228
220
  */
229
221
  function toMap(hash) {
230
- let m = new Map;
222
+ let m = new Map()
231
223
  for (let key in hash) {
232
- if (hash.hasOwnProperty(key)) {
233
- m.set(key, hash[key]);
224
+ if (Object.prototype.hasOwnProperty.call(hash, key)) {
225
+ m.set(key, hash[key])
234
226
  }
235
227
  }
236
- return m;
228
+ return m
237
229
  }
238
230
 
239
-
240
231
  /**
241
232
  * Describes a set of capabilities for a WebDriver session.
242
233
  */
@@ -247,47 +238,47 @@ class Capabilities {
247
238
  */
248
239
  constructor(other = undefined) {
249
240
  if (other instanceof Capabilities) {
250
- other = other.map_;
241
+ other = other.map_
251
242
  } else if (other && !(other instanceof Map)) {
252
- other = toMap(other);
243
+ other = toMap(other)
253
244
  }
254
245
  /** @private @const {!Map<string, ?>} */
255
- this.map_ = new Map(other);
246
+ this.map_ = new Map(other)
256
247
  }
257
248
 
258
249
  /**
259
250
  * @return {!Capabilities} A basic set of capabilities for Chrome.
260
251
  */
261
252
  static chrome() {
262
- return new Capabilities().setBrowserName(Browser.CHROME);
253
+ return new Capabilities().setBrowserName(Browser.CHROME)
263
254
  }
264
255
 
265
256
  /**
266
257
  * @return {!Capabilities} A basic set of capabilities for Microsoft Edge.
267
258
  */
268
259
  static edge() {
269
- return new Capabilities().setBrowserName(Browser.EDGE);
260
+ return new Capabilities().setBrowserName(Browser.EDGE)
270
261
  }
271
262
 
272
263
  /**
273
264
  * @return {!Capabilities} A basic set of capabilities for Firefox.
274
265
  */
275
266
  static firefox() {
276
- return new Capabilities().setBrowserName(Browser.FIREFOX);
267
+ return new Capabilities().setBrowserName(Browser.FIREFOX)
277
268
  }
278
269
 
279
270
  /**
280
271
  * @return {!Capabilities} A basic set of capabilities for Internet Explorer.
281
272
  */
282
273
  static ie() {
283
- return new Capabilities().setBrowserName(Browser.INTERNET_EXPLORER);
274
+ return new Capabilities().setBrowserName(Browser.INTERNET_EXPLORER)
284
275
  }
285
276
 
286
277
  /**
287
278
  * @return {!Capabilities} A basic set of capabilities for Safari.
288
279
  */
289
280
  static safari() {
290
- return new Capabilities().setBrowserName(Browser.SAFARI);
281
+ return new Capabilities().setBrowserName(Browser.SAFARI)
291
282
  }
292
283
 
293
284
  /**
@@ -297,7 +288,7 @@ class Capabilities {
297
288
  * Map).
298
289
  */
299
290
  [Symbols.serialize]() {
300
- return serialize(this);
291
+ return serialize(this)
301
292
  }
302
293
 
303
294
  /**
@@ -306,7 +297,7 @@ class Capabilities {
306
297
  * @template T
307
298
  */
308
299
  get(key) {
309
- return this.map_.get(key);
300
+ return this.map_.get(key)
310
301
  }
311
302
 
312
303
  /**
@@ -314,19 +305,19 @@ class Capabilities {
314
305
  * @return {boolean} whether this capability set has the specified key.
315
306
  */
316
307
  has(key) {
317
- return this.map_.has(key);
308
+ return this.map_.has(key)
318
309
  }
319
310
 
320
311
  /**
321
312
  * @return {!Iterator<string>} an iterator of the keys set.
322
313
  */
323
314
  keys() {
324
- return this.map_.keys();
315
+ return this.map_.keys()
325
316
  }
326
317
 
327
318
  /** @return {number} The number of capabilities set. */
328
319
  get size() {
329
- return this.map_.size;
320
+ return this.map_.size
330
321
  }
331
322
 
332
323
  /**
@@ -337,20 +328,20 @@ class Capabilities {
337
328
  */
338
329
  merge(other) {
339
330
  if (other) {
340
- let otherMap;
331
+ let otherMap
341
332
  if (other instanceof Capabilities) {
342
- otherMap = other.map_;
333
+ otherMap = other.map_
343
334
  } else if (other instanceof Map) {
344
- otherMap = other;
335
+ otherMap = other
345
336
  } else {
346
- otherMap = toMap(other);
337
+ otherMap = toMap(other)
347
338
  }
348
339
  otherMap.forEach((value, key) => {
349
- this.set(key, value);
350
- });
351
- return this;
340
+ this.set(key, value)
341
+ })
342
+ return this
352
343
  } else {
353
- throw new TypeError('no capabilities provided for merge');
344
+ throw new TypeError('no capabilities provided for merge')
354
345
  }
355
346
  }
356
347
 
@@ -360,7 +351,7 @@ class Capabilities {
360
351
  * @param {string} key the capability key to delete.
361
352
  */
362
353
  delete(key) {
363
- this.map_.delete(key);
354
+ this.map_.delete(key)
364
355
  }
365
356
 
366
357
  /**
@@ -371,10 +362,10 @@ class Capabilities {
371
362
  */
372
363
  set(key, value) {
373
364
  if (typeof key !== 'string') {
374
- throw new TypeError('Capability keys must be strings: ' + typeof key);
365
+ throw new TypeError('Capability keys must be strings: ' + typeof key)
375
366
  }
376
- this.map_.set(key, value);
377
- return this;
367
+ this.map_.set(key, value)
368
+ return this
378
369
  }
379
370
 
380
371
  /**
@@ -385,7 +376,7 @@ class Capabilities {
385
376
  * @return {!Capabilities} a self reference.
386
377
  */
387
378
  setAcceptInsecureCerts(accept) {
388
- return this.set(Capability.ACCEPT_INSECURE_TLS_CERTS, accept);
379
+ return this.set(Capability.ACCEPT_INSECURE_TLS_CERTS, accept)
389
380
  }
390
381
 
391
382
  /**
@@ -393,7 +384,7 @@ class Capabilities {
393
384
  * TLS certificates.
394
385
  */
395
386
  getAcceptInsecureCerts() {
396
- return this.get(Capability.ACCEPT_INSECURE_TLS_CERTS);
387
+ return this.get(Capability.ACCEPT_INSECURE_TLS_CERTS)
397
388
  }
398
389
 
399
390
  /**
@@ -403,7 +394,7 @@ class Capabilities {
403
394
  * @return {!Capabilities} a self reference.
404
395
  */
405
396
  setBrowserName(name) {
406
- return this.set(Capability.BROWSER_NAME, name);
397
+ return this.set(Capability.BROWSER_NAME, name)
407
398
  }
408
399
 
409
400
  /**
@@ -411,7 +402,7 @@ class Capabilities {
411
402
  * not set.
412
403
  */
413
404
  getBrowserName() {
414
- return this.get(Capability.BROWSER_NAME);
405
+ return this.get(Capability.BROWSER_NAME)
415
406
  }
416
407
 
417
408
  /**
@@ -421,7 +412,7 @@ class Capabilities {
421
412
  * @return {!Capabilities} a self reference.
422
413
  */
423
414
  setBrowserVersion(version) {
424
- return this.set(Capability.BROWSER_VERSION, version);
415
+ return this.set(Capability.BROWSER_VERSION, version)
425
416
  }
426
417
 
427
418
  /**
@@ -429,7 +420,7 @@ class Capabilities {
429
420
  * if not set.
430
421
  */
431
422
  getBrowserVersion() {
432
- return this.get(Capability.BROWSER_VERSION);
423
+ return this.get(Capability.BROWSER_VERSION)
433
424
  }
434
425
 
435
426
  /**
@@ -439,7 +430,7 @@ class Capabilities {
439
430
  * @return {!Capabilities} a self reference.
440
431
  */
441
432
  setPageLoadStrategy(strategy) {
442
- return this.set(Capability.PAGE_LOAD_STRATEGY, strategy);
433
+ return this.set(Capability.PAGE_LOAD_STRATEGY, strategy)
443
434
  }
444
435
 
445
436
  /**
@@ -448,7 +439,7 @@ class Capabilities {
448
439
  * @return {(string|undefined)} the page load strategy.
449
440
  */
450
441
  getPageLoadStrategy() {
451
- return this.get(Capability.PAGE_LOAD_STRATEGY);
442
+ return this.get(Capability.PAGE_LOAD_STRATEGY)
452
443
  }
453
444
 
454
445
  /**
@@ -458,7 +449,7 @@ class Capabilities {
458
449
  * @return {!Capabilities} a self reference.
459
450
  */
460
451
  setPlatform(platform) {
461
- return this.set(Capability.PLATFORM_NAME, platform);
452
+ return this.set(Capability.PLATFORM_NAME, platform)
462
453
  }
463
454
 
464
455
  /**
@@ -466,7 +457,7 @@ class Capabilities {
466
457
  * set.
467
458
  */
468
459
  getPlatform() {
469
- return this.get(Capability.PLATFORM_NAME);
460
+ return this.get(Capability.PLATFORM_NAME)
470
461
  }
471
462
 
472
463
  /**
@@ -478,7 +469,7 @@ class Capabilities {
478
469
  * @return {!Capabilities} A self reference.
479
470
  */
480
471
  setLoggingPrefs(prefs) {
481
- return this.set(Capability.LOGGING_PREFS, prefs);
472
+ return this.set(Capability.LOGGING_PREFS, prefs)
482
473
  }
483
474
 
484
475
  /**
@@ -487,7 +478,7 @@ class Capabilities {
487
478
  * @return {!Capabilities} A self reference.
488
479
  */
489
480
  setProxy(proxy) {
490
- return this.set(Capability.PROXY, proxy);
481
+ return this.set(Capability.PROXY, proxy)
491
482
  }
492
483
 
493
484
  /**
@@ -495,7 +486,7 @@ class Capabilities {
495
486
  * undefined if not set.
496
487
  */
497
488
  getProxy() {
498
- return this.get(Capability.PROXY);
489
+ return this.get(Capability.PROXY)
499
490
  }
500
491
 
501
492
  /**
@@ -508,7 +499,7 @@ class Capabilities {
508
499
  * @return {!Capabilities} A self reference.
509
500
  */
510
501
  setAlertBehavior(behavior) {
511
- return this.set(Capability.UNHANDLED_PROMPT_BEHAVIOR, behavior);
502
+ return this.set(Capability.UNHANDLED_PROMPT_BEHAVIOR, behavior)
512
503
  }
513
504
 
514
505
  /**
@@ -516,18 +507,20 @@ class Capabilities {
516
507
  * to unhandled user prompts, or undefined if not set.
517
508
  */
518
509
  getAlertBehavior() {
519
- return this.get(Capability.UNHANDLED_PROMPT_BEHAVIOR);
510
+ return this.get(Capability.UNHANDLED_PROMPT_BEHAVIOR)
520
511
  }
521
512
 
522
- /**
523
- * Sets the boolean flag configuration for this instance.
524
- */
513
+ /**
514
+ * Sets the boolean flag configuration for this instance.
515
+ */
525
516
  setStrictFileInteractability(strictFileInteractability) {
526
- return this.set(Capability.STRICT_FILE_INTERACTABILITY, strictFileInteractability);
517
+ return this.set(
518
+ Capability.STRICT_FILE_INTERACTABILITY,
519
+ strictFileInteractability
520
+ )
527
521
  }
528
522
  }
529
523
 
530
-
531
524
  /**
532
525
  * Serializes a capabilities object. This is defined as a standalone function
533
526
  * so it may be type checked (where Capabilities[Symbols.serialize] has type
@@ -538,20 +531,18 @@ class Capabilities {
538
531
  * Note, the returned object may contain nested promised values.
539
532
  */
540
533
  function serialize(caps) {
541
- let ret = {};
534
+ let ret = {}
542
535
  for (let key of caps.keys()) {
543
- let cap = caps.get(key);
536
+ let cap = caps.get(key)
544
537
  if (cap !== undefined && cap !== null) {
545
- ret[key] = cap;
538
+ ret[key] = cap
546
539
  }
547
540
  }
548
- return ret;
541
+ return ret
549
542
  }
550
543
 
551
-
552
544
  // PUBLIC API
553
545
 
554
-
555
546
  module.exports = {
556
547
  Browser,
557
548
  Capabilities,
@@ -560,4 +551,4 @@ module.exports = {
560
551
  Platform,
561
552
  Timeouts,
562
553
  UserPromptHandler,
563
- };
554
+ }
package/lib/command.js CHANGED
@@ -19,7 +19,7 @@
19
19
  * @fileoverview Contains several classes for handling commands.
20
20
  */
21
21
 
22
- 'use strict';
22
+ 'use strict'
23
23
 
24
24
  /**
25
25
  * Describes a command to execute.
@@ -29,15 +29,15 @@ class Command {
29
29
  /** @param {string} name The name of this command. */
30
30
  constructor(name) {
31
31
  /** @private {string} */
32
- this.name_ = name;
32
+ this.name_ = name
33
33
 
34
34
  /** @private {!Object<*>} */
35
- this.parameters_ = {};
35
+ this.parameters_ = {}
36
36
  }
37
37
 
38
38
  /** @return {string} This command's name. */
39
39
  getName() {
40
- return this.name_;
40
+ return this.name_
41
41
  }
42
42
 
43
43
  /**
@@ -47,8 +47,8 @@ class Command {
47
47
  * @return {!Command} A self reference.
48
48
  */
49
49
  setParameter(name, value) {
50
- this.parameters_[name] = value;
51
- return this;
50
+ this.parameters_[name] = value
51
+ return this
52
52
  }
53
53
 
54
54
  /**
@@ -57,8 +57,8 @@ class Command {
57
57
  * @return {!Command} A self reference.
58
58
  */
59
59
  setParameters(parameters) {
60
- this.parameters_ = parameters;
61
- return this;
60
+ this.parameters_ = parameters
61
+ return this
62
62
  }
63
63
 
64
64
  /**
@@ -67,18 +67,17 @@ class Command {
67
67
  * @return {*} The parameter value, or undefined if it has not been set.
68
68
  */
69
69
  getParameter(key) {
70
- return this.parameters_[key];
70
+ return this.parameters_[key]
71
71
  }
72
72
 
73
73
  /**
74
74
  * @return {!Object<*>} The parameters to send with this command.
75
75
  */
76
76
  getParameters() {
77
- return this.parameters_;
77
+ return this.parameters_
78
78
  }
79
79
  }
80
80
 
81
-
82
81
  /**
83
82
  * Enumeration of predefined names command names that all command processors
84
83
  * will support.
@@ -109,6 +108,7 @@ const Name = {
109
108
  GET_ACTIVE_ELEMENT: 'getActiveElement',
110
109
  FIND_ELEMENT: 'findElement',
111
110
  FIND_ELEMENTS: 'findElements',
111
+ FIND_ELEMENTS_RELATIVE: 'findElementsRelative',
112
112
  FIND_CHILD_ELEMENT: 'findChildElement',
113
113
  FIND_CHILD_ELEMENTS: 'findChildElements',
114
114
 
@@ -156,6 +156,8 @@ const Name = {
156
156
  TAKE_ELEMENT_SCREENSHOT: 'takeElementScreenshot',
157
157
  SET_SCRIPT_TIMEOUT: 'setScriptTimeout',
158
158
 
159
+ PRINT_PAGE: 'printPage',
160
+
159
161
  GET_TIMEOUT: 'getTimeout',
160
162
  SET_TIMEOUT: 'setTimeout',
161
163
 
@@ -188,9 +190,7 @@ const Name = {
188
190
  LEGACY_ACTION_TOUCH_FLICK: 'legacyAction:touchFlick',
189
191
  LEGACY_ACTION_TOUCH_SINGLE_TAP: 'legacyAction:singleTap',
190
192
  LEGACY_ACTION_TOUCH_DOUBLE_TAP: 'legacyAction:doubleTap',
191
- };
192
-
193
-
193
+ }
194
194
 
195
195
  /**
196
196
  * Handles the execution of WebDriver {@link Command commands}.
@@ -207,16 +207,13 @@ class Executor {
207
207
  * @return {!Promise<?>} A promise that will be fulfilled with the command
208
208
  * result.
209
209
  */
210
- execute(command) {}
210
+ execute(command) {} // eslint-disable-line
211
211
  }
212
212
 
213
-
214
-
215
213
  // PUBLIC API
216
214
 
217
-
218
215
  module.exports = {
219
216
  Command: Command,
220
217
  Name: Name,
221
- Executor: Executor
222
- };
218
+ Executor: Executor,
219
+ }