selenium-webdriver 3.0.0-beta-1 → 3.0.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 (77) hide show
  1. package/CHANGES.md +109 -0
  2. package/LICENSE +1 -1
  3. package/README.md +7 -6
  4. package/chrome.js +31 -128
  5. package/edge.js +13 -91
  6. package/example/chrome_android.js +18 -13
  7. package/example/chrome_mobile_emulation.js +19 -15
  8. package/example/google_search.js +11 -11
  9. package/example/google_search_generator.js +23 -18
  10. package/example/google_search_test.js +31 -17
  11. package/example/logging.js +9 -17
  12. package/example/parallel_flows.js +3 -0
  13. package/firefox/binary.js +17 -0
  14. package/firefox/index.js +198 -101
  15. package/firefox/profile.js +24 -3
  16. package/http/util.js +95 -59
  17. package/ie.js +6 -10
  18. package/index.js +636 -2
  19. package/lib/actions.js +18 -10
  20. package/lib/atoms/getAttribute.js +11 -0
  21. package/lib/atoms/isDisplayed.js +106 -0
  22. package/lib/firefox/amd64/libnoblur64.so +0 -0
  23. package/lib/firefox/i386/libnoblur.so +0 -0
  24. package/lib/firefox/webdriver.xpi +0 -0
  25. package/lib/http.js +159 -46
  26. package/lib/logging.js +7 -1
  27. package/lib/promise.js +602 -358
  28. package/lib/proxy.js +28 -0
  29. package/lib/session.js +1 -1
  30. package/lib/test/build.js +26 -28
  31. package/lib/test/data/formPage.html +1 -0
  32. package/lib/test/fileserver.js +12 -10
  33. package/lib/test/httpserver.js +4 -6
  34. package/lib/test/index.js +18 -11
  35. package/lib/test/promise.js +79 -0
  36. package/lib/webdriver.js +587 -479
  37. package/opera.js +12 -88
  38. package/package.json +13 -14
  39. package/phantomjs.js +7 -14
  40. package/remote/index.js +201 -30
  41. package/safari.js +62 -416
  42. package/test/actions_test.js +9 -11
  43. package/test/chrome/options_test.js +8 -8
  44. package/test/chrome/service_test.js +2 -2
  45. package/test/cookie_test.js +57 -57
  46. package/test/element_finding_test.js +201 -185
  47. package/test/execute_script_test.js +108 -111
  48. package/test/fingerprint_test.js +16 -11
  49. package/test/firefox/firefox_test.js +75 -49
  50. package/test/firefox/profile_test.js +1 -3
  51. package/test/http/util_test.js +21 -27
  52. package/test/io_test.js +2 -5
  53. package/test/lib/http_test.js +8 -6
  54. package/test/lib/promise_aplus_test.js +48 -44
  55. package/test/lib/promise_error_test.js +687 -611
  56. package/test/lib/promise_flow_test.js +1810 -1806
  57. package/test/lib/promise_generator_test.js +227 -225
  58. package/test/lib/promise_test.js +864 -835
  59. package/test/lib/until_test.js +1 -1
  60. package/test/lib/webdriver_test.js +520 -424
  61. package/test/logging_test.js +43 -45
  62. package/test/net/portprober_test.js +23 -24
  63. package/test/page_loading_test.js +84 -78
  64. package/test/phantomjs/execute_phantomjs_test.js +11 -25
  65. package/test/proxy_test.js +23 -23
  66. package/test/remote_test.js +22 -22
  67. package/test/safari_test.js +108 -0
  68. package/test/session_test.js +11 -10
  69. package/test/stale_element_test.js +18 -16
  70. package/test/tag_name_test.js +7 -5
  71. package/test/testing/assert_test.js +2 -3
  72. package/test/testing/index_test.js +163 -117
  73. package/test/upload_test.js +13 -13
  74. package/test/window_test.js +94 -70
  75. package/testing/index.js +176 -37
  76. package/builder.js +0 -553
  77. package/lib/safari/client.js +0 -56
@@ -17,11 +17,12 @@
17
17
 
18
18
  'use strict';
19
19
 
