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
@@ -1,310 +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
- 'use strict';
19
-
20
- const assert = require('assert');
21
- const promise = require('../../lib/promise');
22
- const {enablePromiseManager, promiseManagerSuite} = require('../../lib/test/promise');
23
-
24
- describe('promise.consume()', function() {
25
- promiseManagerSuite(() => {
26
- it('requires inputs to be generator functions', function() {
27
- assert.throws(function() {
28
- promise.consume(function() {});
29
- });
30
- });
31
-
32
- it('handles a basic generator with no yielded promises', function() {
33
- var values = [];
34
- return promise.consume(function* () {
35
- var i = 0;
36
- while (i < 4) {
37
- i = yield i + 1;
38
- values.push(i);
39
- }
40
- }).then(function() {
41
- assert.deepEqual([1, 2, 3, 4], values);
42
- });
43
- });
44
-
45
- it('handles a promise yielding generator', function() {
46
- var values = [];
47
- return promise.consume(function* () {
48
- var i = 0;
49
- while (i < 4) {
50
- // Test that things are actually async here.
51
- setTimeout(function() {
52
- values.push(i * 2);
53
- }, 10);
54
-
55
- yield promise.delayed(10).then(function() {
56
- values.push(i++);
57
- });
58
- }
59
- }).then(function() {
60
- assert.deepEqual([0, 0, 2, 1, 4, 2, 6, 3], values);
61
- });
62
- });
63
-
64
- it('assignments to yielded promises get fulfilled value', function() {
65
- return promise.consume(function* () {
66
- let x = yield Promise.resolve(2);
67
- assert.equal(2, x);
68
- });
69
- });
70
-
71
- it('uses final return value as fulfillment value', function() {
72
- return promise.consume(function* () {
73
- yield 1;
74
- yield 2;
75
- return 3;
76
- }).then(function(value) {
77
- assert.equal(3, value);
78
- });
79
- });
80
-
81
- it('throws rejected promise errors within the generator', function() {
82
- var values = [];
83
- return promise.consume(function* () {
84
- values.push('a');
85
- var e = Error('stub error');
86
- try {
87
- yield Promise.reject(e);
88
- values.push('b');
89
- } catch (ex) {
90
- assert.equal(e, ex);
91
- values.push('c');
92
- }
93
- values.push('d');
94
- }).then(function() {
95
- assert.deepEqual(['a', 'c', 'd'], values);
96
- });
97
- });
98
-
99
- it('aborts the generator if there is an unhandled rejection', function() {
100
- var values = [];
101
- var e = Error('stub error');
102
- return promise.consume(function* () {
103
- values.push(1);
104
- yield promise.rejected(e);
105
- values.push(2);
106
- }).catch(function() {
107
- assert.deepEqual([1], values);
108
- });
109
- });
110
-
111
- it('yield waits for promises', function() {
112
- let values = [];
113
- let blocker = promise.delayed(100).then(() => {
114
- assert.deepEqual([1], values);
115
- return 2;
116
- });
117
-
118
- return promise.consume(function* () {
119
- values.push(1);
120
- values.push(yield blocker, 3);
121
- }).then(function() {
122
- assert.deepEqual([1, 2, 3], values);
123
- });
124
- });
125
-
126
- it('accepts custom scopes', function() {
127
- return promise.consume(function* () {
128
- return this.name;
129
- }, {name: 'Bob'}).then(function(value) {
130
- assert.equal('Bob', value);
131
- });
132
- });
133
-
134
- it('accepts initial generator arguments', function() {
135
- return promise.consume(function* (a, b) {
136
- assert.equal('red', a);
137
- assert.equal('apples', b);
138
- }, null, 'red', 'apples');
139
- });
140
- });
141
-
142
- enablePromiseManager(() => {
143
- it('is possible to cancel promise generators', function() {
144
- var values = [];
145
- var p = promise.consume(function* () {
146
- var i = 0;
147
- while (i < 3) {
148
- yield promise.delayed(100).then(function() {
149
- values.push(i++);
150
- });
151
- }
152
- });
153
- return promise.delayed(75).then(function() {
154
- p.cancel();
155
- return p.catch(function() {
156
- return promise.delayed(300);
157
- });
158
- }).then(function() {
159
- assert.deepEqual([0], values);
160
- });
161
- });
162
-
163
- it('executes generator within the control flow', function() {
164
- var promises = [
165
- promise.defer(),
166
- promise.defer()
167
- ];
168
- var values = [];
169
-
170
- setTimeout(function() {
171
- assert.deepEqual([], values);
172
- promises[0].fulfill(1);
173
- }, 100);
174
-
175
- setTimeout(function() {
176
- assert.deepEqual([1], values);
177
- promises[1].fulfill(2);
178
- }, 200);
179
-
180
- return promise.controlFlow().execute(function* () {
181
- values.push(yield promises[0].promise);
182
- values.push(yield promises[1].promise);
183
- values.push('fin');
184
- }).then(function() {
185
- assert.deepEqual([1, 2, 'fin'], values);
186
- });
187
- });
188
-
189
- it('handles tasks scheduled in generator', function() {
190
- var flow = promise.controlFlow();
191
- return flow.execute(function* () {
192
- var x = yield flow.execute(function() {
193
- return promise.delayed(10).then(function() {
194
- return 1;
195
- });
196
- });
197
-
198
- var y = yield flow.execute(function() {
199
- return 2;
200
- });
201
-
202
- return x + y;
203
- }).then(function(value) {
204
- assert.equal(3, value);
205
- });
206
- });
207
-
208
- it('blocks the control flow while processing generator', function() {
209
- var values = [];
210
- return promise.controlFlow().wait(function* () {
211
- yield values.push(1);
212
- values.push(yield promise.delayed(10).then(function() {
213
- return 2;
214
- }));
215
- yield values.push(3);
216
- return values.length === 6;
217
- }, 250).then(function() {
218
- assert.deepEqual([1, 2, 3, 1, 2, 3], values);
219
- });
220
- });
221
-
222
- it('ControlFlow.wait() will timeout on long generator', function() {
223
- var values = [];
224
- return promise.controlFlow().wait(function* () {
225
- var i = 0;
226
- while (i < 3) {
227
- yield promise.delayed(100).then(function() {
228
- values.push(i++);
229
- });
230
- }
231
- }, 75).catch(function() {
232
- assert.deepEqual(
233
- [0, 1, 2], values, 'Should complete one loop of wait condition');
234
- });
235
- });
236
-
237
- describe('generators in promise callbacks', function() {
238
- it('works with no initial value', function() {
239
- var promises = [
240
- promise.defer(),
241
- promise.defer()
242
- ];
243
- var values = [];
244
-
245
- setTimeout(function() {
246
- promises[0].fulfill(1);
247
- }, 50);
248
-
249
- setTimeout(function() {
250
- promises[1].fulfill(2);
251
- }, 100);
252
-
253
- return promise.fulfilled().then(function*() {
254
- values.push(yield promises[0].promise);
255
- values.push(yield promises[1].promise);
256
- values.push('fin');
257
- }).then(function() {
258
- assert.deepEqual([1, 2, 'fin'], values);
259
- });
260
- });
261
-
262
- it('starts the generator with promised value', function() {
263
- var promises = [
264
- promise.defer(),
265
- promise.defer()
266
- ];
267
- var values = [];
268
-
269
- setTimeout(function() {
270
- promises[0].fulfill(1);
271
- }, 50);
272
-
273
- setTimeout(function() {
274
- promises[1].fulfill(2);
275
- }, 100);
276
-
277
- return promise.fulfilled(3).then(function*(value) {
278
- var p1 = yield promises[0].promise;
279
- var p2 = yield promises[1].promise;
280
- values.push(value + p1);
281
- values.push(value + p2);
282
- values.push('fin');
283
- }).then(function() {
284
- assert.deepEqual([4, 5, 'fin'], values);
285
- });
286
- });
287
-
288
- it('throws yielded rejections within the generator callback', function() {
289
- var d = promise.defer();
290
- var e = Error('stub');
291
-
292
- setTimeout(function() {
293
- d.reject(e);
294
- }, 50);
295
-
296
- return promise.fulfilled().then(function*() {
297
- var threw = false;
298
- try {
299
- yield d.promise;
300
- } catch (ex) {
301
- threw = true;
302
- assert.equal(e, ex);
303
- }
304
- assert.ok(threw);
305
- });
306
- });
307
- });
308
- });
309
- });
310
-
@@ -1,59 +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
- 'use strict';
19
-
20
- var assert = require('assert');
21
- var path = require('path');
22
- var test = require('../../lib/test');
23
-
24
- test.suite(function(env) {
25
- var driver;
26
-
27
- test.before(function*() {
28
- driver = yield env.builder().build();
29
- });
30
-
31
- test.after(function() {
32
- return driver.quit();
33
- });
34
-
35
- var testPageUrl =
36
- 'data:text/html,<html><h1>' + path.basename(__filename) + '</h1></html>';
37
-
38
- test.beforeEach(function() {
39
- return driver.get(testPageUrl);
40
- });
41
-
42
- describe('phantomjs.Driver', function() {
43
- describe('#executePhantomJS()', function() {
44
-
45
- test.it('can execute scripts using PhantomJS API', function*() {
46
- let url = yield driver.executePhantomJS('return this.url;');
47
- assert.equal(testPageUrl, decodeURIComponent(url));
48
- });
49
-
50
- test.it('can execute scripts as functions', function*() {
51
- let result = yield driver.executePhantomJS(function(a, b) {
52
- return a + b;
53
- }, 1, 2);
54
-
55
- assert.equal(3, result);
56
- });
57
- });
58
- });
59
- }, {browsers: ['phantomjs']});