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,185 +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 AdmZip = require('adm-zip'),
21
- assert = require('assert'),
22
- fs = require('fs'),
23
- path = require('path');
24
-
25
- var promise = require('../..').promise,
26
- Profile = require('../../firefox/profile').Profile,
27
- decode = require('../../firefox/profile').decode,
28
- loadUserPrefs = require('../../firefox/profile').loadUserPrefs,
29
- io = require('../../io');
30
-
31
-
32
- var JETPACK_EXTENSION = path.join(__dirname,
33
- '../../lib/test/data/firefox/jetpack-sample.xpi');
34
- var NORMAL_EXTENSION = path.join(__dirname,
35
- '../../lib/test/data/firefox/sample.xpi');
36
-
37
- var JETPACK_EXTENSION_ID = 'jid1-EaXX7k0wwiZR7w@jetpack.xpi';
38
- var NORMAL_EXTENSION_ID = 'sample@seleniumhq.org';
39
- var WEBDRIVER_EXTENSION_ID = 'fxdriver@googlecode.com';
40
-
41
-
42
-
43
- describe('Profile', function() {
44
- describe('setPreference', function() {
45
- it('allows setting custom properties', function() {
46
- var profile = new Profile();
47
- assert.equal(undefined, profile.getPreference('foo'));
48
-
49
- profile.setPreference('foo', 'bar');
50
- assert.equal('bar', profile.getPreference('foo'));
51
- });
52
-
53
- it('allows overriding mutable properties', function() {
54
- var profile = new Profile();
55
-
56
- profile.setPreference('browser.newtab.url', 'http://www.example.com');
57
- assert.equal('http://www.example.com',
58
- profile.getPreference('browser.newtab.url'));
59
- });
60
-
61
- it('throws if setting a frozen preference', function() {
62
- var profile = new Profile();
63
- assert.throws(function() {
64
- profile.setPreference('app.update.auto', true);
65
- });
66
- });
67
- });
68
-
69
- describe('writeToDisk', function() {
70
- it('copies template directory recursively', function() {
71
- var templateDir;
72
- return io.tmpDir().then(function(td) {
73
- templateDir = td;
74
- var foo = path.join(templateDir, 'foo');
75
- fs.writeFileSync(foo, 'Hello, world');
76
-
77
- var bar = path.join(templateDir, 'subfolder/bar');
78
- fs.mkdirSync(path.dirname(bar));
79
- fs.writeFileSync(bar, 'Goodbye, world!');
80
-
81
- return new Profile(templateDir).writeToDisk();
82
- }).then(function(profileDir) {
83
- assert.notEqual(profileDir, templateDir);
84
-
85
- assert.equal('Hello, world',
86
- fs.readFileSync(path.join(profileDir, 'foo')));
87
- assert.equal('Goodbye, world!',
88
- fs.readFileSync(path.join(profileDir, 'subfolder/bar')));
89
- });
90
- });
91
-
92
- it('does not copy lock files', function() {
93
- return io.tmpDir().then(function(dir) {
94
- fs.writeFileSync(path.join(dir, 'parent.lock'), 'lock');
95
- fs.writeFileSync(path.join(dir, 'lock'), 'lock');
96
- fs.writeFileSync(path.join(dir, '.parentlock'), 'lock');
97
- return new Profile(dir).writeToDisk();
98
- }).then(function(dir) {
99
- assert.ok(fs.existsSync(dir));
100
- assert.ok(!fs.existsSync(path.join(dir, 'parent.lock')));
101
- assert.ok(!fs.existsSync(path.join(dir, 'lock')));
102
- assert.ok(!fs.existsSync(path.join(dir, '.parentlock')));
103
- });
104
- });
105
-
106
- describe('user.js', function() {
107
-
108
- it('writes defaults', function() {
109
- return new Profile().writeToDisk().then(function(dir) {
110
- return loadUserPrefs(path.join(dir, 'user.js'));
111
- }).then(function(prefs) {
112
- // Just check a few.
113
- assert.equal(false, prefs['app.update.auto']);
114
- assert.equal(true, prefs['browser.EULA.override']);
115
- assert.equal(false, prefs['extensions.update.enabled']);
116
- assert.equal('about:blank', prefs['browser.newtab.url']);
117
- assert.equal(30, prefs['dom.max_script_run_time']);
118
- });
119
- });
120
-
121
- it('merges template user.js into preferences', function() {
122
- return io.tmpDir().then(function(dir) {
123
- fs.writeFileSync(path.join(dir, 'user.js'), [
124
- 'user_pref("browser.newtab.url", "http://www.example.com")',
125
- 'user_pref("dom.max_script_run_time", 1234)'
126
- ].join('\n'));
127
-
128
- return new Profile(dir).writeToDisk();
129
- }).then(function(profile) {
130
- return loadUserPrefs(path.join(profile, 'user.js'));
131
- }).then(function(prefs) {
132
- assert.equal('http://www.example.com', prefs['browser.newtab.url']);
133
- assert.equal(1234, prefs['dom.max_script_run_time']);
134
- });
135
- });
136
-
137
- it('ignores frozen preferences when merging template user.js',
138
- function() {
139
- return io.tmpDir().then(function(dir) {
140
- fs.writeFileSync(path.join(dir, 'user.js'),
141
- 'user_pref("app.update.auto", true)');
142
- return new Profile(dir).writeToDisk();
143
- }).then(function(profile) {
144
- return loadUserPrefs(path.join(profile, 'user.js'));
145
- }).then(function(prefs) {
146
- assert.equal(false, prefs['app.update.auto']);
147
- });
148
- });
149
- });
150
-
151
- describe('extensions', function() {
152
- it('are copied into new profile directory', function() {
153
- var profile = new Profile();
154
- profile.addExtension(JETPACK_EXTENSION);
155
- profile.addExtension(NORMAL_EXTENSION);
156
-
157
- return profile.writeToDisk().then(function(dir) {
158
- dir = path.join(dir, 'extensions');
159
- assert.ok(fs.existsSync(path.join(dir, JETPACK_EXTENSION_ID)));
160
- assert.ok(fs.existsSync(path.join(dir, NORMAL_EXTENSION_ID)));
161
- assert.ok(fs.existsSync(path.join(dir, WEBDRIVER_EXTENSION_ID)));
162
- });
163
- });
164
- });
165
- });
166
-
167
- describe('encode', function() {
168
- it('excludes the bundled WebDriver extension', function() {
169
- return new Profile().encode().then(function(data) {
170
- return decode(data);
171
- }).then(function(dir) {
172
- assert.ok(fs.existsSync(path.join(dir, 'user.js')));
173
- assert.ok(fs.existsSync(path.join(dir, 'extensions')));
174
- return loadUserPrefs(path.join(dir, 'user.js'));
175
- }).then(function(prefs) {
176
- // Just check a few.
177
- assert.equal(false, prefs['app.update.auto']);
178
- assert.equal(true, prefs['browser.EULA.override']);
179
- assert.equal(false, prefs['extensions.update.enabled']);
180
- assert.equal('about:blank', prefs['browser.newtab.url']);
181
- assert.equal(30, prefs['dom.max_script_run_time']);
182
- });
183
- });
184
- });
185
- });
@@ -1,177 +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 EventEmitter = require('../../lib/events').EventEmitter;
21
-
22
- const assert = require('assert');
23
- const sinon = require('sinon');
24
-
25
- describe('EventEmitter', function() {
26
- describe('#emit()', function() {
27
- it('can emit events when nothing is registered', function() {
28
- let emitter = new EventEmitter;
29
- emitter.emit('foo');
30
- // Ok if no errors are thrown.
31
- });
32
-
33
- it('can pass args to listeners on emit', function() {
34
- let emitter = new EventEmitter;
35
- let now = Date.now();
36
-
37
- let messages = [];
38
- emitter.on('foo', (arg) => messages.push(arg));
39
-
40
- emitter.emit('foo', now);
41
- assert.deepEqual([now], messages);
42
-
43
- emitter.emit('foo', now + 15);
44
- assert.deepEqual([now, now + 15], messages);
45
- });
46
- });
47
-
48
- describe('#addListener()', function() {
49
- it('can add multiple listeners for one event', function() {
50
- let emitter = new EventEmitter;
51
- let count = 0;
52
- emitter.addListener('foo', () => count++);
53
- emitter.addListener('foo', () => count++);
54
- emitter.addListener('foo', () => count++);
55
- emitter.emit('foo');
56
- assert.equal(3, count);
57
- });
58
-
59
- it('only registers each listener function once', function() {
60
- let emitter = new EventEmitter;
61
- let count = 0;
62
- let onFoo = () => count++;
63
- emitter.addListener('foo', onFoo);
64
- emitter.addListener('foo', onFoo);
65
- emitter.addListener('foo', onFoo);
66
-
67
- emitter.emit('foo');
68
- assert.equal(1, count);
69
-
70
- emitter.emit('foo');
71
- assert.equal(2, count);
72
- });
73
-
74
- it('allows users to specify a custom scope', function() {
75
- let obj = {
76
- count: 0,
77
- inc: function() {
78
- this.count++;
79
- }
80
- };
81
- let emitter = new EventEmitter;
82
- emitter.addListener('foo', obj.inc, obj);
83
-
84
- emitter.emit('foo');
85
- assert.equal(1, obj.count);
86
-
87
- emitter.emit('foo');
88
- assert.equal(2, obj.count);
89
- });
90
- });
91
-
92
- describe('#once()', function() {
93
- it('only calls registered callback once', function() {
94
- let emitter = new EventEmitter;
95
- let count = 0;
96
- emitter.once('foo', () => count++);
97
- emitter.once('foo', () => count++);
98
- emitter.once('foo', () => count++);
99
-
100
- emitter.emit('foo');
101
- assert.equal(3, count);
102
-
103
- emitter.emit('foo');
104
- assert.equal(3, count);
105
-
106
- emitter.emit('foo');
107
- assert.equal(3, count);
108
- });
109
- });
110
-
111
- describe('#removeListeners()', function() {
112
- it('only removes the given listener function', function() {
113
- let emitter = new EventEmitter;
114
- let count = 0;
115
- emitter.addListener('foo', () => count++);
116
- emitter.addListener('foo', () => count++);
117
-
118
- let toRemove = () => count++;
119
- emitter.addListener('foo', toRemove);
120
-
121
- emitter.emit('foo');
122
- assert.equal(3, count);
123
-
124
- emitter.removeListener('foo', toRemove);
125
- emitter.emit('foo');
126
- assert.equal(5, count);
127
- });
128
- });
129
-
130
- describe('#removeAllListeners()', function() {
131
- it('only removes listeners for type if specified', function() {
132
- let emitter = new EventEmitter;
133
- let count = 0;
134
- emitter.addListener('foo', () => count++);
135
- emitter.addListener('foo', () => count++);
136
- emitter.addListener('foo', () => count++);
137
- emitter.addListener('bar', () => count++);
138
-
139
- emitter.emit('foo');
140
- assert.equal(3, count);
141
-
142
- emitter.removeAllListeners('foo');
143
-
144
- emitter.emit('foo');
145
- assert.equal(3, count);
146
-
147
- emitter.emit('bar');
148
- assert.equal(4, count);
149
- });
150
-
151
- it('removes absolutely all listeners if no type specified', function() {
152
- let emitter = new EventEmitter;
153
- let count = 0;
154
- emitter.addListener('foo', () => count++);
155
- emitter.addListener('bar', () => count++);
156
- emitter.addListener('baz', () => count++);
157
- emitter.addListener('baz', () => count++);
158
-
159
- emitter.emit('foo');
160
- assert.equal(1, count);
161
-
162
- emitter.emit('baz');
163
- assert.equal(3, count);
164
-
165
- emitter.removeAllListeners();
166
-
167
- emitter.emit('foo');
168
- assert.equal(3, count);
169
-
170
- emitter.emit('bar');
171
- assert.equal(3, count);
172
-
173
- emitter.emit('baz');
174
- assert.equal(3, count);
175
- });
176
- });
177
- });
@@ -1,78 +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 promise = require('../../lib/promise');
21
- const {enablePromiseManager} = require('../../lib/test/promise');
22
-
23
- describe('Promises/A+ Compliance Tests', function() {
24
- enablePromiseManager(() => {
25
- // The promise spec does not define behavior for unhandled rejections and
26
- // assumes they are effectively swallowed. This is not the case with our
27
- // implementation, so we have to disable error propagation to test that the
28
- // rest of our behavior is compliant.
29
- // We run the tests with a separate instance of the control flow to ensure
30
- // disablign error propagation does not impact other tests.
31
- var flow = new promise.ControlFlow();
32
- flow.setPropagateUnhandledRejections(false);
33
-
34
- // Skip the tests in 2.2.6.1/2. We are not compliant in these scenarios.
35
- var realDescribe = global.describe;
36
- global.describe = function(name, fn) {
37
- realDescribe(name, function() {
38
- var prefix = 'Promises/A+ Compliance Tests '
39
- + 'SELENIUM_PROMISE_MANAGER=true 2.2.6: '
40
- + '`then` may be called multiple times on the same promise.';
41
- var suffix = 'even when one handler is added inside another handler';
42
- if (this.fullTitle().startsWith(prefix)
43
- && this.fullTitle().endsWith(suffix)) {
44
- var realSpecify = global.specify;
45
- try {
46
- global.specify = function(name) {
47
- realSpecify(name);
48
- };
49
- fn();
50
- } finally {
51
- global.specify = realSpecify;
52
- }
53
- } else {
54
- fn();
55
- }
56
- });
57
- };
58
-
59
- require('promises-aplus-tests').mocha({
60
- resolved: function(value) {
61
- return new promise.Promise((fulfill) => fulfill(value), flow);
62
- },
63
- rejected: function(error) {
64
- return new promise.Promise((_, reject) => reject(error), flow);
65
- },
66
- deferred: function() {
67
- var d = new promise.Deferred(flow);
68
- return {
69
- resolve: d.fulfill,
70
- reject: d.reject,
71
- promise: d.promise
72
- };
73
- }
74
- });
75
-
76
- global.describe = realDescribe;
77
- });
78
- });