20
- var assert = require('assert'),
21
- http = require('http');
20
+ const assert = require('assert');
21
+ const http = require('http');
22
22
 
23
- var error = require('../../lib/error');
24
- var util = require('../../http/util');
23
+ const error = require('../../lib/error');
24
+ const util = require('../../http/util');
25
+ const promise = require('../../lib/promise');
25
26
 
26
27
  describe('selenium-webdriver/http/util', function() {
27
28
 
@@ -123,19 +124,15 @@ describe('selenium-webdriver/http/util', function() {
123
124
  function() {});
124
125
  });
125
126
 
126
- it('can cancel wait', function(done) {
127
+ it('can cancel wait', function() {
127
128
  status = 1;
128
- var err = Error('cancelled!');
129
- var isReady = util.waitForServer(baseUrl, 200).
130
- then(function() { done('Did not expect to succeed'); }).
131
- then(null, function(e) {
132
- assert.equal('cancelled!', e.message);
133
- }).
134
- then(function() { done(); }, done);
135
-
136
- setTimeout(function() {
137
- isReady.cancel('cancelled!');
138
- }, 50);
129
+ let cancel = new Promise(resolve => {
130
+ setTimeout(_ => resolve(), 50)
131
+ });
132
+ return util.waitForServer(baseUrl, 200, cancel)
133
+ .then(
134
+ () => { throw Error('Did not expect to succeed!'); },
135
+ (e) => assert.ok(e instanceof promise.CancellationError));
139
136
  });
140
137
  });
141
138
 
@@ -167,18 +164,15 @@ describe('selenium-webdriver/http/util', function() {
167
164
  });
168
165
  });
169
166
 
170
- it('can cancel wait', function(done) {
167
+ it('can cancel wait', function() {
171
168
  responseCode = 404;
172
- var isReady = util.waitForUrl(baseUrl, 200).
173
- then(function() { done('Did not expect to succeed'); }).
174
- then(null, function(e) {
175
- assert.equal('cancelled!', e.message);
176
- }).
177
- then(function() { done(); }, done);
178
-
179
- setTimeout(function() {
180
- isReady.cancel('cancelled!');
181
- }, 50);
169
+ let cancel = new Promise(resolve => {
170
+ setTimeout(_ => resolve(), 50);
171
+ });
172
+ return util.waitForUrl(baseUrl, 200, cancel)
173
+ .then(
174
+ () => { throw Error('Did not expect to succeed!'); },
175
+ (e) => assert.ok(e instanceof promise.CancellationError));
182
176
  });
183
177
  });
184
178
  });
package/test/io_test.js CHANGED
@@ -22,10 +22,7 @@ var assert = require('assert'),
22
22
  path = require('path'),
23
23
  tmp = require('tmp');
24
24
 
25
- var io = require('../io'),
26
- before = require('../testing').before,
27
- beforeEach = require('../testing').beforeEach,
28
- it = require('../testing').it;
25
+ var io = require('../io');
29
26
 
30
27
 
