selenium-webdriver 4.0.0-alpha.3 → 4.0.0-alpha.7

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 (79) hide show
  1. package/CHANGES.md +9 -2
  2. package/README.md +2 -4
  3. package/chrome.js +19 -527
  4. package/chromium.js +762 -0
  5. package/edge.js +97 -58
  6. package/firefox.js +23 -5
  7. package/http/index.js +4 -0
  8. package/io/index.js +1 -1
  9. package/lib/actions.js +1 -1
  10. package/lib/atoms/get-attribute.js +1 -2
  11. package/lib/atoms/is-displayed.js +5 -6
  12. package/lib/atoms/make-atoms-module.js +17 -0
  13. package/lib/capabilities.js +17 -4
  14. package/lib/command.js +1 -0
  15. package/lib/http.js +8 -3
  16. package/lib/input.js +6 -6
  17. package/lib/logging.js +1 -1
  18. package/lib/webdriver.js +33 -3
  19. package/net/portprober.js +1 -1
  20. package/package.json +8 -9
  21. package/BUILD.bazel +0 -88
  22. package/example/chrome_android.js +0 -42
  23. package/example/chrome_mobile_emulation.js +0 -42
  24. package/example/firefox_channels.js +0 -77
  25. package/example/google_search.js +0 -50
  26. package/example/google_search_test.js +0 -72
  27. package/example/headless.js +0 -55
  28. package/example/logging.js +0 -68
  29. package/jasmine.json +0 -11
  30. package/lib/atoms/BUILD.bazel +0 -28
  31. package/lib/test/bootstrap_jasmine.js +0 -28
  32. package/lib/test/build.js +0 -156
  33. package/lib/test/data/actions/click.html +0 -24
  34. package/lib/test/data/actions/drag.html +0 -77
  35. package/lib/test/data/actions/record_click.html +0 -21
  36. package/lib/test/data/chrome/download.html +0 -2
  37. package/lib/test/data/firefox/webextension.xpi +0 -0
  38. package/lib/test/fileserver.js +0 -337
  39. package/lib/test/httpserver.js +0 -120
  40. package/lib/test/index.js +0 -87
  41. package/lib/test/resources.js +0 -40
  42. package/test/actions_test.js +0 -206
  43. package/test/builder_test.js +0 -106
  44. package/test/chrome/devtools_test.js +0 -93
  45. package/test/chrome/options_test.js +0 -121
  46. package/test/chrome/service_test.js +0 -45
  47. package/test/cookie_test.js +0 -210
  48. package/test/element_finding_test.js +0 -431
  49. package/test/execute_script_test.js +0 -355
  50. package/test/fingerprint_test.js +0 -63
  51. package/test/firefox_test.js +0 -233
  52. package/test/frame_test.js +0 -45
  53. package/test/http/http_test.js +0 -229
  54. package/test/http/util_test.js +0 -178
  55. package/test/io/io_test.js +0 -364
  56. package/test/io/zip_test.js +0 -126
  57. package/test/lib/by_test.js +0 -160
  58. package/test/lib/capabilities_test.js +0 -129
  59. package/test/lib/error_test.js +0 -333
  60. package/test/lib/http_test.js +0 -576
  61. package/test/lib/input_test.js +0 -1379
  62. package/test/lib/logging_test.js +0 -272
  63. package/test/lib/promise_test.js +0 -674
  64. package/test/lib/testutil.js +0 -90
  65. package/test/lib/until_test.js +0 -478
  66. package/test/lib/webdriver_test.js +0 -1692
  67. package/test/logging_test.js +0 -160
  68. package/test/net/index_test.js +0 -60
  69. package/test/net/portprober_test.js +0 -128
  70. package/test/page_loading_test.js +0 -156
  71. package/test/proxy_test.js +0 -167
  72. package/test/rect_test.js +0 -51
  73. package/test/remote_test.js +0 -98
  74. package/test/safari_test.js +0 -44
  75. package/test/stale_element_test.js +0 -60
  76. package/test/upload_test.js +0 -78
  77. package/test/window_test.js +0 -168
  78. package/testing/index.js +0 -498
  79. package/tools/init_jasmine.js +0 -7
