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
package/.npmignore DELETED
@@ -1,2 +0,0 @@
1
- node_modules/
2
-
@@ -1,69 +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 Example Mocha tests using async/await.
20
- *
21
- * Usage:
22
- *
23
- * mocha -t 20000 --harmony_async_await \
24
- * selenium-webdriver/example/async_await_test.js
25
- *
26
- * You can change which browser is started with the SELENIUM_BROWSER environment
27
- * variable:
28
- *
29
- * SELENIUM_BROWSER=chrome \
30
- * mocha -t 20000 --harmony_async_await \
31
- * selenium-webdriver/example/async_await_test.js
32
- */
33
-
34
- 'use strict';
35
-
36
- const assert = require('assert');
37
- const {Builder, By, Key, promise, until} = require('..');
38
-
39
- // async/await do not work well when the promise manager is enabled.
40
- // See https://github.com/SeleniumHQ/selenium/issues/3037
41
- //
42
- // 3037 does not impact these specific examples, but it is still recommended
43
- // that you disable the promise manager when using async/await.
44
- promise.USE_PROMISE_MANAGER = false;
45
-
46
- describe('Google Search', function() {
47
- let driver;
48
-
49
- beforeEach(async function() {
50
- driver = await new Builder().forBrowser('firefox').build();
51
- });
52
-
53
- afterEach(async function() {
54
- await driver.quit();
55
- });
56
-
57
- it('example', async function() {
58
- await driver.get('https://www.google.com/ncr');
59
-
60
- await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
61
-
62
- await driver.wait(until.titleIs('webdriver - Google Search'), 1000);
63
-
64
- let url = await driver.getCurrentUrl();
65
- assert.ok(
66
- url.startsWith('https://www.google.com/search'),
67
- 'unexpected url: ' + url);
68
- });
69
- });
@@ -1,47 +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 An example WebDriver script using generator functions.
20
- *
21
- * Before running this script, ensure that Mozilla's geckodriver is present on
22
- * your system PATH: <https://github.com/mozilla/geckodriver/releases>
23
- *
24
- * Usage:
25
- *
26
- * node selenium-webdriver/example/google_search_generator.js
27
- */
28
-
29
- 'use strict';
30
-
31
- const {Builder, By, Key, promise, until} = require('..');
32
-
33
- promise.consume(function* () {
34
- let driver;
35
- try {
36
- driver = yield new Builder().forBrowser('firefox').build();
37
-
38
- yield driver.get('http://www.google.com/ncr');
39
-
40
- let q = yield driver.findElement(By.name('q'));
41
- yield q.sendKeys('webdriver', Key.RETURN);
42
-
43
- yield driver.wait(until.titleIs('webdriver - Google Search'), 1000);
44
- } finally {
45
- yield driver && driver.quit();
46
- }
47
- }).then(_ => console.log('SUCCESS'), err => console.error('ERROR: ' + err));
@@ -1,51 +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 An example of starting multiple WebDriver clients that run
20
- * in parallel in separate control flows.
21
- *
22
- * This example will only work when the promise manager is enabled
23
- * (see <https://github.com/SeleniumHQ/selenium/issues/2969>).
24
- */
25
-
26
- const {Builder, By, Key, promise, until} = require('..');
27
-
28
- for (var i = 0; i < 3; i++) {
29
- (function(n) {
30
- var flow = new promise.ControlFlow()
31
- .on('uncaughtException', function(e) {
32
- console.log('uncaughtException in flow %d: %s', n, e);
33
- });
34
-
35
- var driver = new Builder().
36
- forBrowser('firefox').
37
- setControlFlow(flow). // Comment out this line to see the difference.
38
- build();
39
-
40
- // Position and resize window so it's easy to see them running together.
41
- driver.manage().window().setSize(600, 400);
42
- driver.manage().window().setPosition(300 * i, 400 * i);
43
-
44
- driver.get('http://www.google.com');
45
- driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
46
- driver.wait(until.titleIs('webdriver - Google Search'), 1000);
47
-
48
- driver.quit();
49
- })(i);
50
- }
51
-
package/firefox/binary.js DELETED
@@ -1,347 +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 Manages Firefox binaries. This module is considered internal;
20
- * users should use {@link ./firefox selenium-webdriver/firefox}.
21
- */
22
-
23
- 'use strict';
24
-
25
- const child = require('child_process'),
26
- fs = require('fs'),
27
- path = require('path'),
28
- util = require('util');
29
-
30
- const isDevMode = require('../lib/devmode'),
31
- Symbols = require('../lib/symbols'),
32
- io = require('../io'),
33
- exec = require('../io/exec');
34
-
35
-
36
-
37
- /** @const */
38
- const NO_FOCUS_LIB_X86 = isDevMode ?
39
- path.join(__dirname, '../../../../cpp/prebuilt/i386/libnoblur.so') :
40
- path.join(__dirname, '../lib/firefox/i386/libnoblur.so') ;
41
-
42
- /** @const */
43
- const NO_FOCUS_LIB_AMD64 = isDevMode ?
44
- path.join(__dirname, '../../../../cpp/prebuilt/amd64/libnoblur64.so') :
45
- path.join(__dirname, '../lib/firefox/amd64/libnoblur64.so') ;
46
-
47
- const X_IGNORE_NO_FOCUS_LIB = 'x_ignore_nofocus.so';
48
-
49
-
50
- /**
51
- * @param {string} file Path to the file to find, relative to the program files
52
- * root.
53
- * @return {!Promise<?string>} A promise for the located executable.
54
- * The promise will resolve to {@code null} if Firefox was not found.
55
- */
56
- function findInProgramFiles(file) {
57
- let files = [
58
- process.env['PROGRAMFILES'] || 'C:\\Program Files',
59
- process.env['PROGRAMFILES(X86)'] || 'C:\\Program Files (x86)'
60
- ].map(prefix => path.join(prefix, file));
61
- return io.exists(files[0]).then(function(exists) {
62
- return exists ? files[0] : io.exists(files[1]).then(function(exists) {
63
- return exists ? files[1] : null;
64
- });
65
- });
66
- }
67
-
68
-
69
- /**
70
- * Provides methods for locating the executable for a Firefox release channel
71
- * on Windows and MacOS. For other systems (i.e. Linux), Firefox will always
72
- * be located on the system PATH.
73
- *
74
- * @final
75
- */
76
- class Channel {
77
- /**
78
- * @param {string} darwin The path to check when running on MacOS.
79
- * @param {string} win32 The path to check when running on Windows.
80
- */
81
- constructor(darwin, win32) {
82
- /** @private @const */ this.darwin_ = darwin;
83
- /** @private @const */ this.win32_ = win32;
84
- /** @private {Promise<string>} */
85
- this.found_ = null;
86
- }
87
-
88
- /**
89
- * Attempts to locate the Firefox executable for this release channel. This
90
- * will first check the default installation location for the channel before
91
- * checking the user's PATH. The returned promise will be rejected if Firefox
92
- * can not be found.
93
- *
94
- * @return {!Promise<string>} A promise for the location of the located
95
- * Firefox executable.
96
- */
97
- locate() {
98
- if (this.found_) {
99
- return this.found_;
100
- }
101
-
102
- let found;
103
- switch (process.platform) {
104
- case 'darwin':
105
- found = io.exists(this.darwin_)
106
- .then(exists => exists ? this.darwin_ : io.findInPath('firefox'));
107
- break;
108
-
109
- case 'win32':
110
- found = findInProgramFiles(this.win32_)
111
- .then(found => found || io.findInPath('firefox.exe'));
112
- break;
113
-
114
- default:
115
- found = Promise.resolve(io.findInPath('firefox'));
116
- break;
117
- }
118
-
119
- this.found_ = found.then(found => {
120
- if (found) {
121
- // TODO: verify version info.
122
- return found;
123
- }
124
- throw Error('Could not locate Firefox on the current system');
125
- });
126
- return this.found_;
127
- }
128
- }
129
-
130
-
131
- /**
132
- * Firefox's developer channel.
133
- * @const
134
- * @see <https://www.mozilla.org/en-US/firefox/channel/desktop/#aurora>
135
- */
136
- Channel.AURORA = new Channel(
137
- '/Applications/FirefoxDeveloperEdition.app/Contents/MacOS/firefox-bin',
138
- 'Firefox Developer Edition\\firefox.exe');
139
-
140
- /**
141
- * Firefox's beta channel. Note this is provided mainly for convenience as
142
- * the beta channel has the same installation location as the main release
143
- * channel.
144
- * @const
145
- * @see <https://www.mozilla.org/en-US/firefox/channel/desktop/#beta>
146
- */
147
- Channel.BETA = new Channel(
148
- '/Applications/Firefox.app/Contents/MacOS/firefox-bin',
149
- 'Mozilla Firefox\\firefox.exe');
150
-
151
- /**
152
- * Firefox's release channel.
153
- * @const
154
- * @see <https://www.mozilla.org/en-US/firefox/desktop/>
155
- */
156
- Channel.RELEASE = new Channel(
157
- '/Applications/Firefox.app/Contents/MacOS/firefox-bin',
158
- 'Mozilla Firefox\\firefox.exe');
159
-
160
- /**
161
- * Firefox's nightly release channel.
162
- * @const
163
- * @see <https://www.mozilla.org/en-US/firefox/channel/desktop/#nightly>
164
- */
165
- Channel.NIGHTLY = new Channel(
166
- '/Applications/FirefoxNightly.app/Contents/MacOS/firefox-bin',
167
- 'Nightly\\firefox.exe');
168
-
169
-
170
- /**
171
- * Copies the no focus libs into the given profile directory.
172
- * @param {string} profileDir Path to the profile directory to install into.
173
- * @return {!Promise<string>} The LD_LIBRARY_PATH prefix string to use
174
- * for the installed libs.
175
- */
176
- function installNoFocusLibs(profileDir) {
177
- var x86 = path.join(profileDir, 'x86');
178
- var amd64 = path.join(profileDir, 'amd64');
179
-
180
- return io.mkdir(x86)
181
- .then(() => copyLib(NO_FOCUS_LIB_X86, x86))
182
- .then(() => io.mkdir(amd64))
183
- .then(() => copyLib(NO_FOCUS_LIB_AMD64, amd64))
184
- .then(function() {
185
- return x86 + ':' + amd64;
186
- });
187
-
188
- function copyLib(src, dir) {
189
- return io.copy(src, path.join(dir, X_IGNORE_NO_FOCUS_LIB));
190
- }
191
- }
192
-
193
-
194
- /**
195
- * Provides a mechanism to configure and launch Firefox in a subprocess for
196
- * use with WebDriver.
197
- *
198
- * If created _without_ a path for the Firefox binary to use, this class will
199
- * attempt to find Firefox when {@link #launch()} is called. For MacOS and
200
- * Windows, this class will look for Firefox in the current platform's default
201
- * installation location (e.g. /Applications/Firefox.app on MacOS). For all
202
- * other platforms, the Firefox executable must be available on your system
203
- * `PATH`.
204
- *
205
- * @final
206
- * @deprecated This class will be removed in 4.0. Use the binary management
207
- * functions available on the {@link ./index.Options firefox.Options} class.
208
- */
209
- class Binary {
210
- /**
211
- * @param {?(string|Channel)=} opt_exeOrChannel Either the path to a specific
212
- * Firefox binary to use, or a {@link Channel} instance that describes
213
- * how to locate the desired Firefox version.
214
- */
215
- constructor(opt_exeOrChannel) {
216
- /** @private {?(string|Channel)} */
217
- this.exe_ = opt_exeOrChannel || null;
218
-
219
- /** @private {!Array.<string>} */
220
- this.args_ = [];
221
-
222
- /** @private {!Object<string, string>} */
223
- this.env_ = {};
224
- Object.assign(this.env_, process.env, {
225
- MOZ_CRASHREPORTER_DISABLE: '1',
226
- MOZ_NO_REMOTE: '1',
227
- NO_EM_RESTART: '1'
228
- });
229
-
230
- /** @private {boolean} */
231
- this.devEdition_ = false;
232
- }
233
-
234
- /**
235
- * @return {(string|undefined)} The path to the Firefox executable to use, or
236
- * `undefined` if WebDriver should attempt to locate Firefox automatically
237
- * on the current system.
238
- */
239
- getExe() {
240
- return typeof this.exe_ === 'string' ? this.exe_ : undefined;
241
- }
242
-
243
- /**
244
- * Add arguments to the command line used to start Firefox.
245
- * @param {...(string|!Array.<string>)} var_args Either the arguments to add
246
- * as varargs, or the arguments as an array.
247
- * @deprecated Use {@link ./index.Options#addArguments}.
248
- */
249
- addArguments(var_args) {
250
- for (var i = 0; i < arguments.length; i++) {
251
- if (Array.isArray(arguments[i])) {
252
- this.args_ = this.args_.concat(arguments[i]);
253
- } else {
254
- this.args_.push(arguments[i]);
255
- }
256
- }
257
- }
258
-
259
- /**
260
- * @return {!Array<string>} The command line arguments to use when starting
261
- * the browser.
262
- */
263
- getArguments() {
264
- return this.args_;
265
- }
266
-
267
- /**
268
- * Specifies whether to use Firefox Developer Edition instead of the normal
269
- * stable channel. Setting this option has no effect if this instance was
270
- * created with a path to a specific Firefox binary.
271
- *
272
- * This method has no effect on Unix systems where the Firefox application
273
- * has the same (default) name regardless of version.
274
- *
275
- * @param {boolean=} opt_use Whether to use the developer edition. Defaults to
276
- * true.
277
- * @deprecated Use the {@link Channel} class to indicate the desired Firefox
278
- * version when creating a new binary: `new Binary(Channel.AURORA)`.
279
- */
280
- useDevEdition(opt_use) {
281
- this.devEdition_ = opt_use === undefined || !!opt_use;
282
- }
283
-
284
- /**
285
- * Returns a promise for the Firefox executable used by this instance. The
286
- * returned promise will be immediately resolved if the user supplied an
287
- * executable path when this instance was created. Otherwise, an attempt will
288
- * be made to find Firefox on the current system.
289
- *
290
- * @return {!Promise<string>} a promise for the path to the Firefox executable
291
- * used by this instance.
292
- */
293
- locate() {
294
- if (typeof this.exe_ === 'string') {
295
- return Promise.resolve(this.exe_);
296
- } else if (this.exe_ instanceof Channel) {
297
- return this.exe_.locate();
298
- }
299
- let channel = this.devEdition_ ? Channel.AURORA : Channel.RELEASE;
300
- return channel.locate();
301
- }
302
-
303
- /**
304
- * Launches Firefox and returns a promise that will be fulfilled when the
305
- * process terminates.
306
- * @param {string} profile Path to the profile directory to use.
307
- * @return {!Promise<!exec.Command>} A promise for the handle to the started
308
- * subprocess.
309
- */
310
- launch(profile) {
311
- let env = {};
312
- Object.assign(env, this.env_, {XRE_PROFILE_PATH: profile});
313
-
314
- let args = ['-foreground'].concat(this.args_);
315
-
316
- return this.locate().then(function(firefox) {
317
- if (process.platform === 'win32' || process.platform === 'darwin') {
318
- return exec(firefox, {args: args, env: env});
319
- }
320
- return installNoFocusLibs(profile).then(function(ldLibraryPath) {
321
- env['LD_LIBRARY_PATH'] = ldLibraryPath + ':' + env['LD_LIBRARY_PATH'];
322
- env['LD_PRELOAD'] = X_IGNORE_NO_FOCUS_LIB;
323
- return exec(firefox, {args: args, env: env});
324
- });
325
- });
326
- }
327
-
328
- /**
329
- * Returns a promise for the wire representation of this binary. Note: the
330
- * FirefoxDriver only supports passing the path to the binary executable over
331
- * the wire; all command line arguments and environment variables will be
332
- * discarded.
333
- *
334
- * @return {!Promise<string>} A promise for this binary's wire representation.
335
- */
336
- [Symbols.serialize]() {
337
- return this.locate();
338
- }
339
- }
340
-
341
-
342
- // PUBLIC API
343
-
344
-
345
- exports.Binary = Binary;
346
- exports.Channel = Channel;
347
-