selenium-webdriver 3.3.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 (117) hide show
  1. package/CHANGES.md +273 -0
  2. package/NOTICE +1 -1
  3. package/README.md +28 -36
  4. package/chrome.js +221 -146
  5. package/edge.js +43 -118
  6. package/example/chrome_android.js +8 -9
  7. package/example/chrome_mobile_emulation.js +9 -10
  8. package/example/firefox_channels.js +23 -19
  9. package/example/google_search.js +3 -3
  10. package/example/google_search_test.js +39 -27
  11. package/example/headless.js +55 -0
  12. package/example/logging.js +40 -7
  13. package/firefox.js +769 -0
  14. package/http/index.js +41 -4
  15. package/http/util.js +11 -6
  16. package/ie.js +57 -98
  17. package/index.js +182 -115
  18. package/io/index.js +59 -0
  19. package/io/zip.js +214 -0
  20. package/jasmine.json +11 -0
  21. package/lib/actions.js +68 -63
  22. package/lib/atoms/get-attribute.js +9 -0
  23. package/lib/atoms/is-displayed.js +73 -78
  24. package/lib/by.js +9 -1
  25. package/lib/capabilities.js +303 -201
  26. package/lib/command.js +28 -50
  27. package/lib/error.js +113 -42
  28. package/lib/http.js +167 -135
  29. package/lib/input.js +1044 -8
  30. package/lib/promise.js +222 -3331
  31. package/lib/proxy.js +134 -39
  32. package/lib/test/bootstrap_jasmine.js +28 -0
  33. package/lib/test/data/actions/click.html +24 -0
  34. package/lib/test/data/actions/drag.html +77 -0
  35. package/lib/test/data/actions/record_click.html +21 -0
  36. package/lib/test/data/chrome/download.html +2 -0
  37. package/lib/test/data/click_tests/disabled_element.html +12 -0
  38. package/lib/test/data/content-editable.html +10 -0
  39. package/lib/test/data/firefox/webextension.xpi +0 -0
  40. package/lib/test/data/inputs.html +42 -0
  41. package/lib/test/data/key_logger.html +34 -0
  42. package/lib/test/data/nestedElements.html +10 -1
  43. package/lib/test/data/scrolling_tests/page_with_partially_hidden_element.html +14 -0
  44. package/lib/test/data/selectPage.html +12 -0
  45. package/lib/test/data/simpleTest.html +5 -0
  46. package/lib/test/data/single_text_input.html +12 -0
  47. package/lib/test/data/upload_invisible.html +45 -0
  48. package/lib/test/fileserver.js +23 -19
  49. package/lib/test/index.js +30 -244
  50. package/lib/test/resources.js +0 -1
  51. package/lib/webdriver.js +770 -939
  52. package/net/index.js +21 -25
  53. package/net/portprober.js +51 -68
  54. package/package.json +6 -4
  55. package/remote/index.js +18 -30
  56. package/safari.js +42 -129
  57. package/test/actions_test.js +173 -18
  58. package/test/builder_test.js +106 -0
  59. package/test/chrome/devtools_test.js +93 -0
  60. package/test/chrome/options_test.js +48 -154
  61. package/test/chrome/service_test.js +7 -7
  62. package/test/cookie_test.js +77 -63
  63. package/test/element_finding_test.js +206 -201
  64. package/test/execute_script_test.js +115 -114
  65. package/test/fingerprint_test.js +16 -15
  66. package/test/firefox_test.js +251 -0
  67. package/test/http/http_test.js +18 -1
  68. package/test/http/util_test.js +2 -2
  69. package/test/{io_test.js → io/io_test.js} +40 -1
  70. package/test/io/zip_test.js +127 -0
  71. package/test/lib/by_test.js +21 -0
  72. package/test/lib/error_test.js +55 -8
  73. package/test/lib/http_test.js +18 -130
  74. package/test/lib/input_test.js +1379 -0
  75. package/test/lib/promise_test.js +473 -908
  76. package/test/lib/webdriver_test.js +357 -825
  77. package/test/logging_test.js +37 -43
  78. package/test/page_loading_test.js +70 -86
  79. package/test/proxy_test.js +64 -72
  80. package/test/rect_test.js +14 -25
  81. package/test/remote_test.js +13 -32
  82. package/test/safari_test.js +7 -71
  83. package/test/stale_element_test.js +20 -23
  84. package/test/tag_name_test.js +10 -9
  85. package/test/upload_test.js +27 -35
  86. package/test/window_test.js +72 -85
  87. package/testing/index.js +386 -315
  88. package/.npmignore +0 -2
  89. package/example/async_await_test.js +0 -68
  90. package/example/google_search_generator.js +0 -50
  91. package/example/parallel_flows.js +0 -54
  92. package/firefox/binary.js +0 -344
  93. package/firefox/extension.js +0 -187
  94. package/firefox/index.js +0 -722
  95. package/firefox/profile.js +0 -430
  96. package/lib/atoms/getAttribute.js +0 -12
  97. package/lib/events.js +0 -210
  98. package/lib/firefox/webdriver.json +0 -70
  99. package/lib/firefox/webdriver.xpi +0 -0
  100. package/lib/test/data/firefox/jetpack-sample.xpi +0 -0
  101. package/lib/test/data/firefox/sample.xpi +0 -0
  102. package/lib/test/promise.js +0 -79
  103. package/opera.js +0 -405
  104. package/phantomjs.js +0 -282
  105. package/test/firefox/extension_test.js +0 -96
  106. package/test/firefox/firefox_test.js +0 -226
  107. package/test/firefox/profile_test.js +0 -185
  108. package/test/lib/events_test.js +0 -177
  109. package/test/lib/promise_aplus_test.js +0 -78
  110. package/test/lib/promise_error_test.js +0 -884
  111. package/test/lib/promise_flow_test.js +0 -2288
  112. package/test/lib/promise_generator_test.js +0 -310
  113. package/test/phantomjs/execute_phantomjs_test.js +0 -59
  114. package/test/session_test.js +0 -54
  115. package/test/testing/assert_test.js +0 -373
  116. package/test/testing/index_test.js +0 -224
  117. package/testing/assert.js +0 -378
