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/testing/assert.js DELETED
@@ -1,378 +0,0 @@
1
- // Licensed to the Software Freedom Conservancy (SFC) under one
2
- // or more contributor license agreements. See the NOTICE file
3
- // distributed with this work for additional information
4
- // regarding copyright ownership. The SFC licenses this file
5
- // to you under the Apache License, Version 2.0 (the
6
- // "License"); you may not use this file except in compliance
7
- // with the License. You may obtain a copy of the License at
8
- //
9
- // http://www.apache.org/licenses/LICENSE-2.0
10
- //
11
- // Unless required by applicable law or agreed to in writing,
12
- // software distributed under the License is distributed on an
13
- // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
- // KIND, either express or implied. See the License for the
15
- // specific language governing permissions and limitations
16
- // under the License.
17
-
18
- /**
19
- * @fileoverview Defines a library that simplifies writing assertions against
20
- * promised values.
21
- *
22
- * > <hr>
23
- * > __NOTE:__ This module is considered experimental and is subject to
24
- * > change, or removal, at any time!
25
- * > <hr>
26
- *
27
- * Sample usage:
28
- *
29
- * var driver = new webdriver.Builder().build();
30
- * driver.get('http://www.google.com');
31
- *
32
- * assert(driver.getTitle()).equalTo('Google');
33
- */
34
-
35
- 'use strict';
36
-
37
- const assert = require('assert');
38
-
39
- function trueType(v) {
40
- if (v === null) {
41
- return 'null';
42
- }
43
-
44
- let type = typeof v;
45
- if (type === 'object') {
46
- if (Array.isArray(v)) {
47
- type = 'array';
48
- }
49
- }
50
- return type;
51
- }
52
-
53
-
54
- function checkType(v, want) {
55
- let got = trueType(v);
56
- if (got !== want) {
57
- throw new TypeError('require ' + want + ', but got ' + got);
58
- }
59
- return v;
60
- }
61
-
62
- const checkNumber = v => checkType(v, 'number');
63
- const checkFunction = v => checkType(v, 'function');
64
- const checkString = v => checkType(v, 'string');
65
-
66
- const isFunction = v => trueType(v) === 'function';
67
- const isNumber = v => trueType(v) === 'number';
68
- const isObject = v => trueType(v) === 'object';
69
- const isString = v => trueType(v) === 'string';
70
-
71
-
72
- function describe(value) {
73
- let ret;
74
- try {
75
- ret = `<${String(value)}>`;
76
- } catch (e) {
77
- ret = `<toString failed: ${e.message}>`;
78
- }
79
-
80
- if (null !== value && void(0) !== value) {
81
- ret += ` (${trueType(value)})`;
82
- }
83
-
84
- return ret;
85
- }
86
-
87
-
88
- function evaluate(value, predicate) {
89
- if (isObject(value) && isFunction(value.then)) {
90
- return value.then(predicate);
91
- }
92
- predicate(value);
93
- }
94
-
95
-
96
- /**
97
- * @private
98
- */
99
- class Assertion {
100
- /**
101
- * @param {?} subject The subject of this assertion.
102
- * @param {boolean=} opt_invert Whether to invert any assertions performed by
103
- * this instance.
104
- */
105
- constructor(subject, opt_invert) {
106
- /** @private {?} */
107
- this.subject_ = subject;
108
- /** @private {boolean} */
109
- this.invert_ = !!opt_invert;
110
- }
111
-
112
- /**
113
- * @param {number} expected The minimum permissible value (inclusive).
114
- * @param {string=} opt_message An optional failure message.
115
- * @return {(Promise|undefined)} The result of this assertion, if the subject
116
- * is a promised-value. Otherwise, the assertion is performed immediately
117
- * and nothing is returned.
118
- */
119
- atLeast(expected, opt_message) {
120
- checkNumber(expected);
121
- return evaluate(this.subject_, function(actual) {
122
- if (!isNumber(actual) || actual < expected) {
123
- assert.fail(actual, expected, opt_message, '>=');
124
- }
125
- });
126
- }
127
-
128
- /**
129
- * @param {number} expected The maximum permissible value (inclusive).
130
- * @param {string=} opt_message An optional failure message.
131
- * @return {(Promise|undefined)} The result of this assertion, if the subject
132
- * is a promised-value. Otherwise, the assertion is performed immediately
133
- * and nothing is returned.
134
- */
135
- atMost(expected, opt_message) {
136
- checkNumber(expected);
137
- return evaluate(this.subject_, function (actual) {
138
- if (!isNumber(actual) || actual > expected) {
139
- assert.fail(actual, expected, opt_message, '<=');
140
- }
141
- });
142
- }
143
-
144
- /**
145
- * @param {number} expected The maximum permissible value (exclusive).
146
- * @param {string=} opt_message An optional failure message.
147
- * @return {(Promise|undefined)} The result of this assertion, if the subject
148
- * is a promised-value. Otherwise, the assertion is performed immediately
149
- * and nothing is returned.
150
- */
151
- greaterThan(expected, opt_message) {
152
- checkNumber(expected);
153
- return evaluate(this.subject_, function(actual) {
154
- if (!isNumber(actual) || actual <= expected) {
155
- assert.fail(actual, expected, opt_message, '>');
156
- }
157
- });
158
- }
159
-
160
- /**
161
- * @param {number} expected The minimum permissible value (exclusive).
162
- * @param {string=} opt_message An optional failure message.
163
- * @return {(Promise|undefined)} The result of this assertion, if the subject
164
- * is a promised-value. Otherwise, the assertion is performed immediately
165
- * and nothing is returned.
166
- */
167
- lessThan(expected, opt_message) {
168
- checkNumber(expected);
169
- return evaluate(this.subject_, function (actual) {
170
- if (!isNumber(actual) || actual >= expected) {
171
- assert.fail(actual, expected, opt_message, '<');
172
- }
173
- });
174
- }
175
-
176
- /**
177
- * @param {number} expected The desired value.
178
- * @param {number} epsilon The maximum distance from the desired value.
179
- * @param {string=} opt_message An optional failure message.
180
- * @return {(Promise|undefined)} The result of this assertion, if the subject
181
- * is a promised-value. Otherwise, the assertion is performed immediately
182
- * and nothing is returned.
183
- */
184
- closeTo(expected, epsilon, opt_message) {
185
- checkNumber(expected);
186
- checkNumber(epsilon);
187
- return evaluate(this.subject_, function(actual) {
188
- checkNumber(actual);
189
- if (Math.abs(expected - actual) > epsilon) {
190
- assert.fail(opt_message || `${actual} === ${expected} (± ${epsilon})`);
191
- }
192
- });
193
- }
194
-
195
- /**
196
- * @param {function(new: ?)} ctor The exptected type's constructor.
197
- * @param {string=} opt_message An optional failure message.
198
- * @return {(Promise|undefined)} The result of this assertion, if the subject
199
- * is a promised-value. Otherwise, the assertion is performed immediately
200
- * and nothing is returned.
201
- */
202
- instanceOf(ctor, opt_message) {
203
- checkFunction(ctor);
204
- return evaluate(this.subject_, function(actual) {
205
- if (!(actual instanceof ctor)) {
206
- assert.fail(
207
- opt_message
208
- || `${describe(actual)} instanceof ${ctor.name || ctor}`);
209
- }
210
- });
211
- }
212
-
213
- /**
214
- * @param {string=} opt_message An optional failure message.
215
- * @return {(Promise|undefined)} The result of this assertion, if the subject
216
- * is a promised-value. Otherwise, the assertion is performed immediately
217
- * and nothing is returned.
218
- */
219
- isNull(opt_message) {
220
- return this.isEqualTo(null);
221
- }
222
-
223
- /**
224
- * @param {string=} opt_message An optional failure message.
225
- * @return {(Promise|undefined)} The result of this assertion, if the subject
226
- * is a promised-value. Otherwise, the assertion is performed immediately
227
- * and nothing is returned.
228
- */
229
- isUndefined(opt_message) {
230
- return this.isEqualTo(void(0));
231
- }
232
-
233
- /**
234
- * Ensures the subject of this assertion is either a string or array
235
- * containing the given `value`.
236
- *
237
- * @param {?} value The value expected to be contained within the subject.
238
- * @param {string=} opt_message An optional failure message.
239
- * @return {(Promise|undefined)} The result of this assertion, if the subject
240
- * is a promised-value. Otherwise, the assertion is performed immediately
241
- * and nothing is returned.
242
- */
243
- contains(value, opt_message) {
244
- return evaluate(this.subject_, function(actual) {
245
- if (actual instanceof Map || actual instanceof Set) {
246
- assert.ok(actual.has(value), opt_message || `${actual}.has(${value})`);
247
- } else if (Array.isArray(actual) || isString(actual)) {
248
- assert.ok(
249
- actual.indexOf(value) !== -1,
250
- opt_message || `${actual}.indexOf(${value}) !== -1`);
251
- } else {
252
- assert.fail(
253
- `Expected an array, map, set, or string: got ${describe(actual)}`);
254
- }
255
- });
256
- }
257
-
258
- /**
259
- * @param {string} str The expected suffix.
260
- * @param {string=} opt_message An optional failure message.
261
- * @return {(Promise|undefined)} The result of this assertion, if the subject
262
- * is a promised-value. Otherwise, the assertion is performed immediately
263
- * and nothing is returned.
264
- */
265
- endsWith(str, opt_message) {
266
- checkString(str);
267
- return evaluate(this.subject_, function(actual) {
268
- if (!isString(actual) || !actual.endsWith(str)) {
269
- assert.fail(actual, str, 'ends with');
270
- }
271
- });
272
- }
273
-
274
- /**
275
- * @param {string} str The expected prefix.
276
- * @param {string=} opt_message An optional failure message.
277
- * @return {(Promise|undefined)} The result of this assertion, if the subject
278
- * is a promised-value. Otherwise, the assertion is performed immediately
279
- * and nothing is returned.
280
- */
281
- startsWith(str, opt_message) {
282
- checkString(str);
283
- return evaluate(this.subject_, function(actual) {
284
- if (!isString(actual) || !actual.startsWith(str)) {
285
- assert.fail(actual, str, 'starts with');
286
- }
287
- });
288
- }
289
-
290
- /**
291
- * @param {!RegExp} regex The regex the subject is expected to match.
292
- * @param {string=} opt_message An optional failure message.
293
- * @return {(Promise|undefined)} The result of this assertion, if the subject
294
- * is a promised-value. Otherwise, the assertion is performed immediately
295
- * and nothing is returned.
296
- */
297
- matches(regex, opt_message) {
298
- if (!(regex instanceof RegExp)) {
299
- throw TypeError(`Not a RegExp: ${describe(regex)}`);
300
- }
301
- return evaluate(this.subject_, function(actual) {
302
- if (!isString(actual) || !regex.test(actual)) {
303
- let message = opt_message
304
- || `Expected a string matching ${regex}, got ${describe(actual)}`;
305
- assert.fail(actual, regex, message);
306
- }
307
- });
308
- }
309
-
310
- /**
311
- * @param {?} value The unexpected value.
312
- * @param {string=} opt_message An optional failure message.
313
- * @return {(Promise|undefined)} The result of this assertion, if the subject
314
- * is a promised-value. Otherwise, the assertion is performed immediately
315
- * and nothing is returned.
316
- */
317
- notEqualTo(value, opt_message) {
318
- return evaluate(this.subject_, function(actual) {
319
- assert.notStrictEqual(actual, value, opt_message);
320
- });
321
- }
322
-
323
- /** An alias for {@link #isEqualTo}. */
324
- equalTo(value, opt_message) {
325
- return this.isEqualTo(value, opt_message);
326
- }
327
-
328
- /** An alias for {@link #isEqualTo}. */
329
- equals(value, opt_message) {
330
- return this.isEqualTo(value, opt_message);
331
- }
332
-
333
- /**
334
- * @param {?} value The expected value.
335
- * @param {string=} opt_message An optional failure message.
336
- * @return {(Promise|undefined)} The result of this assertion, if the subject
337
- * is a promised-value. Otherwise, the assertion is performed immediately
338
- * and nothing is returned.
339
- */
340
- isEqualTo(value, opt_message) {
341
- return evaluate(this.subject_, function(actual) {
342
- assert.strictEqual(actual, value, opt_message);
343
- });
344
- }
345
-
346
- /**
347
- * @param {string=} opt_message An optional failure message.
348
- * @return {(Promise|undefined)} The result of this assertion, if the subject
349
- * is a promised-value. Otherwise, the assertion is performed immediately
350
- * and nothing is returned.
351
- */
352
- isTrue(opt_message) {
353
- return this.isEqualTo(true, opt_message);
354
- }
355
-
356
- /**
357
- * @param {string=} opt_message An optional failure message.
358
- * @return {(Promise|undefined)} The result of this assertion, if the subject
359
- * is a promised-value. Otherwise, the assertion is performed immediately
360
- * and nothing is returned.
361
- */
362
- isFalse(opt_message) {
363
- return this.isEqualTo(false, opt_message);
364
- }
365
- }
366
-
367
-
368
- // PUBLIC API
369
-
370
-
371
- /**
372
- * Creates an assertion about the given `value`.
373
- * @return {!Assertion} the new assertion.
374
- */
375
- module.exports = function assertThat(value) {
376
- return new Assertion(value);
377
- };
378
- module.exports.Assertion = Assertion; // Exported to help generated docs