@@ -1,129 +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 Capabilities = require('../../lib/capabilities').Capabilities;
21
- const Symbols = require('../../lib/symbols');
22
-
23
- const assert = require('assert');
24
-
25
- describe('Capabilities', function() {
26
- it('can set and unset a capability', function() {
27
- let caps = new Capabilities();
28
- assert.equal(undefined, caps.get('foo'));
29
- assert.ok(!caps.has('foo'));
30
-
31
- caps.set('foo', 'bar');
32
- assert.equal('bar', caps.get('foo'));
33
- assert.ok(caps.has('foo'));
34
-
35
- caps.set('foo', null);
36
- assert.equal(null, caps.get('foo'));
37
- assert.ok(caps.has('foo'));
38
- });
39
-
40
- it('requires string capability keys', function() {
41
- let caps = new Capabilities();
42
- assert.throws(() => caps.set({}, 'hi'));
43
- });
44
-
45
- it('can merge capabilities', function() {
46
- const caps1 = new Capabilities()
47
- .set('foo', 'bar')
48
- .set('color', 'red');
49
-
50
- const caps2 = new Capabilities()
51
- .set('color', 'green');
52
-
53
- assert.equal('bar', caps1.get('foo'));
54
- assert.equal('red', caps1.get('color'));
55
- assert.equal('green', caps2.get('color'));
56
- assert.equal(undefined, caps2.get('foo'));
57
-
58
- caps2.merge(caps1);
59
- assert.equal('bar', caps1.get('foo'));
60
- assert.equal('red', caps1.get('color'));
61
- assert.equal('red', caps2.get('color'));
62
- assert.equal('bar', caps2.get('foo'));
63
-
64
- const caps3 = new Map()
65
- .set('color', 'blue');
66
-
67
- caps2.merge(caps3);
68
- assert.equal('blue', caps2.get('color'));
69
- assert.equal('bar', caps2.get('foo'));
70
-
71
- const caps4 = {foo: 'baz'};
72
-
73
- const caps5 = caps2.merge(caps4);
74
-
75
- assert.equal('blue', caps2.get('color'));
76
- assert.equal('baz', caps2.get('foo'));
77
- assert.equal('blue', caps5.get('color'));
78
- assert.equal('baz', caps5.get('foo'));
79
- assert.equal(true, caps5 instanceof Capabilities);
80
- assert.equal(caps2, caps5);
81
- });
82
-
83
- it('can be initialized from a hash object', function() {
84
- let caps = new Capabilities({'one': 123, 'abc': 'def'});
85
- assert.equal(123, caps.get('one'));
86
- assert.equal('def', caps.get('abc'));
87
- });
88
-
89
- it('can be initialized from a map', function() {
90
- let m = new Map([['one', 123], ['abc', 'def']]);
91
-
92
- let caps = new Capabilities(m);
93
- assert.equal(123, caps.get('one'));
94
- assert.equal('def', caps.get('abc'));
95
- });
96
-
97
- describe('serialize', function() {
98
- it('works for simple capabilities', function() {
99
- let m = new Map([['one', 123], ['abc', 'def']]);
100
- let caps = new Capabilities(m);
101
- assert.deepEqual({one: 123, abc: 'def'}, caps[Symbols.serialize]());
102
- });
103
-
104
- it('does not omit capabilities set to a false-like value', function() {
105
- let caps = new Capabilities;
106
- caps.set('bool', false);
107
- caps.set('number', 0);
108
- caps.set('string', '');
109
-
110
- assert.deepEqual(
111
- {bool: false, number: 0, string: ''},
112
- caps[Symbols.serialize]());
113
- });
114
-
115
- it('omits capabilities with a null value', function() {
116
- let caps = new Capabilities;
117
- caps.set('foo', null);
118
- caps.set('bar', 123);
119
- assert.deepEqual({bar: 123}, caps[Symbols.serialize]());
120
- });
121
-
122
- it('omits capabilities with an undefined value', function() {
123
- let caps = new Capabilities;
124
- caps.set('foo', undefined);
125
- caps.set('bar', 123);
126
- assert.deepEqual({bar: 123}, caps[Symbols.serialize]());
127
- });
128
- });
129
- });
@@ -1,333 +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
- describe('error', function() {
21
- let assert = require('assert');
22
- let error = require('../../lib/error');
23
-
24
- describe('checkResponse', function() {
25
- it('defaults to WebDriverError if type is unrecognized', function() {
26
- assert.throws(
27
- () => error.checkResponse({error: 'foo', message: 'hi there'}),
28
- (e) => {
29
- assert.equal(e.constructor, error.WebDriverError);
30
- return true;
31
- });
32
- });
33
-
34
- it('does not throw if error property is not a string', function() {
35
- let resp = {error: 123, message: 'abc123'};
36
- let out = error.checkResponse(resp);
37
- assert.strictEqual(out, resp);
38
- });
39
-
40
- test('unknown error', error.WebDriverError);
41
- test('element not interactable', error.ElementNotInteractableError);
42
- test('element not selectable', error.ElementNotSelectableError);
43
- test('insecure certificate', error.InsecureCertificateError);
44
- test('invalid argument', error.InvalidArgumentError);
45
- test('invalid cookie domain', error.InvalidCookieDomainError);
46
- test('invalid coordinates', error.InvalidCoordinatesError);
47
- test('invalid element state', error.InvalidElementStateError);
48
- test('invalid selector', error.InvalidSelectorError);
49
- test('invalid session id', error.NoSuchSessionError);
50
- test('javascript error', error.JavascriptError);
51
- test('move target out of bounds', error.MoveTargetOutOfBoundsError);
52
- test('no such alert', error.NoSuchAlertError);
53
- test('no such cookie', error.NoSuchCookieError);
54
- test('no such element', error.NoSuchElementError);
55
- test('no such frame', error.NoSuchFrameError);
56
- test('no such window', error.NoSuchWindowError);
57
- test('script timeout', error.ScriptTimeoutError);
58
- test('session not created', error.SessionNotCreatedError);
59
- test('stale element reference', error.StaleElementReferenceError);
60
- test('timeout', error.TimeoutError);
61
- test('unable to set cookie', error.UnableToSetCookieError);
62
- test('unable to capture screen', error.UnableToCaptureScreenError);
63
- test('unexpected alert open', error.UnexpectedAlertOpenError);
64
- test('unknown command', error.UnknownCommandError);
65
- test('unknown method', error.UnknownMethodError);
66
- test('unsupported operation', error.UnsupportedOperationError);
67
-
68
- function test(status, expectedType) {
69
- it(`"${status}" => ${expectedType.name}`, function() {
70
- assert.throws(
71
- () => error.checkResponse({error: status, message: 'oops'}),
72
- (e) => {
73
- assert.equal(expectedType, e.constructor);
74
- assert.equal(e.message, 'oops');
75
- return true;
76
- });
77
- });
78
- }
79
- });
80
-
81
- describe('encodeError', function() {
82
- describe('defaults to an unknown error', function() {
83
- it('for a generic error value', function() {
84
- runTest('hi', 'unknown error', 'hi');
85
- runTest(1, 'unknown error', '1');
86
- runTest({}, 'unknown error', '[object Object]');
87
- });
88
-
89
- it('for a generic Error object', function() {
90
- runTest(Error('oops'), 'unknown error', 'oops');
91
- runTest(TypeError('bad value'), 'unknown error', 'bad value');
92
- });
93
- });
94
-
95
- test(error.WebDriverError, 'unknown error');
96
- test(error.ElementClickInterceptedError, 'element click intercepted');
97
- test(error.ElementNotSelectableError, 'element not selectable');
98
- test(error.InsecureCertificateError, 'insecure certificate');
99
- test(error.InvalidArgumentError, 'invalid argument');
100
- test(error.InvalidCookieDomainError, 'invalid cookie domain');
101
- test(error.InvalidElementStateError, 'invalid element state');
102
- test(error.InvalidSelectorError, 'invalid selector');
103
- test(error.NoSuchSessionError, 'invalid session id');
104
- test(error.JavascriptError, 'javascript error');
105
- test(error.MoveTargetOutOfBoundsError, 'move target out of bounds');
106
- test(error.NoSuchAlertError, 'no such alert');
107
- test(error.NoSuchCookieError, 'no such cookie');
108
- test(error.NoSuchElementError, 'no such element');
109
- test(error.NoSuchFrameError, 'no such frame');
110
- test(error.NoSuchWindowError, 'no such window');
111
- test(error.ScriptTimeoutError, 'script timeout');
112
- test(error.SessionNotCreatedError, 'session not created');
113
- test(error.StaleElementReferenceError, 'stale element reference');
114
- test(error.TimeoutError, 'timeout');
115
- test(error.UnableToSetCookieError, 'unable to set cookie');
116
- test(error.UnableToCaptureScreenError, 'unable to capture screen');
117
- test(error.UnexpectedAlertOpenError, 'unexpected alert open');
118
- test(error.UnknownCommandError, 'unknown command');
119
- test(error.UnknownMethodError, 'unknown method');
120
- test(error.UnsupportedOperationError, 'unsupported operation');
121
-
122
- function test(ctor, code) {
123
- it(`${ctor.name} => "${code}"`, () => {
124
- runTest(new ctor('oops'), code, 'oops');
125
- });
126
- }
127
-
128
- function runTest(err, code, message) {
129
- let obj = error.encodeError(err);
130
- assert.strictEqual(obj['error'], code);
131
- assert.strictEqual(obj['message'], message);
132
- }
133
- });
134
-
135
- describe('throwDecodedError', function() {
136
- it('defaults to WebDriverError if type is unrecognized', function() {
137
- assert.throws(
138
- () => error.throwDecodedError({error: 'foo', message: 'hi there'}),
139
- (e) => {
140
- assert.equal(e.constructor, error.WebDriverError);
141
- return true;
142
- });
143
- });
144
-
145
- it('throws generic error if encoded data is not valid', function() {
146
- assert.throws(
147
- () => error.throwDecodedError({error: 123, message: 'abc123'}),
148
- (e) => {
149
- assert.strictEqual(e.constructor, error.WebDriverError);
150
- return true;
151
- });
152
-
153
- assert.throws(
154
- () => error.throwDecodedError('null'),
155
- (e) => {
156
- assert.strictEqual(e.constructor, error.WebDriverError);
157
- return true;
158
- });
159
-
160
- assert.throws(
161
- () => error.throwDecodedError(''),
162
- (e) => {
163
- assert.strictEqual(e.constructor, error.WebDriverError);
164
- return true;
165
- });
166
- });
167
-
168
- test('unknown error', error.WebDriverError);
169
- test('element click intercepted', error.ElementClickInterceptedError);
170
- test('element not selectable', error.ElementNotSelectableError);
171
- test('insecure certificate', error.InsecureCertificateError);
172
- test('invalid argument', error.InvalidArgumentError);
173
- test('invalid cookie domain', error.InvalidCookieDomainError);
174
- test('invalid coordinates', error.InvalidCoordinatesError);
175
- test('invalid element state', error.InvalidElementStateError);
176
- test('invalid selector', error.InvalidSelectorError);
177
- test('invalid session id', error.NoSuchSessionError);
178
- test('javascript error', error.JavascriptError);
179
- test('move target out of bounds', error.MoveTargetOutOfBoundsError);
180
- test('no such alert', error.NoSuchAlertError);
181
- test('no such cookie', error.NoSuchCookieError);
182
- test('no such element', error.NoSuchElementError);
183
- test('no such frame', error.NoSuchFrameError);
184
- test('no such window', error.NoSuchWindowError);
185
- test('script timeout', error.ScriptTimeoutError);
186
- test('session not created', error.SessionNotCreatedError);
187
- test('stale element reference', error.StaleElementReferenceError);
188
- test('timeout', error.TimeoutError);
189
- test('unable to set cookie', error.UnableToSetCookieError);
190
- test('unable to capture screen', error.UnableToCaptureScreenError);
191
- test('unexpected alert open', error.UnexpectedAlertOpenError);
192
- test('unknown command', error.UnknownCommandError);
193
- test('unknown method', error.UnknownMethodError);
194
- test('unsupported operation', error.UnsupportedOperationError);
195
-
196
- it('leaves remoteStacktrace empty if not in encoding', function() {
197
- assert.throws(
198
- () => error.throwDecodedError({
199
- error: 'session not created',
200
- message: 'oops'
201
- }),
202
- (e) => {
203
- assert.strictEqual(e.constructor, error.SessionNotCreatedError);
204
- assert.strictEqual(e.message, 'oops');
205
- assert.strictEqual(e.remoteStacktrace, '');
206
- return true;
207
- });
208
- });
209
-
210
- function test(status, expectedType) {
211
- it(`"${status}" => ${expectedType.name}`, function() {
212
- assert.throws(
213
- () => error.throwDecodedError({
214
- error: status,
215
- message: 'oops',
216
- stacktrace: 'some-stacktrace'
217
- }),
218
- (e) => {
219
- assert.strictEqual(e.constructor, expectedType);
220
- assert.strictEqual(e.message, 'oops');
221
- assert.strictEqual(e.remoteStacktrace, 'some-stacktrace');
222
- return true;
223
- });
224
- });
225
- }
226
-
227
- describe('remote stack trace decoding', function() {
228
- test('stacktrace');
229
- test('stackTrace');
230
-
231
- function test(key) {
232
- it(`encoded as "${key}"`, function() {
233
- let data = {error: 'unknown command', message: 'oops'};
234
- data[key] = 'some-stacktrace';
235
- assert.throws(
236
- () => error.throwDecodedError(data),
237
- (e) => {
238
- assert.strictEqual(e.remoteStacktrace, 'some-stacktrace');
239
- return true;
240
- });
241
- });
242
- }
243
- });
244
- });
245
-
246
- describe('checkLegacyResponse', function() {
247
- it('does not throw for success', function() {
248
- let resp = {status: error.ErrorCode.SUCCESS};
249
- assert.strictEqual(resp, error.checkLegacyResponse(resp));
250
- });
251
-
252
- test('NO_SUCH_SESSION', error.NoSuchSessionError);
253
- test('NO_SUCH_ELEMENT', error.NoSuchElementError);
254
- test('NO_SUCH_FRAME', error.NoSuchFrameError);
255
- test('UNKNOWN_COMMAND', error.UnsupportedOperationError);
256
- test('UNSUPPORTED_OPERATION', error.UnsupportedOperationError);
257
- test('STALE_ELEMENT_REFERENCE', error.StaleElementReferenceError);
258
- test('INVALID_ELEMENT_STATE', error.InvalidElementStateError);
259
- test('UNKNOWN_ERROR', error.WebDriverError);
260
- test('ELEMENT_NOT_SELECTABLE', error.ElementNotSelectableError);
261
- test('JAVASCRIPT_ERROR', error.JavascriptError);
262
- test('XPATH_LOOKUP_ERROR', error.InvalidSelectorError);
263
- test('TIMEOUT', error.TimeoutError);
264
- test('NO_SUCH_WINDOW', error.NoSuchWindowError);
265
- test('INVALID_COOKIE_DOMAIN', error.InvalidCookieDomainError);
266
- test('UNABLE_TO_SET_COOKIE', error.UnableToSetCookieError);
267
- test('UNEXPECTED_ALERT_OPEN', error.UnexpectedAlertOpenError);
268
- test('NO_SUCH_ALERT', error.NoSuchAlertError);
269
- test('SCRIPT_TIMEOUT', error.ScriptTimeoutError);
270
- test('INVALID_ELEMENT_COORDINATES', error.InvalidCoordinatesError);
271
- test('INVALID_SELECTOR_ERROR', error.InvalidSelectorError);
272
- test('SESSION_NOT_CREATED', error.SessionNotCreatedError);
273
- test('MOVE_TARGET_OUT_OF_BOUNDS', error.MoveTargetOutOfBoundsError);
274
- test('INVALID_XPATH_SELECTOR', error.InvalidSelectorError);
275
- test('INVALID_XPATH_SELECTOR_RETURN_TYPE', error.InvalidSelectorError);
276
- test('ELEMENT_NOT_INTERACTABLE', error.ElementNotInteractableError);
277
- test('INVALID_ARGUMENT', error.InvalidArgumentError);
278
- test('UNABLE_TO_CAPTURE_SCREEN', error.UnableToCaptureScreenError);
279
- test('ELEMENT_CLICK_INTERCEPTED', error.ElementClickInterceptedError);
280
- test('METHOD_NOT_ALLOWED', error.UnsupportedOperationError);
281
-
282
- describe('UnexpectedAlertOpenError', function() {
283
- it('includes alert text from the response object', function() {
284
- let response = {
285
- status: error.ErrorCode.UNEXPECTED_ALERT_OPEN,
286
- value: {
287
- message: 'hi',
288
- alert: {text: 'alert text here'}
289
- }
290
- };
291
- assert.throws(
292
- () => error.checkLegacyResponse(response),
293
- (e) => {
294
- assert.equal(error.UnexpectedAlertOpenError, e.constructor);
295
- assert.equal(e.message, 'hi');
296
- assert.equal(e.getAlertText(), 'alert text here');
297
- return true;
298
- });
299
- });
300
-
301
- it('uses an empty string if alert text omitted', function() {
302
- let response = {
303
- status: error.ErrorCode.UNEXPECTED_ALERT_OPEN,
304
- value: {
305
- message: 'hi'
306
- }
307
- };
308
- assert.throws(
309
- () => error.checkLegacyResponse(response),
310
- (e) => {
311
- assert.equal(error.UnexpectedAlertOpenError, e.constructor);
312
- assert.equal(e.message, 'hi');
313
- assert.equal(e.getAlertText(), '');
314
- return true;
315
- });
316
- });
317
- });
318
-
319
- function test(codeKey, expectedType) {
320
- it(`${codeKey} => ${expectedType.name}`, function() {
321
- let code = error.ErrorCode[codeKey];
322
- let resp = {status: code, value: {message: 'hi'}};
323
- assert.throws(
324
- () => error.checkLegacyResponse(resp),
325
- (e) => {
326
- assert.equal(expectedType, e.constructor);
327
- assert.equal(e.message, 'hi');
328
- return true;
329
- });
330
- });
331
- }
332
- });
333
- });