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
package/http/util.js CHANGED
@@ -61,38 +61,54 @@ exports.getStatus = getStatus;
61
61
  * Waits for a WebDriver server to be healthy and accepting requests.
62
62
  * @param {string} url Base URL of the server to query.
63
63
  * @param {number} timeout How long to wait for the server.
64
- * @return {!promise.Promise} A promise that will resolve when the
65
- * server is ready.
64
+ * @param {Promise=} opt_cancelToken A promise used as a cancellation signal:
65
+ * if resolved before the server is ready, the wait will be terminated
66
+ * early with a {@link promise.CancellationError}.
67
+ * @return {!Promise} A promise that will resolve when the server is ready, or
68
+ * if the wait is cancelled.
66
69
  */
67
- exports.waitForServer = function(url, timeout) {
68
- var ready = promise.defer(),
69
- start = Date.now();
70
- checkServerStatus();
71
- return ready.promise;
72
-
73
- function checkServerStatus() {
74
- return getStatus(url).then(status => ready.fulfill(status), onError);
75
- }
76
-
77
- function onError(e) {
78
- // Some servers don't support the status command. If they are able to
79
- // response with an error, then can consider the server ready.
80
- if (e instanceof error.UnsupportedOperationError) {
81
- ready.fulfill();
82
- return;
70
+ exports.waitForServer = function(url, timeout, opt_cancelToken) {
71
+ return new Promise((onResolve, onReject) => {
72
+ let start = Date.now();
73
+
74
+ let done = false;
75
+ let resolve = (status) => {
76
+ done = true;
77
+ onResolve(status);
78
+ };
79
+ let reject = (err) => {
80
+ done = true;
81
+ onReject(err);
82
+ };
83
+
84
+ if (opt_cancelToken) {
85
+ opt_cancelToken.then(_ => reject(new promise.CancellationError));
83
86
  }
84
87
 
85
- if (Date.now() - start > timeout) {
86
- ready.reject(
87
- Error('Timed out waiting for the WebDriver server at ' + url));
88
- } else {
89
- setTimeout(function() {
90
- if (ready.promise.isPending()) {
91
- checkServerStatus();
92
- }
93
- }, 50);
88
+ checkServerStatus();
89
+ function checkServerStatus() {
90
+ return getStatus(url).then(status => resolve(status), onError);
94
91
  }
95
- }
92
+
93
+ function onError(e) {
94
+ // Some servers don't support the status command. If they are able to
95
+ // response with an error, then can consider the server ready.
96
+ if (e instanceof error.UnsupportedOperationError) {
97
+ resolve({});
98
+ return;
99
+ }
100
+
101
+ if (Date.now() - start > timeout) {
102
+ reject(Error('Timed out waiting for the WebDriver server at ' + url));
103
+ } else {
104
+ setTimeout(function() {
105
+ if (!done) {
106
+ checkServerStatus();
107
+ }
108
+ }, 50);
109
+ }
110
+ }
111
+ });
96
112
  };
97
113
 
98
114
 
@@ -101,39 +117,59 @@ exports.waitForServer = function(url, timeout) {
101
117
  * timeout expires.
102
118
  * @param {string} url The URL to poll.
103
119
  * @param {number} timeout How long to wait, in milliseconds.
104
- * @return {!promise.Promise} A promise that will resolve when the
105
- * URL responds with 2xx.
120
+ * @param {Promise=} opt_cancelToken A promise used as a cancellation signal:
121
+ * if resolved before the a 2xx response is received, the wait will be
122
+ * terminated early with a {@link promise.CancellationError}.
123
+ * @return {!Promise} A promise that will resolve when a 2xx is received from
124
+ * the given URL, or if the wait is cancelled.
106
125
  */
107
- exports.waitForUrl = function(url, timeout) {
108
- var client = new HttpClient(url),
109
- request = new HttpRequest('GET', ''),
110
- ready = promise.defer(),
111
- start = Date.now();
112
- testUrl();
113
- return ready.promise;
114
-
115
- function testUrl() {
116
- client.send(request).then(onResponse, onError);
117
- }
118
-
119
- function onError() {
120
- if (Date.now() - start > timeout) {
121
- ready.reject(Error(
122
- 'Timed out waiting for the URL to return 2xx: ' + url));
123
- } else {
124
- setTimeout(function() {
125
- if (ready.promise.isPending()) {
126
- testUrl();
127
- }
128
- }, 50);
126
+ exports.waitForUrl = function(url, timeout, opt_cancelToken) {
127
+ return new Promise((onResolve, onReject) => {
128
+ let client = new HttpClient(url);
129
+ let request = new HttpRequest('GET', '');
130
+ let start = Date.now();
131
+
132
+ let done = false;
133
+ let resolve = () => {
134
+ done = true;
135
+ onResolve();
136
+ };
137
+ let reject = (err) => {
138
+ done = true;
139
+ onReject(err);
140
+ };
141
+
142
+ if (opt_cancelToken) {
143
+ opt_cancelToken.then(_ => reject(new promise.CancellationError));
144
+ }
145
+
146
+ testUrl();
147
+
148
+ function testUrl() {
149
+ client.send(request).then(onResponse, onError);
150
+ }
151
+
152
+ function onError() {
153
+ if (Date.now() - start > timeout) {
154
+ reject(Error('Timed out waiting for the URL to return 2xx: ' + url));
155
+ } else {
156
+ setTimeout(function() {
157
+ if (!done) {
158
+ testUrl();
159
+ }
160
+ }, 50);
161
+ }
129
162
  }
130
- }
131
163
 
132
- function onResponse(response) {
133
- if (!ready.promise.isPending()) return;
134
- if (response.status > 199 && response.status < 300) {
135
- return ready.fulfill();
164
+ function onResponse(response) {
165
+ if (done) {
166
+ return;
167
+ }
168
+ if (response.status > 199 && response.status < 300) {
169
+ resolve();
170
+ return;
171
+ }
172
+ onError();
136
173
  }
137
- onError();
138
- }
174
+ });
139
175
  };
package/ie.js CHANGED
@@ -403,12 +403,15 @@ function createServiceFromCapabilities(capabilities) {
403
403
  */
404
404
  class Driver extends webdriver.WebDriver {
405
405
  /**
406
+ * Creates a new session for Microsoft's Internet Explorer.
407
+ *
406
408
  * @param {(capabilities.Capabilities|Options)=} opt_config The configuration
407
409
  * options.
408
410
  * @param {promise.ControlFlow=} opt_flow The control flow to use,
409
411
  * or {@code null} to use the currently active flow.
412
+ * @return {!Driver} A new driver instance.
410
413
  */
411
- constructor(opt_config, opt_flow) {
414
+ static createSession(opt_config, opt_flow) {
412
415
  var caps = opt_config instanceof Options ?
413
416
  opt_config.toCapabilities() :
414
417
  (opt_config || capabilities.Capabilities.ie());
@@ -416,16 +419,9 @@ class Driver extends webdriver.WebDriver {
416
419
  var service = createServiceFromCapabilities(caps);
417
420
  var client = service.start().then(url => new http.HttpClient(url));
418
421
  var executor = new http.Executor(client);
419
- var driver = webdriver.WebDriver.createSession(executor, caps, opt_flow);
420
-
421
- super(driver.getSession(), executor, driver.controlFlow());
422
-
423
- let boundQuit = this.quit.bind(this);
424
422
 
425
- /** @override */
426
- this.quit = function() {
427
- return boundQuit().finally(service.kill.bind(service));
428
- };
423
+ return /** @type {!Driver} */(webdriver.WebDriver.createSession(
424
+ executor, caps, opt_flow, this, () => service.kill()));
429
425
  }
430
426
 
431
427
  /**