selenium-webdriver 3.6.0 → 4.0.0-alpha.1

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 (97) hide show
  1. package/CHANGES.md +181 -0
  2. package/README.md +25 -27
  3. package/chrome.js +113 -127
  4. package/edge.js +42 -117
  5. package/example/chrome_android.js +8 -8
  6. package/example/chrome_mobile_emulation.js +8 -8
  7. package/example/firefox_channels.js +22 -18
  8. package/example/google_search_test.js +39 -26
  9. package/example/logging.js +39 -6
  10. package/firefox.js +769 -0
  11. package/http/index.js +41 -4
  12. package/http/util.js +11 -6
  13. package/ie.js +56 -97
  14. package/index.js +178 -114
  15. package/jasmine.json +11 -0
  16. package/lib/actions.js +68 -63
  17. package/lib/by.js +1 -1
  18. package/lib/capabilities.js +255 -192
  19. package/lib/command.js +26 -50
  20. package/lib/error.js +85 -44
  21. package/lib/http.js +133 -110
  22. package/lib/input.js +1044 -8
  23. package/lib/promise.js +222 -3323
  24. package/lib/proxy.js +134 -39
  25. package/lib/test/bootstrap_jasmine.js +28 -0
  26. package/lib/test/data/actions/click.html +24 -0
  27. package/lib/test/data/actions/drag.html +77 -0
  28. package/lib/test/data/actions/record_click.html +21 -0
  29. package/lib/test/data/chrome/download.html +2 -0
  30. package/lib/test/data/inputs.html +42 -0
  31. package/lib/test/data/selectPage.html +12 -0
  32. package/lib/test/data/simpleTest.html +5 -0
  33. package/lib/test/data/upload_invisible.html +45 -0
  34. package/lib/test/fileserver.js +23 -19
  35. package/lib/test/index.js +30 -212
  36. package/lib/test/resources.js +0 -1
  37. package/lib/webdriver.js +675 -936
  38. package/net/index.js +21 -25
  39. package/net/portprober.js +51 -68
  40. package/package.json +5 -3
  41. package/remote/index.js +5 -19
  42. package/safari.js +41 -128
  43. package/test/actions_test.js +173 -18
  44. package/test/{session_test.js → builder_test.js} +44 -37
  45. package/test/chrome/devtools_test.js +93 -0
  46. package/test/chrome/options_test.js +48 -154
  47. package/test/chrome/service_test.js +7 -7
  48. package/test/cookie_test.js +77 -63
  49. package/test/element_finding_test.js +206 -201
  50. package/test/execute_script_test.js +115 -114
  51. package/test/fingerprint_test.js +16 -15
  52. package/test/firefox_test.js +251 -0
  53. package/test/http/http_test.js +0 -1
  54. package/test/http/util_test.js +2 -2
  55. package/test/io/zip_test.js +6 -7
  56. package/test/lib/error_test.js +34 -7
  57. package/test/lib/http_test.js +8 -128
  58. package/test/lib/input_test.js +1379 -0
  59. package/test/lib/promise_test.js +473 -908
  60. package/test/lib/webdriver_test.js +296 -868
  61. package/test/logging_test.js +37 -43
  62. package/test/page_loading_test.js +71 -81
  63. package/test/proxy_test.js +64 -72
  64. package/test/rect_test.js +14 -25
  65. package/test/remote_test.js +10 -29
  66. package/test/safari_test.js +7 -71
  67. package/test/stale_element_test.js +20 -23
  68. package/test/tag_name_test.js +10 -9
  69. package/test/upload_test.js +27 -35
  70. package/test/window_test.js +72 -85
  71. package/testing/index.js +386 -314
  72. package/.npmignore +0 -2
  73. package/example/async_await_test.js +0 -69
  74. package/example/google_search_generator.js +0 -47
  75. package/example/parallel_flows.js +0 -51
  76. package/firefox/binary.js +0 -347
  77. package/firefox/extension.js +0 -224
  78. package/firefox/index.js +0 -576
  79. package/firefox/profile.js +0 -311
  80. package/lib/events.js +0 -210
  81. package/lib/test/data/firefox/jetpack-sample.xpi +0 -0
  82. package/lib/test/data/firefox/sample.xpi +0 -0
  83. package/lib/test/promise.js +0 -79
  84. package/opera.js +0 -405
  85. package/phantomjs.js +0 -282
  86. package/test/firefox/extension_test.js +0 -120
  87. package/test/firefox/firefox_test.js +0 -244
  88. package/test/firefox/profile_test.js +0 -140
  89. package/test/lib/events_test.js +0 -177
  90. package/test/lib/promise_aplus_test.js +0 -78
  91. package/test/lib/promise_error_test.js +0 -884
  92. package/test/lib/promise_flow_test.js +0 -2288
  93. package/test/lib/promise_generator_test.js +0 -310
  94. package/test/phantomjs/execute_phantomjs_test.js +0 -59
  95. package/test/testing/assert_test.js +0 -373
  96. package/test/testing/index_test.js +0 -224
  97. package/testing/assert.js +0 -378