31
28
  describe('io', function() {
@@ -310,7 +307,7 @@ describe('io', function() {
310
307
  });
311
308
 
312
309
  it('catches errors from invalid input', function() {
313
- return io.read(1234)
310
+ return io.read({})
314
311
  .then(() => assert.fail('should have failed'),
315
312
  (e) => assert.ok(e instanceof TypeError));
316
313
  });
@@ -84,12 +84,14 @@ describe('http', function() {
84
84
 
85
85
  describe('command routing', function() {
86
86
  it('rejects unrecognized commands', function() {
87
- assert.throws(
88
- () => executor.execute(new Command('fake-name')),
89
- function (err) {
90
- return err instanceof error.UnknownCommandError
91
- && 'Unrecognized command: fake-name' === err.message;
92
- });
87
+ return executor.execute(new Command('fake-name'))
88
+ .then(assert.fail, err => {
89
+ if (err instanceof error.UnknownCommandError
90
+ && 'Unrecognized command: fake-name' === err.message) {
91
+ return;
92
+ }
93
+ throw err;
94
+ })
93
95
  });
94
96
 
95
97
  it('rejects promise if client fails to send request', function() {
@@ -18,57 +18,61 @@
18
18
  'use strict';
19
19
 
20
20
  const promise = require('../../lib/promise');
21
+ const {enablePromiseManager} = require('../../lib/test/promise');
21
22
 
22
23
  describe('Promises/A+ Compliance Tests', function() {
23
- // The promise spec does not define behavior for unhandled rejections and
24
- // assumes they are effectively swallowed. This is not the case with our
25
- // implementation, so we have to disable error propagation to test that the
26
- // rest of our behavior is compliant.
27
- // We run the tests with a separate instance of the control flow to ensure
28
- // disablign error propagation does not impact other tests.
29
- var flow = new promise.ControlFlow();
30
- flow.setPropagateUnhandledRejections(false);
24
+ enablePromiseManager(() => {
25
+ // The promise spec does not define behavior for unhandled rejections and
26
+ // assumes they are effectively swallowed. This is not the case with our
27
+ // implementation, so we have to disable error propagation to test that the
28
+ // rest of our behavior is compliant.
29
+ // We run the tests with a separate instance of the control flow to ensure
30
+ // disablign error propagation does not impact other tests.
31
+ var flow = new promise.ControlFlow();
32
+ flow.setPropagateUnhandledRejections(false);
31
33
 
32
- // Skip the tests in 2.2.6.1/2. We are not compliant in these scenarios.
33
- var realDescribe = global.describe;
34
- global.describe = function(name, fn) {
35
- realDescribe(name, function() {
36
- var prefix = 'Promises/A+ Compliance Tests 2.2.6: '
37
- + '`then` may be called multiple times on the same promise.';
38
- var suffix = 'even when one handler is added inside another handler';
39
- if (this.fullTitle().startsWith(prefix)
40
- && this.fullTitle().endsWith(suffix)) {
41
- var realSpecify = global.specify;
42
- try {
43
- global.specify = function(name) {
44
- realSpecify(name);
45
- };
34
+ // Skip the tests in 2.2.6.1/2. We are not compliant in these scenarios.
35
+ var realDescribe = global.describe;
36
+ global.describe = function(name, fn) {
37
+ realDescribe(name, function() {
38
+ var prefix = 'Promises/A+ Compliance Tests '
39
+ + 'SELENIUM_PROMISE_MANAGER=true 2.2.6: '
40
+ + '`then` may be called multiple times on the same promise.';
41
+ var suffix = 'even when one handler is added inside another handler';
42
+ if (this.fullTitle().startsWith(prefix)
43
+ && this.fullTitle().endsWith(suffix)) {
44
+ var realSpecify = global.specify;
45
+ try {
46
+ global.specify = function(name) {
47
+ realSpecify(name);
48
+ };
49
+ fn();
50
+ } finally {
51
+ global.specify = realSpecify;
52
+ }
53
+ } else {
46
54
  fn();
47
- } finally {
48
- global.specify = realSpecify;
49
55
  }
50
- } else {
51
- fn();
56
+ });
57
+ };
58
+
59
+ require('promises-aplus-tests').mocha({
60
+ resolved: function(value) {
61
+ return new promise.Promise((fulfill) => fulfill(value), flow);
62
+ },
63
+ rejected: function(error) {
64
+ return new promise.Promise((_, reject) => reject(error), flow);
65
+ },
66
+ deferred: function() {
67
+ var d = new promise.Deferred(flow);
68
+ return {
69
+ resolve: d.fulfill,
70
+ reject: d.reject,
71
+ promise: d.promise
72
+ };
52
73
  }
53
74
  });
54
- };
55
75
 
56
- require('promises-aplus-tests').mocha({
57
- resolved: function(value) {
58
- return new promise.Promise((fulfill) => fulfill(value), flow);
59
- },
60
- rejected: function(error) {
61
- return new promise.Promise((_, reject) => reject(error), flow);
62
- },
63
- deferred: function() {
64
- var d = new promise.Deferred(flow);
65
- return {
66
- resolve: d.fulfill,
67
- reject: d.reject,
68
- promise: d.promise
69
- };
70
- }
76
+ global.describe = realDescribe;
71
77
  });
72
-
73
- global.describe = realDescribe;
74
78
  });