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.
- package/CHANGES.md +9 -2
- package/README.md +2 -4
- package/chrome.js +19 -527
- package/chromium.js +762 -0
- package/edge.js +97 -58
- package/firefox.js +23 -5
- package/http/index.js +4 -0
- package/io/index.js +1 -1
- package/lib/actions.js +1 -1
- package/lib/atoms/get-attribute.js +1 -2
- package/lib/atoms/is-displayed.js +5 -6
- package/lib/atoms/make-atoms-module.js +17 -0
- package/lib/capabilities.js +17 -4
- package/lib/command.js +1 -0
- package/lib/http.js +8 -3
- package/lib/input.js +6 -6
- package/lib/logging.js +1 -1
- package/lib/webdriver.js +33 -3
- package/net/portprober.js +1 -1
- package/package.json +8 -9
- package/BUILD.bazel +0 -88
- package/example/chrome_android.js +0 -42
- package/example/chrome_mobile_emulation.js +0 -42
- package/example/firefox_channels.js +0 -77
- package/example/google_search.js +0 -50
- package/example/google_search_test.js +0 -72
- package/example/headless.js +0 -55
- package/example/logging.js +0 -68
- package/jasmine.json +0 -11
- package/lib/atoms/BUILD.bazel +0 -28
- package/lib/test/bootstrap_jasmine.js +0 -28
- package/lib/test/build.js +0 -156
- package/lib/test/data/actions/click.html +0 -24
- package/lib/test/data/actions/drag.html +0 -77
- package/lib/test/data/actions/record_click.html +0 -21
- package/lib/test/data/chrome/download.html +0 -2
- package/lib/test/data/firefox/webextension.xpi +0 -0
- package/lib/test/fileserver.js +0 -337
- package/lib/test/httpserver.js +0 -120
- package/lib/test/index.js +0 -87
- package/lib/test/resources.js +0 -40
- package/test/actions_test.js +0 -206
- package/test/builder_test.js +0 -106
- package/test/chrome/devtools_test.js +0 -93
- package/test/chrome/options_test.js +0 -121
- package/test/chrome/service_test.js +0 -45
- package/test/cookie_test.js +0 -210
- package/test/element_finding_test.js +0 -431
- package/test/execute_script_test.js +0 -355
- package/test/fingerprint_test.js +0 -63
- package/test/firefox_test.js +0 -233
- package/test/frame_test.js +0 -45
- package/test/http/http_test.js +0 -229
- package/test/http/util_test.js +0 -178
- package/test/io/io_test.js +0 -364
- package/test/io/zip_test.js +0 -126
- package/test/lib/by_test.js +0 -160
- package/test/lib/capabilities_test.js +0 -129
- package/test/lib/error_test.js +0 -333
- package/test/lib/http_test.js +0 -576
- package/test/lib/input_test.js +0 -1379
- package/test/lib/logging_test.js +0 -272
- package/test/lib/promise_test.js +0 -674
- package/test/lib/testutil.js +0 -90
- package/test/lib/until_test.js +0 -478
- package/test/lib/webdriver_test.js +0 -1692
- package/test/logging_test.js +0 -160
- package/test/net/index_test.js +0 -60
- package/test/net/portprober_test.js +0 -128
- package/test/page_loading_test.js +0 -156
- package/test/proxy_test.js +0 -167
- package/test/rect_test.js +0 -51
- package/test/remote_test.js +0 -98
- package/test/safari_test.js +0 -44
- package/test/stale_element_test.js +0 -60
- package/test/upload_test.js +0 -78
- package/test/window_test.js +0 -168
- package/testing/index.js +0 -498
- package/tools/init_jasmine.js +0 -7
package/CHANGES.md
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
## v4.0.0-alpha.
|
|
1
|
+
## v4.0.0-alpha.4
|
|
2
|
+
|
|
3
|
+
### Changes
|
|
4
|
+
|
|
5
|
+
* Removed BUILD.bazel files from the build artifact
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## v4.0.0-alpha.3
|
|
2
9
|
|
|
3
10
|
### Notice
|
|
4
11
|
|
|
@@ -718,7 +725,7 @@ continue to be supported, but will require setting the `--harmony` flag.
|
|
|
718
725
|
due to a previously uncaught error within the frame.
|
|
719
726
|
* FIXED: 8496: Extended the `chrome.Options` API to cover all configuration
|
|
720
727
|
options (e.g. mobile emulation and performance logging) documented on the
|
|
721
|
-
ChromeDriver [project site](https://
|
|
728
|
+
ChromeDriver [project site](https://chromedriver.chromium.org/capabilities).
|
|
722
729
|
|
|
723
730
|
## v2.45.0
|
|
724
731
|
|
package/README.md
CHANGED
|
@@ -117,13 +117,12 @@ Additional resources include
|
|
|
117
117
|
|
|
118
118
|
- the #selenium channel on freenode IRC
|
|
119
119
|
- the [selenium-users@googlegroups.com][users] list
|
|
120
|
-
- [SeleniumHQ](
|
|
120
|
+
- [SeleniumHQ](https://selenium.dev/documentation/) documentation
|
|
121
121
|
|
|
122
122
|
## Contributing
|
|
123
123
|
|
|
124
124
|
Contributions are accepted either through [GitHub][gh] pull requests or patches
|
|
125
|
-
via the [Selenium issue tracker][issues].
|
|
126
|
-
[Contributor License Agreement][cla] before your changes will be accepted.
|
|
125
|
+
via the [Selenium issue tracker][issues].
|
|
127
126
|
|
|
128
127
|
## Node Support Policy
|
|
129
128
|
|
|
@@ -217,7 +216,6 @@ under the License.
|
|
|
217
216
|
[LTS]: https://github.com/nodejs/LTS
|
|
218
217
|
[PATH]: http://en.wikipedia.org/wiki/PATH_%28variable%29
|
|
219
218
|
[api]: http://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/
|
|
220
|
-
[cla]: http://goo.gl/qC50R
|
|
221
219
|
[chrome]: http://chromedriver.storage.googleapis.com/index.html
|
|
222
220
|
[gh]: https://github.com/SeleniumHQ/selenium/
|
|
223
221
|
[issues]: https://github.com/SeleniumHQ/selenium/issues
|
package/chrome.js
CHANGED
|
@@ -118,29 +118,20 @@
|
|
|
118
118
|
* [Refer to the ChromeDriver site] for more information on using the
|
|
119
119
|
* [ChromeDriver with Android][android].
|
|
120
120
|
*
|
|
121
|
-
* [ChromeDriver]: https://
|
|
121
|
+
* [ChromeDriver]: https://chromedriver.chromium.org/
|
|
122
122
|
* [ChromeDriver release]: http://chromedriver.storage.googleapis.com/index.html
|
|
123
123
|
* [PATH]: http://en.wikipedia.org/wiki/PATH_%28variable%29
|
|
124
|
-
* [android]: https://
|
|
124
|
+
* [android]: https://chromedriver.chromium.org/getting-started/getting-started---android
|
|
125
125
|
* [webview]: https://developer.chrome.com/multidevice/webview/overview
|
|
126
126
|
*/
|
|
127
127
|
|
|
128
128
|
'use strict';
|
|
129
129
|
|
|
130
|
-
const fs = require('fs');
|
|
131
|
-
const util = require('util');
|
|
132
|
-
|
|
133
130
|
const http = require('./http');
|
|
134
131
|
const io = require('./io');
|
|
135
|
-
const {Browser, Capabilities
|
|
136
|
-
const command = require('./lib/command');
|
|
137
|
-
const error = require('./lib/error');
|
|
138
|
-
const logging = require('./lib/logging');
|
|
139
|
-
const promise = require('./lib/promise');
|
|
140
|
-
const Symbols = require('./lib/symbols');
|
|
141
|
-
const webdriver = require('./lib/webdriver');
|
|
142
|
-
const portprober = require('./net/portprober');
|
|
132
|
+
const {Browser, Capabilities} = require('./lib/capabilities');
|
|
143
133
|
const remote = require('./remote');
|
|
134
|
+
const chromium = require('./chromium');
|
|
144
135
|
|
|
145
136
|
|
|
146
137
|
/**
|
|
@@ -152,56 +143,6 @@ const CHROMEDRIVER_EXE =
|
|
|
152
143
|
process.platform === 'win32' ? 'chromedriver.exe' : 'chromedriver';
|
|
153
144
|
|
|
154
145
|
|
|
155
|
-
/**
|
|
156
|
-
* Custom command names supported by ChromeDriver.
|
|
157
|
-
* @enum {string}
|
|
158
|
-
*/
|
|
159
|
-
const Command = {
|
|
160
|
-
LAUNCH_APP: 'launchApp',
|
|
161
|
-
GET_NETWORK_CONDITIONS: 'getNetworkConditions',
|
|
162
|
-
SET_NETWORK_CONDITIONS: 'setNetworkConditions',
|
|
163
|
-
SEND_DEVTOOLS_COMMAND: 'sendDevToolsCommand',
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Creates a command executor with support for ChromeDriver's custom commands.
|
|
169
|
-
* @param {!Promise<string>} url The server's URL.
|
|
170
|
-
* @return {!command.Executor} The new command executor.
|
|
171
|
-
*/
|
|
172
|
-
function createExecutor(url) {
|
|
173
|
-
let agent = new http.Agent({ keepAlive: true });
|
|
174
|
-
let client = url.then(url => new http.HttpClient(url, agent));
|
|
175
|
-
let executor = new http.Executor(client);
|
|
176
|
-
configureExecutor(executor);
|
|
177
|
-
return executor;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Configures the given executor with Chrome-specific commands.
|
|
183
|
-
* @param {!http.Executor} executor the executor to configure.
|
|
184
|
-
*/
|
|
185
|
-
function configureExecutor(executor) {
|
|
186
|
-
executor.defineCommand(
|
|
187
|
-
Command.LAUNCH_APP,
|
|
188
|
-
'POST',
|
|
189
|
-
'/session/:sessionId/chromium/launch_app');
|
|
190
|
-
executor.defineCommand(
|
|
191
|
-
Command.GET_NETWORK_CONDITIONS,
|
|
192
|
-
'GET',
|
|
193
|
-
'/session/:sessionId/chromium/network_conditions');
|
|
194
|
-
executor.defineCommand(
|
|
195
|
-
Command.SET_NETWORK_CONDITIONS,
|
|
196
|
-
'POST',
|
|
197
|
-
'/session/:sessionId/chromium/network_conditions');
|
|
198
|
-
executor.defineCommand(
|
|
199
|
-
Command.SEND_DEVTOOLS_COMMAND,
|
|
200
|
-
'POST',
|
|
201
|
-
'/session/:sessionId/chromium/send_command');
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
|
|
205
146
|
/**
|
|
206
147
|
* _Synchronously_ attempts to locate the chromedriver executable on the current
|
|
207
148
|
* system.
|
|
@@ -215,10 +156,10 @@ function locateSynchronously() {
|
|
|
215
156
|
|
|
216
157
|
/**
|
|
217
158
|
* Creates {@link selenium-webdriver/remote.DriverService} instances that manage
|
|
218
|
-
* a [ChromeDriver](https://
|
|
159
|
+
* a [ChromeDriver](https://chromedriver.chromium.org/)
|
|
219
160
|
* server in a child process.
|
|
220
161
|
*/
|
|
221
|
-
class ServiceBuilder extends
|
|
162
|
+
class ServiceBuilder extends chromium.ServiceBuilder {
|
|
222
163
|
/**
|
|
223
164
|
* @param {string=} opt_exe Path to the server executable to use. If omitted,
|
|
224
165
|
* the builder will attempt to locate the chromedriver on the current
|
|
@@ -237,60 +178,10 @@ class ServiceBuilder extends remote.DriverService.Builder {
|
|
|
237
178
|
}
|
|
238
179
|
|
|
239
180
|
super(exe);
|
|
240
|
-
this.setLoopback(true); // Required
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* Sets which port adb is listening to. _The ChromeDriver will connect to adb
|
|
245
|
-
* if an {@linkplain Options#androidPackage Android session} is requested, but
|
|
246
|
-
* adb **must** be started beforehand._
|
|
247
|
-
*
|
|
248
|
-
* @param {number} port Which port adb is running on.
|
|
249
|
-
* @return {!ServiceBuilder} A self reference.
|
|
250
|
-
*/
|
|
251
|
-
setAdbPort(port) {
|
|
252
|
-
return this.addArguments('--adb-port=' + port);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* Sets the path of the log file the driver should log to. If a log file is
|
|
257
|
-
* not specified, the driver will log to stderr.
|
|
258
|
-
* @param {string} path Path of the log file to use.
|
|
259
|
-
* @return {!ServiceBuilder} A self reference.
|
|
260
|
-
*/
|
|
261
|
-
loggingTo(path) {
|
|
262
|
-
return this.addArguments('--log-path=' + path);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* Enables verbose logging.
|
|
267
|
-
* @return {!ServiceBuilder} A self reference.
|
|
268
|
-
*/
|
|
269
|
-
enableVerboseLogging() {
|
|
270
|
-
return this.addArguments('--verbose');
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* Sets the number of threads the driver should use to manage HTTP requests.
|
|
275
|
-
* By default, the driver will use 4 threads.
|
|
276
|
-
* @param {number} n The number of threads to use.
|
|
277
|
-
* @return {!ServiceBuilder} A self reference.
|
|
278
|
-
*/
|
|
279
|
-
setNumHttpThreads(n) {
|
|
280
|
-
return this.addArguments('--http-threads=' + n);
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* @override
|
|
285
|
-
*/
|
|
286
|
-
setPath(path) {
|
|
287
|
-
super.setPath(path);
|
|
288
|
-
return this.addArguments('--url-base=' + path);
|
|
289
181
|
}
|
|
290
182
|
}
|
|
291
183
|
|
|
292
184
|
|
|
293
|
-
|
|
294
185
|
/** @type {remote.DriverService} */
|
|
295
186
|
let defaultService = null;
|
|
296
187
|
|
|
@@ -324,111 +215,10 @@ function getDefaultService() {
|
|
|
324
215
|
}
|
|
325
216
|
|
|
326
217
|
|
|
327
|
-
const OPTIONS_CAPABILITY_KEY = 'goog:chromeOptions';
|
|
328
|
-
|
|
329
|
-
|
|
330
218
|
/**
|
|
331
219
|
* Class for managing ChromeDriver specific options.
|
|
332
220
|
*/
|
|
333
|
-
class Options extends
|
|
334
|
-
/**
|
|
335
|
-
* @param {(Capabilities|Map<string, ?>|Object)=} other Another set of
|
|
336
|
-
* capabilities to initialize this instance from.
|
|
337
|
-
*/
|
|
338
|
-
constructor(other = undefined) {
|
|
339
|
-
super(other);
|
|
340
|
-
|
|
341
|
-
/** @private {!Object} */
|
|
342
|
-
this.options_ = this.get(OPTIONS_CAPABILITY_KEY) || {};
|
|
343
|
-
|
|
344
|
-
this.setBrowserName(Browser.CHROME);
|
|
345
|
-
this.set(OPTIONS_CAPABILITY_KEY, this.options_);
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* Add additional command line arguments to use when launching the Chrome
|
|
350
|
-
* browser. Each argument may be specified with or without the "--" prefix
|
|
351
|
-
* (e.g. "--foo" and "foo"). Arguments with an associated value should be
|
|
352
|
-
* delimited by an "=": "foo=bar".
|
|
353
|
-
*
|
|
354
|
-
* @param {...(string|!Array<string>)} args The arguments to add.
|
|
355
|
-
* @return {!Options} A self reference.
|
|
356
|
-
*/
|
|
357
|
-
addArguments(...args) {
|
|
358
|
-
let newArgs = (this.options_.args || []).concat(...args);
|
|
359
|
-
if (newArgs.length) {
|
|
360
|
-
this.options_.args = newArgs;
|
|
361
|
-
}
|
|
362
|
-
return this;
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
/**
|
|
366
|
-
* Configures the chromedriver to start Chrome in headless mode.
|
|
367
|
-
*
|
|
368
|
-
* > __NOTE:__ Resizing the browser window in headless mode is only supported
|
|
369
|
-
* > in Chrome 60. Users are encouraged to set an initial window size with
|
|
370
|
-
* > the {@link #windowSize windowSize({width, height})} option.
|
|
371
|
-
*
|
|
372
|
-
* > __NOTE__: For security, Chrome disables downloads by default when
|
|
373
|
-
* > in headless mode (to prevent sites from silently downloading files to
|
|
374
|
-
* > your machine). After creating a session, you may call
|
|
375
|
-
* > {@link ./chrome.Driver#setDownloadPath setDownloadPath} to re-enable
|
|
376
|
-
* > downloads, saving files in the specified directory.
|
|
377
|
-
*
|
|
378
|
-
* @return {!Options} A self reference.
|
|
379
|
-
*/
|
|
380
|
-
headless() {
|
|
381
|
-
return this.addArguments('headless');
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
/**
|
|
385
|
-
* Sets the initial window size.
|
|
386
|
-
*
|
|
387
|
-
* @param {{width: number, height: number}} size The desired window size.
|
|
388
|
-
* @return {!Options} A self reference.
|
|
389
|
-
* @throws {TypeError} if width or height is unspecified, not a number, or
|
|
390
|
-
* less than or equal to 0.
|
|
391
|
-
*/
|
|
392
|
-
windowSize({width, height}) {
|
|
393
|
-
function checkArg(arg) {
|
|
394
|
-
if (typeof arg !== 'number' || arg <= 0) {
|
|
395
|
-
throw TypeError('Arguments must be {width, height} with numbers > 0');
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
checkArg(width);
|
|
399
|
-
checkArg(height);
|
|
400
|
-
return this.addArguments(`window-size=${width},${height}`);
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
/**
|
|
404
|
-
* List of Chrome command line switches to exclude that ChromeDriver by default
|
|
405
|
-
* passes when starting Chrome. Do not prefix switches with "--".
|
|
406
|
-
*
|
|
407
|
-
* @param {...(string|!Array<string>)} args The switches to exclude.
|
|
408
|
-
* @return {!Options} A self reference.
|
|
409
|
-
*/
|
|
410
|
-
excludeSwitches(...args) {
|
|
411
|
-
let switches = (this.options_.excludeSwitches || []).concat(...args);
|
|
412
|
-
if (switches.length) {
|
|
413
|
-
this.options_.excludeSwitches = switches;
|
|
414
|
-
}
|
|
415
|
-
return this;
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
/**
|
|
419
|
-
* Add additional extensions to install when launching Chrome. Each extension
|
|
420
|
-
* should be specified as the path to the packed CRX file, or a Buffer for an
|
|
421
|
-
* extension.
|
|
422
|
-
* @param {...(string|!Buffer|!Array<(string|!Buffer)>)} args The
|
|
423
|
-
* extensions to add.
|
|
424
|
-
* @return {!Options} A self reference.
|
|
425
|
-
*/
|
|
426
|
-
addExtensions(...args) {
|
|
427
|
-
let current = this.options_.extensions || [];
|
|
428
|
-
this.options_.extensions = current.concat(...args);
|
|
429
|
-
return this;
|
|
430
|
-
}
|
|
431
|
-
|
|
221
|
+
class Options extends chromium.Options {
|
|
432
222
|
/**
|
|
433
223
|
* Sets the path to the Chrome binary to use. On Mac OS X, this path should
|
|
434
224
|
* reference the actual Chrome executable, not just the application binary
|
|
@@ -441,98 +231,7 @@ class Options extends Capabilities {
|
|
|
441
231
|
* @return {!Options} A self reference.
|
|
442
232
|
*/
|
|
443
233
|
setChromeBinaryPath(path) {
|
|
444
|
-
this.
|
|
445
|
-
return this;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
/**
|
|
449
|
-
* Sets whether to leave the started Chrome browser running if the controlling
|
|
450
|
-
* ChromeDriver service is killed before {@link webdriver.WebDriver#quit()} is
|
|
451
|
-
* called.
|
|
452
|
-
* @param {boolean} detach Whether to leave the browser running if the
|
|
453
|
-
* chromedriver service is killed before the session.
|
|
454
|
-
* @return {!Options} A self reference.
|
|
455
|
-
*/
|
|
456
|
-
detachDriver(detach) {
|
|
457
|
-
this.options_.detach = detach;
|
|
458
|
-
return this;
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
/**
|
|
462
|
-
* Sets the user preferences for Chrome's user profile. See the "Preferences"
|
|
463
|
-
* file in Chrome's user data directory for examples.
|
|
464
|
-
* @param {!Object} prefs Dictionary of user preferences to use.
|
|
465
|
-
* @return {!Options} A self reference.
|
|
466
|
-
*/
|
|
467
|
-
setUserPreferences(prefs) {
|
|
468
|
-
this.options_.prefs = prefs;
|
|
469
|
-
return this;
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
/**
|
|
473
|
-
* Sets the performance logging preferences. Options include:
|
|
474
|
-
*
|
|
475
|
-
* - `enableNetwork`: Whether or not to collect events from Network domain.
|
|
476
|
-
* - `enablePage`: Whether or not to collect events from Page domain.
|
|
477
|
-
* - `enableTimeline`: Whether or not to collect events from Timeline domain.
|
|
478
|
-
* Note: when tracing is enabled, Timeline domain is implicitly disabled,
|
|
479
|
-
* unless `enableTimeline` is explicitly set to true.
|
|
480
|
-
* - `tracingCategories`: A comma-separated string of Chrome tracing
|
|
481
|
-
* categories for which trace events should be collected. An unspecified
|
|
482
|
-
* or empty string disables tracing.
|
|
483
|
-
* - `bufferUsageReportingInterval`: The requested number of milliseconds
|
|
484
|
-
* between DevTools trace buffer usage events. For example, if 1000, then
|
|
485
|
-
* once per second, DevTools will report how full the trace buffer is. If
|
|
486
|
-
* a report indicates the buffer usage is 100%, a warning will be issued.
|
|
487
|
-
*
|
|
488
|
-
* @param {{enableNetwork: boolean,
|
|
489
|
-
* enablePage: boolean,
|
|
490
|
-
* enableTimeline: boolean,
|
|
491
|
-
* tracingCategories: string,
|
|
492
|
-
* bufferUsageReportingInterval: number}} prefs The performance
|
|
493
|
-
* logging preferences.
|
|
494
|
-
* @return {!Options} A self reference.
|
|
495
|
-
*/
|
|
496
|
-
setPerfLoggingPrefs(prefs) {
|
|
497
|
-
this.options_.perfLoggingPrefs = prefs;
|
|
498
|
-
return this;
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
/**
|
|
502
|
-
* Sets preferences for the "Local State" file in Chrome's user data
|
|
503
|
-
* directory.
|
|
504
|
-
* @param {!Object} state Dictionary of local state preferences.
|
|
505
|
-
* @return {!Options} A self reference.
|
|
506
|
-
*/
|
|
507
|
-
setLocalState(state) {
|
|
508
|
-
this.options_.localState = state;
|
|
509
|
-
return this;
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
/**
|
|
513
|
-
* Sets the name of the activity hosting a Chrome-based Android WebView. This
|
|
514
|
-
* option must be set to connect to an [Android WebView](
|
|
515
|
-
* https://sites.google.com/a/chromium.org/chromedriver/getting-started/getting-started---android)
|
|
516
|
-
*
|
|
517
|
-
* @param {string} name The activity name.
|
|
518
|
-
* @return {!Options} A self reference.
|
|
519
|
-
*/
|
|
520
|
-
androidActivity(name) {
|
|
521
|
-
this.options_.androidActivity = name;
|
|
522
|
-
return this;
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
/**
|
|
526
|
-
* Sets the device serial number to connect to via ADB. If not specified, the
|
|
527
|
-
* ChromeDriver will select an unused device at random. An error will be
|
|
528
|
-
* returned if all devices already have active sessions.
|
|
529
|
-
*
|
|
530
|
-
* @param {string} serial The device serial number to connect to.
|
|
531
|
-
* @return {!Options} A self reference.
|
|
532
|
-
*/
|
|
533
|
-
androidDeviceSerial(serial) {
|
|
534
|
-
this.options_.androidDeviceSerial = serial;
|
|
535
|
-
return this;
|
|
234
|
+
return this.setBinaryPath(path);
|
|
536
235
|
}
|
|
537
236
|
|
|
538
237
|
/**
|
|
@@ -545,44 +244,6 @@ class Options extends Capabilities {
|
|
|
545
244
|
return this.androidPackage('com.android.chrome');
|
|
546
245
|
}
|
|
547
246
|
|
|
548
|
-
/**
|
|
549
|
-
* Sets the package name of the Chrome or WebView app.
|
|
550
|
-
*
|
|
551
|
-
* @param {?string} pkg The package to connect to, or `null` to disable Android
|
|
552
|
-
* and switch back to using desktop Chrome.
|
|
553
|
-
* @return {!Options} A self reference.
|
|
554
|
-
*/
|
|
555
|
-
androidPackage(pkg) {
|
|
556
|
-
this.options_.androidPackage = pkg;
|
|
557
|
-
return this;
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
/**
|
|
561
|
-
* Sets the process name of the Activity hosting the WebView (as given by
|
|
562
|
-
* `ps`). If not specified, the process name is assumed to be the same as
|
|
563
|
-
* {@link #androidPackage}.
|
|
564
|
-
*
|
|
565
|
-
* @param {string} processName The main activity name.
|
|
566
|
-
* @return {!Options} A self reference.
|
|
567
|
-
*/
|
|
568
|
-
androidProcess(processName) {
|
|
569
|
-
this.options_.androidProcess = processName;
|
|
570
|
-
return this;
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
/**
|
|
574
|
-
* Sets whether to connect to an already-running instead of the specified
|
|
575
|
-
* {@linkplain #androidProcess app} instead of launching the app with a clean
|
|
576
|
-
* data directory.
|
|
577
|
-
*
|
|
578
|
-
* @param {boolean} useRunning Whether to connect to a running instance.
|
|
579
|
-
* @return {!Options} A self reference.
|
|
580
|
-
*/
|
|
581
|
-
androidUseRunningApp(useRunning) {
|
|
582
|
-
this.options_.androidUseRunningApp = useRunning;
|
|
583
|
-
return this;
|
|
584
|
-
}
|
|
585
|
-
|
|
586
247
|
/**
|
|
587
248
|
* Sets the path to Chrome's log file. This path should exist on the machine
|
|
588
249
|
* that will launch Chrome.
|
|
@@ -590,8 +251,7 @@ class Options extends Capabilities {
|
|
|
590
251
|
* @return {!Options} A self reference.
|
|
591
252
|
*/
|
|
592
253
|
setChromeLogFile(path) {
|
|
593
|
-
this.
|
|
594
|
-
return this;
|
|
254
|
+
return this.setBrowserLogFile(path);
|
|
595
255
|
}
|
|
596
256
|
|
|
597
257
|
/**
|
|
@@ -601,79 +261,18 @@ class Options extends Capabilities {
|
|
|
601
261
|
* @return {!Options} A self reference.
|
|
602
262
|
*/
|
|
603
263
|
setChromeMinidumpPath(path) {
|
|
604
|
-
this.
|
|
605
|
-
return this;
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
/**
|
|
609
|
-
* Configures Chrome to emulate a mobile device. For more information, refer
|
|
610
|
-
* to the ChromeDriver project page on [mobile emulation][em]. Configuration
|
|
611
|
-
* options include:
|
|
612
|
-
*
|
|
613
|
-
* - `deviceName`: The name of a pre-configured [emulated device][devem]
|
|
614
|
-
* - `width`: screen width, in pixels
|
|
615
|
-
* - `height`: screen height, in pixels
|
|
616
|
-
* - `pixelRatio`: screen pixel ratio
|
|
617
|
-
*
|
|
618
|
-
* __Example 1: Using a Pre-configured Device__
|
|
619
|
-
*
|
|
620
|
-
* let options = new chrome.Options().setMobileEmulation(
|
|
621
|
-
* {deviceName: 'Google Nexus 5'});
|
|
622
|
-
*
|
|
623
|
-
* let driver = chrome.Driver.createSession(options);
|
|
624
|
-
*
|
|
625
|
-
* __Example 2: Using Custom Screen Configuration__
|
|
626
|
-
*
|
|
627
|
-
* let options = new chrome.Options().setMobileEmulation({
|
|
628
|
-
* width: 360,
|
|
629
|
-
* height: 640,
|
|
630
|
-
* pixelRatio: 3.0
|
|
631
|
-
* });
|
|
632
|
-
*
|
|
633
|
-
* let driver = chrome.Driver.createSession(options);
|
|
634
|
-
*
|
|
635
|
-
*
|
|
636
|
-
* [em]: https://sites.google.com/a/chromium.org/chromedriver/mobile-emulation
|
|
637
|
-
* [devem]: https://developer.chrome.com/devtools/docs/device-mode
|
|
638
|
-
*
|
|
639
|
-
* @param {?({deviceName: string}|
|
|
640
|
-
* {width: number, height: number, pixelRatio: number})} config The
|
|
641
|
-
* mobile emulation configuration, or `null` to disable emulation.
|
|
642
|
-
* @return {!Options} A self reference.
|
|
643
|
-
*/
|
|
644
|
-
setMobileEmulation(config) {
|
|
645
|
-
this.options_.mobileEmulation = config;
|
|
646
|
-
return this;
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
/**
|
|
650
|
-
* Converts this instance to its JSON wire protocol representation. Note this
|
|
651
|
-
* function is an implementation not intended for general use.
|
|
652
|
-
*
|
|
653
|
-
* @return {!Object} The JSON wire protocol representation of this instance.
|
|
654
|
-
* @suppress {checkTypes} Suppress [] access on a struct.
|
|
655
|
-
*/
|
|
656
|
-
[Symbols.serialize]() {
|
|
657
|
-
if (this.options_.extensions && this.options_.extensions.length) {
|
|
658
|
-
this.options_.extensions =
|
|
659
|
-
this.options_.extensions.map(function(extension) {
|
|
660
|
-
if (Buffer.isBuffer(extension)) {
|
|
661
|
-
return extension.toString('base64');
|
|
662
|
-
}
|
|
663
|
-
return io.read(/** @type {string} */(extension))
|
|
664
|
-
.then(buffer => buffer.toString('base64'));
|
|
665
|
-
});
|
|
666
|
-
}
|
|
667
|
-
return super[Symbols.serialize]();
|
|
264
|
+
return this.setBrowserMinidumpPath(path);
|
|
668
265
|
}
|
|
669
266
|
}
|
|
670
267
|
|
|
268
|
+
Options.prototype.CAPABILITY_KEY = 'goog:chromeOptions';
|
|
269
|
+
Options.prototype.BROWSER_NAME_VALUE = Browser.CHROME;
|
|
270
|
+
|
|
671
271
|
|
|
672
272
|
/**
|
|
673
273
|
* Creates a new WebDriver client for Chrome.
|
|
674
274
|
*/
|
|
675
|
-
class Driver extends
|
|
676
|
-
|
|
275
|
+
class Driver extends chromium.Driver {
|
|
677
276
|
/**
|
|
678
277
|
* Creates a new session with the ChromeDriver.
|
|
679
278
|
*
|
|
@@ -686,121 +285,14 @@ class Driver extends webdriver.WebDriver {
|
|
|
686
285
|
* @return {!Driver} A new driver instance.
|
|
687
286
|
*/
|
|
688
287
|
static createSession(opt_config, opt_serviceExecutor) {
|
|
689
|
-
let
|
|
690
|
-
|
|
691
|
-
executor = opt_serviceExecutor;
|
|
692
|
-
configureExecutor(executor);
|
|
693
|
-
} else {
|
|
694
|
-
let service = opt_serviceExecutor || getDefaultService();
|
|
695
|
-
executor = createExecutor(service.start());
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
let caps = opt_config || Capabilities.chrome();
|
|
699
|
-
|
|
700
|
-
// W3C spec requires noProxy value to be an array of strings, but Chrome
|
|
701
|
-
// expects a single host as a string.
|
|
702
|
-
let proxy = caps.get(Capability.PROXY);
|
|
703
|
-
if (proxy && Array.isArray(proxy.noProxy)) {
|
|
704
|
-
proxy.noProxy = proxy.noProxy[0];
|
|
705
|
-
if (!proxy.noProxy) {
|
|
706
|
-
proxy.noProxy = undefined;
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
return /** @type {!Driver} */(super.createSession(executor, caps));
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
/**
|
|
714
|
-
* This function is a no-op as file detectors are not supported by this
|
|
715
|
-
* implementation.
|
|
716
|
-
* @override
|
|
717
|
-
*/
|
|
718
|
-
setFileDetector() {}
|
|
719
|
-
|
|
720
|
-
/**
|
|
721
|
-
* Schedules a command to launch Chrome App with given ID.
|
|
722
|
-
* @param {string} id ID of the App to launch.
|
|
723
|
-
* @return {!Promise<void>} A promise that will be resolved
|
|
724
|
-
* when app is launched.
|
|
725
|
-
*/
|
|
726
|
-
launchApp(id) {
|
|
727
|
-
return this.execute(
|
|
728
|
-
new command.Command(Command.LAUNCH_APP).setParameter('id', id));
|
|
729
|
-
}
|
|
730
|
-
|
|
731
|
-
/**
|
|
732
|
-
* Schedules a command to get Chrome network emulation settings.
|
|
733
|
-
* @return {!Promise} A promise that will be resolved when network
|
|
734
|
-
* emulation settings are retrievied.
|
|
735
|
-
*/
|
|
736
|
-
getNetworkConditions() {
|
|
737
|
-
return this.execute(new command.Command(Command.GET_NETWORK_CONDITIONS));
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
/**
|
|
741
|
-
* Schedules a command to set Chrome network emulation settings.
|
|
742
|
-
*
|
|
743
|
-
* __Sample Usage:__
|
|
744
|
-
*
|
|
745
|
-
* driver.setNetworkConditions({
|
|
746
|
-
* offline: false,
|
|
747
|
-
* latency: 5, // Additional latency (ms).
|
|
748
|
-
* download_throughput: 500 * 1024, // Maximal aggregated download throughput.
|
|
749
|
-
* upload_throughput: 500 * 1024 // Maximal aggregated upload throughput.
|
|
750
|
-
* });
|
|
751
|
-
*
|
|
752
|
-
* @param {Object} spec Defines the network conditions to set
|
|
753
|
-
* @return {!Promise<void>} A promise that will be resolved when network
|
|
754
|
-
* emulation settings are set.
|
|
755
|
-
*/
|
|
756
|
-
setNetworkConditions(spec) {
|
|
757
|
-
if (!spec || typeof spec !== 'object') {
|
|
758
|
-
throw TypeError('setNetworkConditions called with non-network-conditions parameter');
|
|
759
|
-
}
|
|
760
|
-
return this.execute(
|
|
761
|
-
new command.Command(Command.SET_NETWORK_CONDITIONS)
|
|
762
|
-
.setParameter('network_conditions', spec));
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
/**
|
|
766
|
-
* Sends an arbitrary devtools command to the browser.
|
|
767
|
-
*
|
|
768
|
-
* @param {string} cmd The name of the command to send.
|
|
769
|
-
* @param {Object=} params The command parameters.
|
|
770
|
-
* @return {!Promise<void>} A promise that will be resolved when the command
|
|
771
|
-
* has finished.
|
|
772
|
-
* @see <https://chromedevtools.github.io/devtools-protocol/>
|
|
773
|
-
*/
|
|
774
|
-
sendDevToolsCommand(cmd, params = {}) {
|
|
775
|
-
return this.execute(
|
|
776
|
-
new command.Command(Command.SEND_DEVTOOLS_COMMAND)
|
|
777
|
-
.setParameter('cmd', cmd)
|
|
778
|
-
.setParameter('params', params));
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
/**
|
|
782
|
-
* Sends a DevTools command to change Chrome's download directory.
|
|
783
|
-
*
|
|
784
|
-
* @param {string} path The desired download directory.
|
|
785
|
-
* @return {!Promise<void>} A promise that will be resolved when the command
|
|
786
|
-
* has finished.
|
|
787
|
-
* @see #sendDevToolsCommand
|
|
788
|
-
*/
|
|
789
|
-
async setDownloadPath(path) {
|
|
790
|
-
if (!path || typeof path !== 'string') {
|
|
791
|
-
throw new error.InvalidArgumentError('invalid download path');
|
|
792
|
-
}
|
|
793
|
-
const stat = await io.stat(path);
|
|
794
|
-
if (!stat.isDirectory()) {
|
|
795
|
-
throw new error.InvalidArgumentError('not a directory: ' + path);
|
|
796
|
-
}
|
|
797
|
-
return this.sendDevToolsCommand('Page.setDownloadBehavior', {
|
|
798
|
-
'behavior': 'allow',
|
|
799
|
-
'downloadPath': path
|
|
800
|
-
});
|
|
288
|
+
let caps = opt_config || new Options();
|
|
289
|
+
return /** @type {!Driver} */(super.createSession(caps, opt_serviceExecutor));
|
|
801
290
|
}
|
|
802
291
|
}
|
|
803
292
|
|
|
293
|
+
Driver.getDefaultService = getDefaultService;
|
|
294
|
+
Driver.prototype.VENDOR_COMMAND_PREFIX = "goog";
|
|
295
|
+
|
|
804
296
|
|
|
805
297
|
// PUBLIC API
|
|
806
298
|
|