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
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