@@ -118,7 +118,7 @@ describe('http', function() {
118
118
  });
119
119
  });
120
120
 
121
- it('rejects commands missing URL parameters', function() {
121
+ it('rejects commands missing URL parameters', async function() {
122
122
  let command =
123
123
  new Command(CommandName.FIND_CHILD_ELEMENT).
124
124
  setParameter('sessionId', 's123').
@@ -126,12 +126,13 @@ describe('http', function() {
126
126
  setParameter('using', 'id').
127
127
  setParameter('value', 'foo');
128
128
 
129
- assert.throws(
130
- () => executor.execute(command),
131
- function(err) {
132
- return err instanceof error.InvalidArgumentError
133
- && 'Missing required parameter: id' === err.message;
134
- });
129
+ try {
130
+ await executor.execute(command);
131
+ return Promise.reject(Error('should have thrown'));
132
+ } catch (err) {
133
+ assert.strictEqual(err.constructor, error.InvalidArgumentError);
134
+ assert.equal(err.message, 'Missing required parameter: id');
135
+ }
135
136
  assert.ok(!send.called);
136
137
  });
137
138
 
@@ -153,14 +154,6 @@ describe('http', function() {
153
154
  beforeEach(() => executor = new http.Executor(client));
154
155
 
155
156
  describe('in legacy mode', function() {
156
- test(CommandName.GET_WINDOW_SIZE, {sessionId:'s123'}, false,
157
- 'GET', '/session/s123/window/current/size');
158
-
159
- test(CommandName.SET_WINDOW_SIZE,
160
- {sessionId:'s123', width: 1, height: 1}, false,
161
- 'POST', '/session/s123/window/current/size',
162
- {width: 1, height: 1});
163
-
164
157
  test(CommandName.MAXIMIZE_WINDOW, {sessionId:'s123'}, false,
165
158
  'POST', '/session/s123/window/current/maximize');
166
159
 
@@ -171,14 +164,6 @@ describe('http', function() {
171
164
  });
172
165
 
173
166
  describe('in W3C mode', function() {
174
- test(CommandName.GET_WINDOW_SIZE,
175
- {sessionId:'s123'}, true,
176
- 'GET', '/session/s123/window/size');
177
-
178
- test(CommandName.SET_WINDOW_SIZE,
179
- {sessionId:'s123', width: 1, height: 1}, true,
180
- 'POST', '/session/s123/window/size', {width: 1, height: 1});
181
-
182
167
  test(CommandName.MAXIMIZE_WINDOW, {sessionId:'s123'}, true,
183
168
  'POST', '/session/s123/window/maximize');
184
169
 
@@ -293,7 +278,14 @@ describe('http', function() {
293
278
  });
294
279
 
295
280
  it('auto-upgrades on W3C response', function() {
296
- var rawResponse = {sessionId: 's123', value: {name: 'Bob'}};
281
+ let rawResponse = {
282
+ value: {
283
+ sessionId: 's123',
284
+ value: {
285
+ name: 'Bob'
286
+ }
287
+ }
288
+ };
297
289
 
298
290
  send.returns(Promise.resolve(
299
291
  new http.Response(200, {}, JSON.stringify(rawResponse))));
@@ -344,7 +336,8 @@ describe('http', function() {
344
336
  });
345
337
 
346
338
  it('handles w3c new session failures', function() {
347
- let rawResponse = {error: 'no such element', message: 'oops'};
339
+ let rawResponse =
340
+ {value: {error: 'no such element', message: 'oops'}};
348
341
 
349
342
  send.returns(Promise.resolve(
350
343
  new http.Response(500, {}, JSON.stringify(rawResponse))));
@@ -358,111 +351,6 @@ describe('http', function() {
358
351
  });
359
352
  });
360
353
 
361
- describe('extracts Session from DESCRIBE_SESSION response', function() {
362
- let command;
363
-
364
- beforeEach(function() {
365
- executor = new http.Executor(client);
366
- command = new Command(CommandName.DESCRIBE_SESSION)
367
- .setParameter('sessionId', 'foo');
368
- });
369
-
370
- describe('fails if server returns invalid response', function() {
371
- describe('(empty response)', function() {
372
- test(true);
373
- test(false);
374
-
375
- function test(w3c) {
376
- it('w3c === ' + w3c, function() {
377
- send.returns(Promise.resolve(new http.Response(200, {}, '')));
378
- executor.w3c = w3c;
379
- return executor.execute(command).then(
380
- () => assert.fail('expected to fail'),
381
- (e) => {
382
- if (!e.message.startsWith('Unable to parse')) {
383
- throw e;
384
- }
385
- });
386
- });
387
- }
388
- });
389
-
390
- describe('(no session ID)', function() {
391
- test(true);
392
- test(false);
393
-
394
- function test(w3c) {
395
- it('w3c === ' + w3c, function() {
396
- let resp = {value:{name: 'Bob'}};
397
- send.returns(Promise.resolve(
398
- new http.Response(200, {}, JSON.stringify(resp))));
399
- executor.w3c = w3c;
400
- return executor.execute(command).then(
401
- () => assert.fail('expected to fail'),
402
- (e) => {
403
- if (!e.message.startsWith('Unable to parse')) {
404
- throw e;
405
- }
406
- });
407
- });
408
- }
409
- });
410
- });
411
-
412
- it('handles legacy response', function() {
413
- var rawResponse = {sessionId: 's123', status: 0, value: {name: 'Bob'}};
414
-
415
- send.returns(Promise.resolve(
416
- new http.Response(200, {}, JSON.stringify(rawResponse))));
417
-
418
- assert.ok(!executor.w3c);
419
- return executor.execute(command).then(function(response) {
420
- assert.ok(response instanceof Session);
421
- assert.equal(response.getId(), 's123');
422
-
423
- let caps = response.getCapabilities();
424
- assert.ok(caps instanceof Capabilities);
425
- assert.equal(caps.get('name'), 'Bob');
426
-
427
- assert.ok(!executor.w3c);
428
- });
429
- });
430
-
431
- it('does not auto-upgrade on W3C response', function() {
432
- var rawResponse = {sessionId: 's123', value: {name: 'Bob'}};
433
-
434
- send.returns(Promise.resolve(
435
- new http.Response(200, {}, JSON.stringify(rawResponse))));
436
-
437
- assert.ok(!executor.w3c);
438
- return executor.execute(command).then(function(response) {
439
- assert.ok(response instanceof Session);
440
- assert.equal(response.getId(), 's123');
441
-
442
- let caps = response.getCapabilities();
443
- assert.ok(caps instanceof Capabilities);
444
- assert.equal(caps.get('name'), 'Bob');
445
-
446
- assert.ok(!executor.w3c);
447
- });
448
- });
449
-
450
- it('if w3c, does not downgrade on legacy response', function() {
451
- var rawResponse = {sessionId: 's123', status: 0, value: null};
452
-
453
- send.returns(Promise.resolve(
454
- new http.Response(200, {}, JSON.stringify(rawResponse))));
455
-
456
- executor.w3c = true;
457
- return executor.execute(command).then(function(response) {
458
- assert.ok(response instanceof Session);
459
- assert.equal(response.getId(), 's123');
460
- assert.equal(response.getCapabilities().size, 0);
461
- assert.ok(executor.w3c, 'should never downgrade');
462
- });
463
- });
464
- });
465
-
466
354
  it('handles JSON null', function() {
467
355
  var command = new Command(CommandName.GET_CURRENT_URL)
468
356
  .setParameter('sessionId', 's123');