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
@@ -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']});
@@ -1,54 +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 WebDriver = require('..').WebDriver,
21
- assert = require('../testing/assert'),
22
- test = require('../lib/test'),
23
- Pages = test.Pages;
24
-
25
-
26
- test.suite(function(env) {
27
- var browsers = env.browsers;
28
-
29
- var driver;
30
- test.before(function*() {
31
- driver = yield env.builder().build();
32
- });
33
-
34
- test.after(function() {
35
- return driver.quit();
36
- });
37
-
38
- test.it('can connect to an existing session', function*() {
39
- yield driver.get(Pages.simpleTestPage);
40
- yield assert(driver.getTitle()).equalTo('Hello WebDriver');
41
-
42
- return driver.getSession().then(session1 => {
43
- let driver2 = WebDriver.attachToSession(
44
- driver.getExecutor(),
45
- session1.getId());
46
-
47
- return assert(driver2.getTitle()).equalTo('Hello WebDriver')
48
- .then(_ => {
49
- let session2Id = driver2.getSession().then(s => s.getId());
50
- return assert(session2Id).equalTo(session1.getId());
51
- });
52
- });
53
- });
54
- });