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.
- package/CHANGES.md +181 -0
- package/README.md +25 -27
- package/chrome.js +113 -127
- package/edge.js +42 -117
- package/example/chrome_android.js +8 -8
- package/example/chrome_mobile_emulation.js +8 -8
- package/example/firefox_channels.js +22 -18
- package/example/google_search_test.js +39 -26
- package/example/logging.js +39 -6
- package/firefox.js +769 -0
- package/http/index.js +41 -4
- package/http/util.js +11 -6
- package/ie.js +56 -97
- package/index.js +178 -114
- package/jasmine.json +11 -0
- package/lib/actions.js +68 -63
- package/lib/by.js +1 -1
- package/lib/capabilities.js +255 -192
- package/lib/command.js +26 -50
- package/lib/error.js +85 -44
- package/lib/http.js +133 -110
- package/lib/input.js +1044 -8
- package/lib/promise.js +222 -3323
- package/lib/proxy.js +134 -39
- package/lib/test/bootstrap_jasmine.js +28 -0
- package/lib/test/data/actions/click.html +24 -0
- package/lib/test/data/actions/drag.html +77 -0
- package/lib/test/data/actions/record_click.html +21 -0
- package/lib/test/data/chrome/download.html +2 -0
- package/lib/test/data/inputs.html +42 -0
- package/lib/test/data/selectPage.html +12 -0
- package/lib/test/data/simpleTest.html +5 -0
- package/lib/test/data/upload_invisible.html +45 -0
- package/lib/test/fileserver.js +23 -19
- package/lib/test/index.js +30 -212
- package/lib/test/resources.js +0 -1
- package/lib/webdriver.js +675 -936
- package/net/index.js +21 -25
- package/net/portprober.js +51 -68
- package/package.json +5 -3
- package/remote/index.js +5 -19
- package/safari.js +41 -128
- package/test/actions_test.js +173 -18
- package/test/{session_test.js → builder_test.js} +44 -37
- package/test/chrome/devtools_test.js +93 -0
- package/test/chrome/options_test.js +48 -154
- package/test/chrome/service_test.js +7 -7
- package/test/cookie_test.js +77 -63
- package/test/element_finding_test.js +206 -201
- package/test/execute_script_test.js +115 -114
- package/test/fingerprint_test.js +16 -15
- package/test/firefox_test.js +251 -0
- package/test/http/http_test.js +0 -1
- package/test/http/util_test.js +2 -2
- package/test/io/zip_test.js +6 -7
- package/test/lib/error_test.js +34 -7
- package/test/lib/http_test.js +8 -128
- package/test/lib/input_test.js +1379 -0
- package/test/lib/promise_test.js +473 -908
- package/test/lib/webdriver_test.js +296 -868
- package/test/logging_test.js +37 -43
- package/test/page_loading_test.js +71 -81
- package/test/proxy_test.js +64 -72
- package/test/rect_test.js +14 -25
- package/test/remote_test.js +10 -29
- package/test/safari_test.js +7 -71
- package/test/stale_element_test.js +20 -23
- package/test/tag_name_test.js +10 -9
- package/test/upload_test.js +27 -35
- package/test/window_test.js +72 -85
- package/testing/index.js +386 -314
- package/.npmignore +0 -2
- package/example/async_await_test.js +0 -69
- package/example/google_search_generator.js +0 -47
- package/example/parallel_flows.js +0 -51
- package/firefox/binary.js +0 -347
- package/firefox/extension.js +0 -224
- package/firefox/index.js +0 -576
- package/firefox/profile.js +0 -311
- package/lib/events.js +0 -210
- package/lib/test/data/firefox/jetpack-sample.xpi +0 -0
- package/lib/test/data/firefox/sample.xpi +0 -0
- package/lib/test/promise.js +0 -79
- package/opera.js +0 -405
- package/phantomjs.js +0 -282
- package/test/firefox/extension_test.js +0 -120
- package/test/firefox/firefox_test.js +0 -244
- package/test/firefox/profile_test.js +0 -140
- package/test/lib/events_test.js +0 -177
- package/test/lib/promise_aplus_test.js +0 -78
- package/test/lib/promise_error_test.js +0 -884
- package/test/lib/promise_flow_test.js +0 -2288
- package/test/lib/promise_generator_test.js +0 -310
- package/test/phantomjs/execute_phantomjs_test.js +0 -59
- package/test/testing/assert_test.js +0 -373
- package/test/testing/index_test.js +0 -224
- package/testing/assert.js +0 -378
package/index.js
CHANGED
|
@@ -22,27 +22,23 @@
|
|
|
22
22
|
|
|
23
23
|
'use strict';
|
|
24
24
|
|
|
25
|
-
const chrome = require('./chrome');
|
|
26
|
-
const edge = require('./edge');
|
|
27
|
-
const firefox = require('./firefox');
|
|
28
25
|
const _http = require('./http');
|
|
29
|
-
const ie = require('./ie');
|
|
30
|
-
const actions = require('./lib/actions');
|
|
31
26
|
const by = require('./lib/by');
|
|
32
27
|
const capabilities = require('./lib/capabilities');
|
|
28
|
+
const chrome = require('./chrome');
|
|
33
29
|
const command = require('./lib/command');
|
|
30
|
+
const edge = require('./edge');
|
|
34
31
|
const error = require('./lib/error');
|
|
35
|
-
const
|
|
32
|
+
const firefox = require('./firefox');
|
|
33
|
+
const ie = require('./ie');
|
|
36
34
|
const input = require('./lib/input');
|
|
37
35
|
const logging = require('./lib/logging');
|
|
38
36
|
const promise = require('./lib/promise');
|
|
37
|
+
const remote = require('./remote');
|
|
38
|
+
const safari = require('./safari');
|
|
39
39
|
const session = require('./lib/session');
|
|
40
40
|
const until = require('./lib/until');
|
|
41
41
|
const webdriver = require('./lib/webdriver');
|
|
42
|
-
const opera = require('./opera');
|
|
43
|
-
const phantomjs = require('./phantomjs');
|
|
44
|
-
const remote = require('./remote');
|
|
45
|
-
const safari = require('./safari');
|
|
46
42
|
|
|
47
43
|
const Browser = capabilities.Browser;
|
|
48
44
|
const Capabilities = capabilities.Capabilities;
|
|
@@ -107,7 +103,7 @@ function ensureFileDetectorsAreEnabled(ctor) {
|
|
|
107
103
|
* every issued command will fail.
|
|
108
104
|
*
|
|
109
105
|
* @extends {webdriver.IWebDriver}
|
|
110
|
-
* @extends {
|
|
106
|
+
* @extends {IThenable<!webdriver.IWebDriver>}
|
|
111
107
|
* @interface
|
|
112
108
|
*/
|
|
113
109
|
class ThenableWebDriver {
|
|
@@ -147,24 +143,13 @@ function createDriver(ctor, ...args) {
|
|
|
147
143
|
return new ctor(session, ...rest);
|
|
148
144
|
});
|
|
149
145
|
|
|
150
|
-
/**
|
|
151
|
-
* @param {(string|Error)=} opt_reason
|
|
152
|
-
* @override
|
|
153
|
-
*/
|
|
154
|
-
this.cancel = function(opt_reason) {
|
|
155
|
-
if (promise.CancellableThenable.isImplementation(pd)) {
|
|
156
|
-
/** @type {!promise.CancellableThenable} */(pd).cancel(opt_reason);
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
|
|
160
146
|
/** @override */
|
|
161
147
|
this.then = pd.then.bind(pd);
|
|
162
148
|
|
|
163
149
|
/** @override */
|
|
164
|
-
this.catch = pd.
|
|
150
|
+
this.catch = pd.catch.bind(pd);
|
|
165
151
|
}
|
|
166
152
|
};
|
|
167
|
-
promise.CancellableThenable.addImplementation(thenableWebDriverProxy);
|
|
168
153
|
THENABLE_DRIVERS.set(ctor, thenableWebDriverProxy);
|
|
169
154
|
}
|
|
170
155
|
return thenableWebDriverProxy.createSession(...args);
|
|
@@ -215,9 +200,6 @@ class Builder {
|
|
|
215
200
|
/** @private @const */
|
|
216
201
|
this.log_ = logging.getLogger('webdriver.Builder');
|
|
217
202
|
|
|
218
|
-
/** @private {promise.ControlFlow} */
|
|
219
|
-
this.flow_ = null;
|
|
220
|
-
|
|
221
203
|
/** @private {string} */
|
|
222
204
|
this.url_ = '';
|
|
223
205
|
|
|
@@ -230,11 +212,14 @@ class Builder {
|
|
|
230
212
|
/** @private {chrome.Options} */
|
|
231
213
|
this.chromeOptions_ = null;
|
|
232
214
|
|
|
215
|
+
/** @private {chrome.ServiceBuilder} */
|
|
216
|
+
this.chromeService_ = null;
|
|
217
|
+
|
|
233
218
|
/** @private {firefox.Options} */
|
|
234
219
|
this.firefoxOptions_ = null;
|
|
235
220
|
|
|
236
|
-
/** @private {
|
|
237
|
-
this.
|
|
221
|
+
/** @private {firefox.ServiceBuilder} */
|
|
222
|
+
this.firefoxService_ = null;
|
|
238
223
|
|
|
239
224
|
/** @private {ie.Options} */
|
|
240
225
|
this.ieOptions_ = null;
|
|
@@ -245,6 +230,9 @@ class Builder {
|
|
|
245
230
|
/** @private {edge.Options} */
|
|
246
231
|
this.edgeOptions_ = null;
|
|
247
232
|
|
|
233
|
+
/** @private {remote.DriverService.Builder} */
|
|
234
|
+
this.edgeService_ = null;
|
|
235
|
+
|
|
248
236
|
/** @private {boolean} */
|
|
249
237
|
this.ignoreEnv_ = false;
|
|
250
238
|
|
|
@@ -358,18 +346,22 @@ class Builder {
|
|
|
358
346
|
* environment variable. If set, this environment variable should be of the
|
|
359
347
|
* form `browser[:[version][:platform]]`.
|
|
360
348
|
*
|
|
361
|
-
* @param {(string
|
|
349
|
+
* @param {(string|!Browser)} name The name of the target browser;
|
|
362
350
|
* common defaults are available on the {@link webdriver.Browser} enum.
|
|
363
351
|
* @param {string=} opt_version A desired version; may be omitted if any
|
|
364
352
|
* version should be used.
|
|
365
|
-
* @param {string=} opt_platform
|
|
366
|
-
*
|
|
353
|
+
* @param {(string|!capabilities.Platform)=} opt_platform
|
|
354
|
+
* The desired platform; may be omitted if any platform may be used.
|
|
367
355
|
* @return {!Builder} A self reference.
|
|
368
356
|
*/
|
|
369
357
|
forBrowser(name, opt_version, opt_platform) {
|
|
370
|
-
this.capabilities_.
|
|
371
|
-
|
|
372
|
-
|
|
358
|
+
this.capabilities_.setBrowserName(name);
|
|
359
|
+
if (opt_version) {
|
|
360
|
+
this.capabilities_.setBrowserVersion(opt_version);
|
|
361
|
+
}
|
|
362
|
+
if (opt_platform) {
|
|
363
|
+
this.capabilities_.setPlatform(opt_platform);
|
|
364
|
+
}
|
|
373
365
|
return this;
|
|
374
366
|
}
|
|
375
367
|
|
|
@@ -378,7 +370,7 @@ class Builder {
|
|
|
378
370
|
* Any calls to {@link #withCapabilities} after this function will
|
|
379
371
|
* overwrite these settings.
|
|
380
372
|
*
|
|
381
|
-
* @param {
|
|
373
|
+
* @param {!./lib/proxy.Config} config The configuration to use.
|
|
382
374
|
* @return {!Builder} A self reference.
|
|
383
375
|
*/
|
|
384
376
|
setProxy(config) {
|
|
@@ -398,33 +390,13 @@ class Builder {
|
|
|
398
390
|
return this;
|
|
399
391
|
}
|
|
400
392
|
|
|
401
|
-
/**
|
|
402
|
-
* Sets whether native events should be used.
|
|
403
|
-
* @param {boolean} enabled Whether to enable native events.
|
|
404
|
-
* @return {!Builder} A self reference.
|
|
405
|
-
*/
|
|
406
|
-
setEnableNativeEvents(enabled) {
|
|
407
|
-
this.capabilities_.setEnableNativeEvents(enabled);
|
|
408
|
-
return this;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
/**
|
|
412
|
-
* Sets how elements should be scrolled into view for interaction.
|
|
413
|
-
* @param {number} behavior The desired scroll behavior: either 0 to align
|
|
414
|
-
* with the top of the viewport or 1 to align with the bottom.
|
|
415
|
-
* @return {!Builder} A self reference.
|
|
416
|
-
*/
|
|
417
|
-
setScrollBehavior(behavior) {
|
|
418
|
-
this.capabilities_.setScrollBehavior(behavior);
|
|
419
|
-
return this;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
393
|
/**
|
|
423
394
|
* Sets the default action to take with an unexpected alert before returning
|
|
424
395
|
* an error.
|
|
425
|
-
*
|
|
426
|
-
*
|
|
396
|
+
*
|
|
397
|
+
* @param {?capabilities.UserPromptHandler} behavior The desired behavior.
|
|
427
398
|
* @return {!Builder} A self reference.
|
|
399
|
+
* @see capabilities.Capabilities#setAlertBehavior
|
|
428
400
|
*/
|
|
429
401
|
setAlertBehavior(behavior) {
|
|
430
402
|
this.capabilities_.setAlertBehavior(behavior);
|
|
@@ -445,6 +417,29 @@ class Builder {
|
|
|
445
417
|
return this;
|
|
446
418
|
}
|
|
447
419
|
|
|
420
|
+
/**
|
|
421
|
+
* @return {chrome.Options} the Chrome specific options currently configured
|
|
422
|
+
* for this builder.
|
|
423
|
+
*/
|
|
424
|
+
getChromeOptions() {
|
|
425
|
+
return this.chromeOptions_;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* Sets the service builder to use for managing the chromedriver child process
|
|
430
|
+
* when creating new Chrome sessions.
|
|
431
|
+
*
|
|
432
|
+
* @param {chrome.ServiceBuilder} service the service to use.
|
|
433
|
+
* @return {!Builder} A self reference.
|
|
434
|
+
*/
|
|
435
|
+
setChromeService(service) {
|
|
436
|
+
if (service && !(service instanceof chrome.ServiceBuilder)) {
|
|
437
|
+
throw TypeError('not a chrome.ServiceBuilder object');
|
|
438
|
+
}
|
|
439
|
+
this.chromeService_ = service;
|
|
440
|
+
return this;
|
|
441
|
+
}
|
|
442
|
+
|
|
448
443
|
/**
|
|
449
444
|
* Sets Firefox specific {@linkplain firefox.Options options} for drivers
|
|
450
445
|
* created by this builder. Any logging or proxy settings defined on the given
|
|
@@ -468,16 +463,17 @@ class Builder {
|
|
|
468
463
|
}
|
|
469
464
|
|
|
470
465
|
/**
|
|
471
|
-
* Sets
|
|
472
|
-
*
|
|
473
|
-
* will take precedence over those set through {@link #setLoggingPrefs} and
|
|
474
|
-
* {@link #setProxy}, respectively.
|
|
466
|
+
* Sets the {@link firefox.ServiceBuilder} to use to manage the geckodriver
|
|
467
|
+
* child process when creating Firefox sessions locally.
|
|
475
468
|
*
|
|
476
|
-
* @param {
|
|
477
|
-
* @return {!Builder}
|
|
469
|
+
* @param {firefox.ServiceBuilder} service the service to use.
|
|
470
|
+
* @return {!Builder} a self reference.
|
|
478
471
|
*/
|
|
479
|
-
|
|
480
|
-
|
|
472
|
+
setFirefoxService(service) {
|
|
473
|
+
if (service && !(service instanceof firefox.ServiceBuilder)) {
|
|
474
|
+
throw TypeError('not a firefox.ServiceBuilder object');
|
|
475
|
+
}
|
|
476
|
+
this.firefoxService_ = service;
|
|
481
477
|
return this;
|
|
482
478
|
}
|
|
483
479
|
|
|
@@ -508,6 +504,21 @@ class Builder {
|
|
|
508
504
|
return this;
|
|
509
505
|
}
|
|
510
506
|
|
|
507
|
+
/**
|
|
508
|
+
* Sets the {@link edge.ServiceBuilder} to use to manage the
|
|
509
|
+
* MicrosoftEdgeDriver child process when creating sessions locally.
|
|
510
|
+
*
|
|
511
|
+
* @param {edge.ServiceBuilder} service the service to use.
|
|
512
|
+
* @return {!Builder} a self reference.
|
|
513
|
+
*/
|
|
514
|
+
setEdgeService(service) {
|
|
515
|
+
if (service && !(service instanceof edge.ServiceBuilder)) {
|
|
516
|
+
throw TypeError('not a edge.ServiceBuilder object');
|
|
517
|
+
}
|
|
518
|
+
this.edgeService_ = service;
|
|
519
|
+
return this;
|
|
520
|
+
}
|
|
521
|
+
|
|
511
522
|
/**
|
|
512
523
|
* Sets Safari specific {@linkplain safari.Options options} for drivers
|
|
513
524
|
* created by this builder. Any logging settings defined on the given options
|
|
@@ -529,19 +540,6 @@ class Builder {
|
|
|
529
540
|
return this.safariOptions_;
|
|
530
541
|
}
|
|
531
542
|
|
|
532
|
-
/**
|
|
533
|
-
* Sets the control flow that created drivers should execute actions in. If
|
|
534
|
-
* the flow is never set, or is set to {@code null}, it will use the active
|
|
535
|
-
* flow at the time {@link #build()} is called.
|
|
536
|
-
* @param {promise.ControlFlow} flow The control flow to use, or
|
|
537
|
-
* {@code null} to
|
|
538
|
-
* @return {!Builder} A self reference.
|
|
539
|
-
*/
|
|
540
|
-
setControlFlow(flow) {
|
|
541
|
-
this.flow_ = flow;
|
|
542
|
-
return this;
|
|
543
|
-
}
|
|
544
|
-
|
|
545
543
|
/**
|
|
546
544
|
* Creates a new WebDriver client based on this builder's current
|
|
547
545
|
* configuration.
|
|
@@ -564,9 +562,10 @@ class Builder {
|
|
|
564
562
|
if (!this.ignoreEnv_ && process.env.SELENIUM_BROWSER) {
|
|
565
563
|
this.log_.fine(`SELENIUM_BROWSER=${process.env.SELENIUM_BROWSER}`);
|
|
566
564
|
browser = process.env.SELENIUM_BROWSER.split(/:/, 3);
|
|
567
|
-
capabilities.
|
|
568
|
-
|
|
569
|
-
capabilities.
|
|
565
|
+
capabilities.setBrowserName(browser[0]);
|
|
566
|
+
|
|
567
|
+
browser[1] && capabilities.setBrowserVersion(browser[1]);
|
|
568
|
+
browser[2] && capabilities.setPlatform(browser[2]);
|
|
570
569
|
}
|
|
571
570
|
|
|
572
571
|
browser = capabilities.get(Capability.BROWSER_NAME);
|
|
@@ -583,24 +582,29 @@ class Builder {
|
|
|
583
582
|
|
|
584
583
|
// Apply browser specific overrides.
|
|
585
584
|
if (browser === Browser.CHROME && this.chromeOptions_) {
|
|
586
|
-
capabilities.merge(this.chromeOptions_
|
|
585
|
+
capabilities.merge(this.chromeOptions_);
|
|
587
586
|
|
|
588
587
|
} else if (browser === Browser.FIREFOX && this.firefoxOptions_) {
|
|
589
|
-
capabilities.merge(this.firefoxOptions_
|
|
588
|
+
capabilities.merge(this.firefoxOptions_);
|
|
590
589
|
|
|
591
590
|
} else if (browser === Browser.INTERNET_EXPLORER && this.ieOptions_) {
|
|
592
|
-
capabilities.merge(this.ieOptions_
|
|
593
|
-
|
|
594
|
-
} else if (browser === Browser.OPERA && this.operaOptions_) {
|
|
595
|
-
capabilities.merge(this.operaOptions_.toCapabilities());
|
|
591
|
+
capabilities.merge(this.ieOptions_);
|
|
596
592
|
|
|
597
593
|
} else if (browser === Browser.SAFARI && this.safariOptions_) {
|
|
598
|
-
capabilities.merge(this.safariOptions_
|
|
594
|
+
capabilities.merge(this.safariOptions_);
|
|
599
595
|
|
|
600
596
|
} else if (browser === Browser.EDGE && this.edgeOptions_) {
|
|
601
|
-
capabilities.merge(this.edgeOptions_
|
|
597
|
+
capabilities.merge(this.edgeOptions_);
|
|
602
598
|
}
|
|
603
599
|
|
|
600
|
+
checkOptions(
|
|
601
|
+
capabilities, 'chromeOptions', chrome.Options, 'setChromeOptions');
|
|
602
|
+
checkOptions(
|
|
603
|
+
capabilities, 'moz:firefoxOptions', firefox.Options,
|
|
604
|
+
'setFirefoxOptions');
|
|
605
|
+
checkOptions(
|
|
606
|
+
capabilities, 'safari.options', safari.Options, 'setSafariOptions');
|
|
607
|
+
|
|
604
608
|
// Check for a remote browser.
|
|
605
609
|
let url = this.url_;
|
|
606
610
|
if (!this.ignoreEnv_) {
|
|
@@ -623,41 +627,47 @@ class Builder {
|
|
|
623
627
|
|
|
624
628
|
if (browser === Browser.CHROME) {
|
|
625
629
|
const driver = ensureFileDetectorsAreEnabled(chrome.Driver);
|
|
626
|
-
return createDriver(
|
|
627
|
-
driver, capabilities, executor, this.flow_);
|
|
630
|
+
return createDriver(driver, capabilities, executor);
|
|
628
631
|
}
|
|
629
632
|
|
|
630
633
|
if (browser === Browser.FIREFOX) {
|
|
631
634
|
const driver = ensureFileDetectorsAreEnabled(firefox.Driver);
|
|
632
|
-
return createDriver(
|
|
633
|
-
driver, capabilities, executor, this.flow_);
|
|
635
|
+
return createDriver(driver, capabilities, executor);
|
|
634
636
|
}
|
|
635
|
-
return createDriver(
|
|
636
|
-
WebDriver, executor, capabilities, this.flow_);
|
|
637
|
+
return createDriver(WebDriver, executor, capabilities);
|
|
637
638
|
}
|
|
638
639
|
|
|
639
640
|
// Check for a native browser.
|
|
640
641
|
switch (browser) {
|
|
641
|
-
case Browser.CHROME:
|
|
642
|
-
|
|
642
|
+
case Browser.CHROME: {
|
|
643
|
+
let service = null;
|
|
644
|
+
if (this.chromeService_) {
|
|
645
|
+
service = this.chromeService_.build();
|
|
646
|
+
}
|
|
647
|
+
return createDriver(chrome.Driver, capabilities, service);
|
|
648
|
+
}
|
|
643
649
|
|
|
644
|
-
case Browser.FIREFOX:
|
|
645
|
-
|
|
650
|
+
case Browser.FIREFOX: {
|
|
651
|
+
let service = null;
|
|
652
|
+
if (this.firefoxService_) {
|
|
653
|
+
service = this.firefoxService_.build();
|
|
654
|
+
}
|
|
655
|
+
return createDriver(firefox.Driver, capabilities, service);
|
|
656
|
+
}
|
|
646
657
|
|
|
647
658
|
case Browser.INTERNET_EXPLORER:
|
|
648
|
-
return createDriver(ie.Driver, capabilities
|
|
649
|
-
|
|
650
|
-
case Browser.EDGE:
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
return createDriver(phantomjs.Driver, capabilities, this.flow_);
|
|
659
|
+
return createDriver(ie.Driver, capabilities);
|
|
660
|
+
|
|
661
|
+
case Browser.EDGE: {
|
|
662
|
+
let service = null;
|
|
663
|
+
if (this.edgeService_) {
|
|
664
|
+
service = this.edgeService_.build();
|
|
665
|
+
}
|
|
666
|
+
return createDriver(edge.Driver, capabilities, service);
|
|
667
|
+
}
|
|
658
668
|
|
|
659
669
|
case Browser.SAFARI:
|
|
660
|
-
return createDriver(safari.Driver, capabilities
|
|
670
|
+
return createDriver(safari.Driver, capabilities);
|
|
661
671
|
|
|
662
672
|
default:
|
|
663
673
|
throw new Error('Do not know how to build driver: ' + browser
|
|
@@ -667,10 +677,66 @@ class Builder {
|
|
|
667
677
|
}
|
|
668
678
|
|
|
669
679
|
|
|
680
|
+
/**
|
|
681
|
+
* In the 3.x releases, the various browser option classes
|
|
682
|
+
* (e.g. firefox.Options) had to be manually set as an option using the
|
|
683
|
+
* Capabilties class:
|
|
684
|
+
*
|
|
685
|
+
* let ffo = new firefox.Options();
|
|
686
|
+
* // Configure firefox options...
|
|
687
|
+
*
|
|
688
|
+
* let caps = new Capabilities();
|
|
689
|
+
* caps.set('moz:firefoxOptions', ffo);
|
|
690
|
+
*
|
|
691
|
+
* let driver = new Builder()
|
|
692
|
+
* .withCapabilities(caps)
|
|
693
|
+
* .build();
|
|
694
|
+
*
|
|
695
|
+
* The options are now subclasses of Capabilities and can be used directly. A
|
|
696
|
+
* direct translation of the above is:
|
|
697
|
+
*
|
|
698
|
+
* let ffo = new firefox.Options();
|
|
699
|
+
* // Configure firefox options...
|
|
700
|
+
*
|
|
701
|
+
* let driver = new Builder()
|
|
702
|
+
* .withCapabilities(ffo)
|
|
703
|
+
* .build();
|
|
704
|
+
*
|
|
705
|
+
* You can also set the options for various browsers at once and let the builder
|
|
706
|
+
* choose the correct set at runtime (see Builder docs above):
|
|
707
|
+
*
|
|
708
|
+
* let ffo = new firefox.Options();
|
|
709
|
+
* // Configure ...
|
|
710
|
+
*
|
|
711
|
+
* let co = new chrome.Options();
|
|
712
|
+
* // Configure ...
|
|
713
|
+
*
|
|
714
|
+
* let driver = new Builder()
|
|
715
|
+
* .setChromeOptions(co)
|
|
716
|
+
* .setFirefoxOptions(ffo)
|
|
717
|
+
* .build();
|
|
718
|
+
*
|
|
719
|
+
* @param {!Capabilities} caps
|
|
720
|
+
* @param {string} key
|
|
721
|
+
* @param {function(new: Capabilities)} optionType
|
|
722
|
+
* @param {string} setMethod
|
|
723
|
+
* @throws {error.InvalidArgumentError}
|
|
724
|
+
*/
|
|
725
|
+
function checkOptions(caps, key, optionType, setMethod) {
|
|
726
|
+
let val = caps.get(key);
|
|
727
|
+
if (val instanceof optionType) {
|
|
728
|
+
throw new error.InvalidArgumentError(
|
|
729
|
+
'Options class extends Capabilities and should not be set as key '
|
|
730
|
+
+ `"${key}"; set browser-specific options with `
|
|
731
|
+
+ `Builder.${setMethod}(). For more information, see the `
|
|
732
|
+
+ 'documentation attached to the function that threw this error');
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
|
|
670
737
|
// PUBLIC API
|
|
671
738
|
|
|
672
739
|
|
|
673
|
-
exports.ActionSequence = actions.ActionSequence;
|
|
674
740
|
exports.Browser = capabilities.Browser;
|
|
675
741
|
exports.Builder = Builder;
|
|
676
742
|
exports.Button = input.Button;
|
|
@@ -678,12 +744,10 @@ exports.By = by.By;
|
|
|
678
744
|
exports.Capabilities = capabilities.Capabilities;
|
|
679
745
|
exports.Capability = capabilities.Capability;
|
|
680
746
|
exports.Condition = webdriver.Condition;
|
|
681
|
-
exports.EventEmitter = events.EventEmitter;
|
|
682
747
|
exports.FileDetector = input.FileDetector;
|
|
683
748
|
exports.Key = input.Key;
|
|
684
749
|
exports.Session = session.Session;
|
|
685
750
|
exports.ThenableWebDriver = ThenableWebDriver;
|
|
686
|
-
exports.TouchSequence = actions.TouchSequence;
|
|
687
751
|
exports.WebDriver = webdriver.WebDriver;
|
|
688
752
|
exports.WebElement = webdriver.WebElement;
|
|
689
753
|
exports.WebElementCondition = webdriver.WebElementCondition;
|