package/lib/actions.js CHANGED
@@ -70,7 +70,7 @@ function checkModifierKey(key) {
70
70
  *
71
71
  * Sample usage:
72
72
  *
73
- * driver.actions().
73
+ * new LegacyActions(driver).
74
74
  * keyDown(Key.SHIFT).
75
75
  * click(element1).
76
76
  * click(element2).
@@ -78,8 +78,14 @@ function checkModifierKey(key) {
78
78
  * keyUp(Key.SHIFT).
79
79
  * perform();
80
80
  *
81
+ * @deprecated This class is strongly deprecated and will be removed once
82
+ * [Google's Chrome][Chrome] and [Microsoft's Edge][Edge] browsers
83
+ * support the new action sequence API.
84
+ *
85
+ * [Chrome]: https://chromium.googlesource.com/chromium/src/+/master/docs/chromedriver_status.md
86
+ * [Edge]: https://docs.microsoft.com/en-us/microsoft-edge/webdriver
81
87
  */
82
- class ActionSequence {
88
+ class LegacyActionSequence {
83
89
  /**
84
90
  * @param {!./webdriver.WebDriver} driver The driver that should be used to
85
91
  * perform this action sequence.
@@ -110,21 +116,17 @@ class ActionSequence {
110
116
  /**
111
117
  * Executes this action sequence.
112
118
  *
113
- * @return {!./promise.Thenable} A promise that will be resolved once
114
- * this sequence has completed.
119
+ * @return {!Promise} A promise that will be resolved once this sequence has
120
+ * completed.
115
121
  */
116
- perform() {
122
+ async perform() {
117
123
  // Make a protected copy of the scheduled actions. This will protect against
118
124
  // users defining additional commands before this sequence is actually
119
125
  // executed.
120
126
  let actions = this.actions_.concat();
121
- let driver = this.driver_;
122
- return driver.controlFlow().execute(function() {
123
- let results = actions.map(action => {
124
- return driver.schedule(action.command, action.description);
125
- });
126
- return Promise.all(results);
127
- }, 'ActionSequence.perform');
127
+ for (let action of actions) {
128
+ await this.driver_.execute(action.command);
129
+ }
128
130
  }
129
131
 
130
132
  /**
@@ -140,10 +142,10 @@ class ActionSequence {
140
142
  * an offset within that element. The offset should be specified in pixels
141
143
  * relative to the top-left corner of the element's bounding box. If
142
144
  * omitted, the element's center will be used as the target offset.
143
- * @return {!ActionSequence} A self reference.
145
+ * @return {!LegacyActionSequence} A self reference.
144
146
  */
145
147
  mouseMove(location, opt_offset) {
146
- let cmd = new command.Command(command.Name.MOVE_TO);
148
+ let cmd = new command.Command(command.Name.LEGACY_ACTION_MOUSE_MOVE);
147
149
 
148
150
  if (typeof location.x === 'number') {
149
151
  setOffset(/** @type {{x: number, y: number}} */(location));
@@ -176,7 +178,7 @@ class ActionSequence {
176
178
  * @param {input.Button=} opt_button The button to use. Defaults to
177
179
  * {@link input.Button.LEFT}. Ignored if the previous argument is
178
180
  * provided as a button.
179
- * @return {!ActionSequence} A self reference.
181
+ * @return {!LegacyActionSequence} A self reference.
180
182
  * @private
181
183
  */
182
184
  scheduleMouseAction_(
@@ -219,11 +221,11 @@ class ActionSequence {
219
221
  * @param {input.Button=} opt_button The button to use. Defaults to
220
222
  * {@link input.Button.LEFT}. Ignored if a button is provided as the
221
223
  * first argument.
222
- * @return {!ActionSequence} A self reference.
224
+ * @return {!LegacyActionSequence} A self reference.
223
225
  */
224
226
  mouseDown(opt_elementOrButton, opt_button) {
225
227
  return this.scheduleMouseAction_('mouseDown',
226
- command.Name.MOUSE_DOWN, opt_elementOrButton, opt_button);
228
+ command.Name.LEGACY_ACTION_MOUSE_DOWN, opt_elementOrButton, opt_button);
227
229
  }
228
230
 
229
231
  /**
@@ -245,11 +247,11 @@ class ActionSequence {
245
247
  * @param {input.Button=} opt_button The button to use. Defaults to
246
248
  * {@link input.Button.LEFT}. Ignored if a button is provided as the
247
249
  * first argument.
248
- * @return {!ActionSequence} A self reference.
250
+ * @return {!LegacyActionSequence} A self reference.
249
251
  */
250
252
  mouseUp(opt_elementOrButton, opt_button) {
251
253
  return this.scheduleMouseAction_('mouseUp',
252
- command.Name.MOUSE_UP, opt_elementOrButton, opt_button);
254
+ command.Name.LEGACY_ACTION_MOUSE_UP, opt_elementOrButton, opt_button);
253
255
  }
254
256
 
255
257
  /**
@@ -261,7 +263,7 @@ class ActionSequence {
261
263
  * @param {(!./webdriver.WebElement|{x: number, y: number})} location The
262
264
  * location to drag to, either as another WebElement or an offset in
263
265
  * pixels.
264
- * @return {!ActionSequence} A self reference.
266
+ * @return {!LegacyActionSequence} A self reference.
265
267
  */
266
268
  dragAndDrop(element, location) {
267
269
  return this.mouseDown(element).mouseMove(location).mouseUp();
@@ -282,11 +284,11 @@ class ActionSequence {
282
284
  * @param {input.Button=} opt_button The button to use. Defaults to
283
285
  * {@link input.Button.LEFT}. Ignored if a button is provided as the
284
286
  * first argument.
285
- * @return {!ActionSequence} A self reference.
287
+ * @return {!LegacyActionSequence} A self reference.
286
288
  */
287
289
  click(opt_elementOrButton, opt_button) {
288
290
  return this.scheduleMouseAction_('click',
289
- command.Name.CLICK, opt_elementOrButton, opt_button);
291
+ command.Name.LEGACY_ACTION_CLICK, opt_elementOrButton, opt_button);
290
292
  }
291
293
 
292
294
  /**
@@ -307,11 +309,12 @@ class ActionSequence {
307
309
  * @param {input.Button=} opt_button The button to use. Defaults to
308
310
  * {@link input.Button.LEFT}. Ignored if a button is provided as the
309
311
  * first argument.
310
- * @return {!ActionSequence} A self reference.
312
+ * @return {!LegacyActionSequence} A self reference.
311
313
  */
312
314
  doubleClick(opt_elementOrButton, opt_button) {
313
315
  return this.scheduleMouseAction_('doubleClick',
314
- command.Name.DOUBLE_CLICK, opt_elementOrButton, opt_button);
316
+ command.Name.LEGACY_ACTION_DOUBLE_CLICK, opt_elementOrButton,
317
+ opt_button);
315
318
  }
316
319
 
317
320
  /**
@@ -320,11 +323,11 @@ class ActionSequence {
320
323
  * @param {string} description A simple descriptive label for the scheduled
321
324
  * action.
322
325
  * @param {!Array<(string|!input.Key)>} keys The keys to send.
323
- * @return {!ActionSequence} A self reference.
326
+ * @return {!LegacyActionSequence} A self reference.
324
327
  * @private
325
328
  */
326
329
  scheduleKeyboardAction_(description, keys) {
327
- let cmd = new command.Command(command.Name.SEND_KEYS_TO_ACTIVE_ELEMENT)
330
+ let cmd = new command.Command(command.Name.LEGACY_ACTION_SEND_KEYS)
328
331
  .setParameter('value', keys);
329
332
  this.schedule_(description, cmd);
330
333
  return this;
@@ -337,7 +340,7 @@ class ActionSequence {
337
340
  *
338
341
  * @param {!input.Key} key The modifier key to push. Must be one of
339
342
  * {ALT, CONTROL, SHIFT, COMMAND, META}.
340
- * @return {!ActionSequence} A self reference.
343
+ * @return {!LegacyActionSequence} A self reference.
341
344
  * @throws {error.InvalidArgumentError} If the key is not a valid modifier
342
345
  * key.
343
346
  */
@@ -351,7 +354,7 @@ class ActionSequence {
351
354
  * focused element.
352
355
  * @param {!input.Key} key The modifier key to release. Must be one of
353
356
  * {ALT, CONTROL, SHIFT, COMMAND, META}.
354
- * @return {!ActionSequence} A self reference.
357
+ * @return {!LegacyActionSequence} A self reference.
355
358
  * @throws {error.InvalidArgumentError} If the key is not a valid modifier
356
359
  * key.
357
360
  */
@@ -367,7 +370,7 @@ class ActionSequence {
367
370
  *
368
371
  * @param {...(string|!input.Key|!Array<(string|!input.Key)>)} var_args
369
372
  * The keys to type.
370
- * @return {!ActionSequence} A self reference.
373
+ * @return {!LegacyActionSequence} A self reference.
371
374
  * @throws {Error} If the key is not a valid modifier key.
372
375
  */
373
376
  sendKeys(var_args) {
@@ -386,14 +389,20 @@ class ActionSequence {
386
389
  *
387
390
  * Sample usage:
388
391
  *
389
- * driver.touchActions().
392
+ * new LegacyActions(driver).
390
393
  * tapAndHold({x: 0, y: 0}).
391
394
  * move({x: 3, y: 4}).
392
395
  * release({x: 10, y: 10}).
393
396
  * perform();
394
397
  *
398
+ * @deprecated This class is strongly deprecated and will be removed once
399
+ * [Google's Chrome][Chrome] and [Microsoft's Edge][Edge] browsers
400
+ * support the new action sequence API.
401
+ *
402
+ * [Chrome]: https://chromium.googlesource.com/chromium/src/+/master/docs/chromedriver_status.md
403
+ * [Edge]: https://docs.microsoft.com/en-us/microsoft-edge/webdriver
395
404
  */
396
- class TouchSequence {
405
+ class LegacyTouchSequence {
397
406
  /**
398
407
  * @param {!./webdriver.WebDriver} driver The driver that should be used to
399
408
  * perform this action sequence.
@@ -422,31 +431,27 @@ class TouchSequence {
422
431
 
423
432
  /**
424
433
  * Executes this action sequence.
425
- * @return {!./promise.Thenable} A promise that will be resolved once
426
- * this sequence has completed.
434
+ * @return {!Promise} A promise that will be resolved once this sequence has
435
+ * completed.
427
436
  */
428
- perform() {
437
+ async perform() {
429
438
  // Make a protected copy of the scheduled actions. This will protect against
430
439
  // users defining additional commands before this sequence is actually
431
440
  // executed.
432
441
  let actions = this.actions_.concat();
433
- let driver = this.driver_;
434
- return driver.controlFlow().execute(function() {
435
- let results = actions.map(action => {
436
- return driver.schedule(action.command, action.description);
437
- });
438
- return Promise.all(results);
439
- }, 'TouchSequence.perform');
442
+ for (let action of actions) {
443
+ await this.driver_.execute(action.command);
444
+ }
440
445
  }
441
446
 
442
447
  /**
443
448
  * Taps an element.
444
449
  *
445
450
  * @param {!./webdriver.WebElement} elem The element to tap.
446
- * @return {!TouchSequence} A self reference.
451
+ * @return {!LegacyTouchSequence} A self reference.
447
452
  */
448
453
  tap(elem) {
449
- let cmd = new command.Command(command.Name.TOUCH_SINGLE_TAP).
454
+ let cmd = new command.Command(command.Name.LEGACY_ACTION_TOUCH_SINGLE_TAP).
450
455
  setParameter('element', elem.getId());
451
456
 
452
457
  this.schedule_('tap', cmd);
@@ -457,10 +462,10 @@ class TouchSequence {
457
462
  * Double taps an element.
458
463
  *
459
464
  * @param {!./webdriver.WebElement} elem The element to double tap.
460
- * @return {!TouchSequence} A self reference.
465
+ * @return {!LegacyTouchSequence} A self reference.
461
466
  */
462
467
  doubleTap(elem) {
463
- let cmd = new command.Command(command.Name.TOUCH_DOUBLE_TAP).
468
+ let cmd = new command.Command(command.Name.LEGACY_ACTION_TOUCH_DOUBLE_TAP).
464
469
  setParameter('element', elem.getId());
465
470
 
466
471
  this.schedule_('doubleTap', cmd);
@@ -471,10 +476,10 @@ class TouchSequence {
471
476
  * Long press on an element.
472
477
  *
473
478
  * @param {!./webdriver.WebElement} elem The element to long press.
474
- * @return {!TouchSequence} A self reference.
479
+ * @return {!LegacyTouchSequence} A self reference.
475
480
  */
476
481
  longPress(elem) {
477
- let cmd = new command.Command(command.Name.TOUCH_LONG_PRESS).
482
+ let cmd = new command.Command(command.Name.LEGACY_ACTION_TOUCH_LONG_PRESS).
478
483
  setParameter('element', elem.getId());
479
484
 
480
485
  this.schedule_('longPress', cmd);
@@ -485,10 +490,10 @@ class TouchSequence {
485
490
  * Touch down at the given location.
486
491
  *
487
492
  * @param {{x: number, y: number}} location The location to touch down at.
488
- * @return {!TouchSequence} A self reference.
493
+ * @return {!LegacyTouchSequence} A self reference.
489
494
  */
490
495
  tapAndHold(location) {
491
- let cmd = new command.Command(command.Name.TOUCH_DOWN).
496
+ let cmd = new command.Command(command.Name.LEGACY_ACTION_TOUCH_DOWN).
492
497
  setParameter('x', location.x).
493
498
  setParameter('y', location.y);
494
499
 
@@ -500,10 +505,10 @@ class TouchSequence {
500
505
  * Move a held {@linkplain #tapAndHold touch} to the specified location.
501
506
  *
502
507
  * @param {{x: number, y: number}} location The location to move to.
503
- * @return {!TouchSequence} A self reference.
508
+ * @return {!LegacyTouchSequence} A self reference.
504
509
  */
505
510
  move(location) {
506
- let cmd = new command.Command(command.Name.TOUCH_MOVE).
511
+ let cmd = new command.Command(command.Name.LEGACY_ACTION_TOUCH_MOVE).
507
512
  setParameter('x', location.x).
508
513
  setParameter('y', location.y);
509
514
 
@@ -515,10 +520,10 @@ class TouchSequence {
515
520
  * Release a held {@linkplain #tapAndHold touch} at the specified location.
516
521
  *
517
522
  * @param {{x: number, y: number}} location The location to release at.
518
- * @return {!TouchSequence} A self reference.
523
+ * @return {!LegacyTouchSequence} A self reference.
519
524
  */
520
525
  release(location) {
521
- let cmd = new command.Command(command.Name.TOUCH_UP).
526
+ let cmd = new command.Command(command.Name.LEGACY_ACTION_TOUCH_UP).
522
527
  setParameter('x', location.x).
523
528
  setParameter('y', location.y);
524
529
 
@@ -530,10 +535,10 @@ class TouchSequence {
530
535
  * Scrolls the touch screen by the given offset.
531
536
  *
532
537
  * @param {{x: number, y: number}} offset The offset to scroll to.
533
- * @return {!TouchSequence} A self reference.
538
+ * @return {!LegacyTouchSequence} A self reference.
534
539
  */
535
540
  scroll(offset) {
536
- let cmd = new command.Command(command.Name.TOUCH_SCROLL).
541
+ let cmd = new command.Command(command.Name.LEGACY_ACTION_TOUCH_SCROLL).
537
542
  setParameter('xoffset', offset.x).
538
543
  setParameter('yoffset', offset.y);
539
544
 
@@ -547,10 +552,10 @@ class TouchSequence {
547
552
  *
548
553
  * @param {!./webdriver.WebElement} elem The element where scroll starts.
549
554
  * @param {{x: number, y: number}} offset The offset to scroll to.
550
- * @return {!TouchSequence} A self reference.
555
+ * @return {!LegacyTouchSequence} A self reference.
551
556
  */
552
557
  scrollFromElement(elem, offset) {
553
- let cmd = new command.Command(command.Name.TOUCH_SCROLL).
558
+ let cmd = new command.Command(command.Name.LEGACY_ACTION_TOUCH_SCROLL).
554
559
  setParameter('element', elem.getId()).
555
560
  setParameter('xoffset', offset.x).
556
561
  setParameter('yoffset', offset.y);
@@ -564,10 +569,10 @@ class TouchSequence {
564
569
  *
565
570
  * @param {{xspeed: number, yspeed: number}} speed The speed to flick in each
566
571
  direction, in pixels per second.
567
- * @return {!TouchSequence} A self reference.
572
+ * @return {!LegacyTouchSequence} A self reference.
568
573
  */
569
574
  flick(speed) {
570
- let cmd = new command.Command(command.Name.TOUCH_FLICK).
575
+ let cmd = new command.Command(command.Name.LEGACY_ACTION_TOUCH_FLICK).
571
576
  setParameter('xspeed', speed.xspeed).
572
577
  setParameter('yspeed', speed.yspeed);
573
578
 
@@ -581,10 +586,10 @@ class TouchSequence {
581
586
  * @param {!./webdriver.WebElement} elem The element where flick starts.
582
587
  * @param {{x: number, y: number}} offset The offset to flick to.
583
588
  * @param {number} speed The speed to flick at in pixels per second.
584
- * @return {!TouchSequence} A self reference.
589
+ * @return {!LegacyTouchSequence} A self reference.
585
590
  */
586
591
  flickElement(elem, offset, speed) {
587
- let cmd = new command.Command(command.Name.TOUCH_FLICK).
592
+ let cmd = new command.Command(command.Name.LEGACY_ACTION_TOUCH_FLICK).
588
593
  setParameter('element', elem.getId()).
589
594
  setParameter('xoffset', offset.x).
590
595
  setParameter('yoffset', offset.y).
@@ -599,6 +604,6 @@ class TouchSequence {
599
604
  // PUBLIC API
600
605
 
601
606
  module.exports = {
602
- ActionSequence: ActionSequence,
603
- TouchSequence: TouchSequence,
607
+ LegacyActionSequence,
608
+ LegacyTouchSequence,
604
609
  };
package/lib/by.js CHANGED
@@ -182,7 +182,7 @@ class By {
182
182
  *
183
183
  * @param {!(string|Function)} script The script to execute.
184
184
  * @param {...*} var_args The arguments to pass to the script.
185
- * @return {function(!./webdriver.WebDriver): !./promise.Promise}
185
+ * @return {function(!./webdriver.WebDriver): !Promise}
186
186
  * A new JavaScript-based locator function.
187
187
  */
188
188
  static js(script, var_args) {