selenium-webdriver 4.0.0-alpha.4 → 4.0.0-alpha.8

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 (52) hide show
  1. package/.eslintrc.js +27 -0
  2. package/.prettierrc +4 -0
  3. package/CHANGES.md +22 -1
  4. package/README.md +4 -4
  5. package/chrome.js +72 -590
  6. package/chromium.js +1024 -0
  7. package/devtools/CDPConnection.js +37 -0
  8. package/devtools/generator/protocol-dts-generator.js +429 -0
  9. package/edge.js +124 -86
  10. package/firefox.js +201 -202
  11. package/http/index.js +131 -115
  12. package/http/util.js +56 -64
  13. package/ie.js +180 -104
  14. package/index.js +246 -199
  15. package/io/exec.js +34 -39
  16. package/io/index.js +141 -151
  17. package/io/zip.js +75 -65
  18. package/lib/README +5 -0
  19. package/lib/actions.js +138 -121
  20. package/lib/atoms/find-elements.js +123 -0
  21. package/lib/atoms/get-attribute.js +79 -60
  22. package/lib/atoms/is-displayed.js +72 -73
  23. package/{example/chrome_mobile_emulation.js → lib/atoms/make-atoms-module.js} +16 -23
  24. package/lib/by.js +192 -65
  25. package/lib/capabilities.js +82 -78
  26. package/lib/command.js +18 -20
  27. package/lib/error.js +134 -168
  28. package/lib/http.js +324 -230
  29. package/lib/input.js +325 -302
  30. package/lib/logging.js +127 -138
  31. package/lib/promise.js +60 -66
  32. package/lib/proxy.js +31 -41
  33. package/lib/session.js +12 -15
  34. package/lib/symbols.js +3 -4
  35. package/lib/until.js +162 -162
  36. package/lib/webdriver.js +733 -522
  37. package/net/index.js +30 -36
  38. package/net/portprober.js +31 -144
  39. package/opera.js +406 -0
  40. package/package.json +18 -11
  41. package/proxy.js +2 -2
  42. package/remote/index.js +190 -187
  43. package/safari.js +40 -49
  44. package/LICENSE +0 -202
  45. package/NOTICE +0 -2
  46. package/example/chrome_android.js +0 -42
  47. package/example/firefox_channels.js +0 -77
  48. package/example/google_search.js +0 -50
  49. package/example/google_search_test.js +0 -72
  50. package/example/headless.js +0 -55
  51. package/example/logging.js +0 -68
  52. package/testing/index.js +0 -498
package/index.js CHANGED
@@ -20,35 +20,32 @@
20
20
  * public API and provides convenience assessors to certain sub-modules.
21
21
  */
22
22
 
23
- 'use strict';
24
-
25
- const _http = require('./http');
26
- const by = require('./lib/by');
27
- const capabilities = require('./lib/capabilities');
28
- const chrome = require('./chrome');
29
- const command = require('./lib/command');
30
- const edge = require('./edge');
31
- const error = require('./lib/error');
32
- const firefox = require('./firefox');
33
- const ie = require('./ie');
34
- const input = require('./lib/input');
35
- const logging = require('./lib/logging');
36
- const promise = require('./lib/promise');
37
- const remote = require('./remote');
38
- const safari = require('./safari');
39
- const session = require('./lib/session');
40
- const until = require('./lib/until');
41
- const webdriver = require('./lib/webdriver');
42
-
43
- const Browser = capabilities.Browser;
44
- const Capabilities = capabilities.Capabilities;
45
- const Capability = capabilities.Capability;
46
- const Session = session.Session;
47
- const WebDriver = webdriver.WebDriver;
48
-
49
-
50
-
51
- var seleniumServer;
23
+ 'use strict'
24
+
25
+ const _http = require('./http')
26
+ const by = require('./lib/by')
27
+ const capabilities = require('./lib/capabilities')
28
+ const chrome = require('./chrome')
29
+ const edge = require('./edge')
30
+ const error = require('./lib/error')
31
+ const firefox = require('./firefox')
32
+ const ie = require('./ie')
33
+ const input = require('./lib/input')
34
+ const logging = require('./lib/logging')
35
+ const promise = require('./lib/promise')
36
+ const remote = require('./remote')
37
+ const safari = require('./safari')
38
+ const session = require('./lib/session')
39
+ const until = require('./lib/until')
40
+ const webdriver = require('./lib/webdriver')
41
+ const opera = require('./opera')
42
+
43
+ const Browser = capabilities.Browser
44
+ const Capabilities = capabilities.Capabilities
45
+ const Capability = capabilities.Capability
46
+ const WebDriver = webdriver.WebDriver
47
+
48
+ var seleniumServer
52
49
 
53
50
  /**
54
51
  * Starts an instance of the Selenium server if not yet running.
@@ -58,12 +55,11 @@ var seleniumServer;
58
55
  */
59
56
  function startSeleniumServer(jar) {
60
57
  if (!seleniumServer) {
61
- seleniumServer = new remote.SeleniumServer(jar);
58
+ seleniumServer = new remote.SeleniumServer(jar)
62
59
  }
63
- return seleniumServer.start();
60
+ return seleniumServer.start()
64
61
  }
65
62
 
66
-
67
63
  /**
68
64
  * {@linkplain webdriver.WebDriver#setFileDetector WebDriver's setFileDetector}
69
65
  * method uses a non-standard command to transfer files from the local client
@@ -83,13 +79,12 @@ function ensureFileDetectorsAreEnabled(ctor) {
83
79
  const mixin = class extends ctor {
84
80
  /** @param {input.FileDetector} detector */
85
81
  setFileDetector(detector) {
86
- webdriver.WebDriver.prototype.setFileDetector.call(this, detector);
82
+ webdriver.WebDriver.prototype.setFileDetector.call(this, detector)
87
83
  }
88
- };
89
- return mixin;
84
+ }
85
+ return mixin
90
86
  }
91
87
 
92
-
93
88
  /**
94
89
  * A thenable wrapper around a {@linkplain webdriver.IWebDriver IWebDriver}
95
90
  * instance that allows commands to be issued directly instead of having to
@@ -108,16 +103,14 @@ function ensureFileDetectorsAreEnabled(ctor) {
108
103
  */
109
104
  class ThenableWebDriver {
110
105
  /** @param {...?} args */
111
- static createSession(...args) {}
106
+ static createSession(...args) {} // eslint-disable-line
112
107
  }
113
108
 
114
-
115
109
  /**
116
110
  * @const {!Map<function(new: WebDriver, !IThenable<!Session>, ...?),
117
111
  * function(new: ThenableWebDriver, !IThenable<!Session>, ...?)>}
118
112
  */
119
- const THENABLE_DRIVERS = new Map;
120
-
113
+ const THENABLE_DRIVERS = new Map()
121
114
 
122
115
  /**
123
116
  * @param {function(new: WebDriver, !IThenable<!Session>, ...?)} ctor
@@ -125,7 +118,7 @@ const THENABLE_DRIVERS = new Map;
125
118
  * @return {!ThenableWebDriver}
126
119
  */
127
120
  function createDriver(ctor, ...args) {
128
- let thenableWebDriverProxy = THENABLE_DRIVERS.get(ctor);
121
+ let thenableWebDriverProxy = THENABLE_DRIVERS.get(ctor)
129
122
  if (!thenableWebDriverProxy) {
130
123
  /**
131
124
  * @extends {WebDriver} // Needed since `ctor` is dynamically typed.
@@ -137,25 +130,24 @@ function createDriver(ctor, ...args) {
137
130
  * @param {...?} rest
138
131
  */
139
132
  constructor(session, ...rest) {
140
- super(session, ...rest);
133
+ super(session, ...rest)
141
134
 
142
- const pd = this.getSession().then(session => {
143
- return new ctor(session, ...rest);
144
- });
135
+ const pd = this.getSession().then((session) => {
136
+ return new ctor(session, ...rest)
137
+ })
145
138
 
146
139
  /** @override */
147
- this.then = pd.then.bind(pd);
140
+ this.then = pd.then.bind(pd)
148
141
 
149
142
  /** @override */
150
- this.catch = pd.catch.bind(pd);
143
+ this.catch = pd.catch.bind(pd)
151
144
  }
152
- };
153
- THENABLE_DRIVERS.set(ctor, thenableWebDriverProxy);
145
+ }
146
+ THENABLE_DRIVERS.set(ctor, thenableWebDriverProxy)
154
147
  }
155
- return thenableWebDriverProxy.createSession(...args);
148
+ return thenableWebDriverProxy.createSession(...args)
156
149
  }
157
150
 
158
-
159
151
  /**
160
152
  * Creates new {@link webdriver.WebDriver WebDriver} instances. The environment
161
153
  * variables listed below may be used to override a builder's configuration,
@@ -198,49 +190,55 @@ function createDriver(ctor, ...args) {
198
190
  class Builder {
199
191
  constructor() {
200
192
  /** @private @const */
201
- this.log_ = logging.getLogger('webdriver.Builder');
193
+ this.log_ = logging.getLogger('webdriver.Builder')
202
194
 
203
195
  /** @private {string} */
204
- this.url_ = '';
196
+ this.url_ = ''
205
197
 
206
198
  /** @private {?string} */
207
- this.proxy_ = null;
199
+ this.proxy_ = null
208
200
 
209
201
  /** @private {!Capabilities} */
210
- this.capabilities_ = new Capabilities();
202
+ this.capabilities_ = new Capabilities()
211
203
 
212
204
  /** @private {chrome.Options} */
213
- this.chromeOptions_ = null;
205
+ this.chromeOptions_ = null
214
206
 
215
207
  /** @private {chrome.ServiceBuilder} */
216
- this.chromeService_ = null;
208
+ this.chromeService_ = null
217
209
 
218
210
  /** @private {firefox.Options} */
219
- this.firefoxOptions_ = null;
211
+ this.firefoxOptions_ = null
220
212
 
221
213
  /** @private {firefox.ServiceBuilder} */
222
- this.firefoxService_ = null;
214
+ this.firefoxService_ = null
223
215
 
224
216
  /** @private {ie.Options} */
225
- this.ieOptions_ = null;
226
-
217
+ this.ieOptions_ = null
218
+
227
219
  /** @private {ie.ServiceBuilder} */
228
- this.ieService_ = null;
220
+ this.ieService_ = null
229
221
 
230
222
  /** @private {safari.Options} */
231
- this.safariOptions_ = null;
223
+ this.safariOptions_ = null
232
224
 
233
225
  /** @private {edge.Options} */
234
- this.edgeOptions_ = null;
226
+ this.edgeOptions_ = null
235
227
 
236
228
  /** @private {remote.DriverService.Builder} */
237
- this.edgeService_ = null;
229
+ this.edgeService_ = null
238
230
 
239
231
  /** @private {boolean} */
240
- this.ignoreEnv_ = false;
232
+ this.ignoreEnv_ = false
241
233
 
242
234
  /** @private {http.Agent} */
243
- this.agent_ = null;
235
+ this.agent_ = null
236
+
237
+ /** @private {opera.Options} */
238
+ this.operaOptions_ = null
239
+
240
+ /** @private {remote.DriverService.Builder} */
241
+ this.operaService_ = null
244
242
  }
245
243
 
246
244
  /**
@@ -250,8 +248,8 @@ class Builder {
250
248
  * @return {!Builder} A self reference.
251
249
  */
252
250
  disableEnvironmentOverrides() {
253
- this.ignoreEnv_ = true;
254
- return this;
251
+ this.ignoreEnv_ = true
252
+ return this
255
253
  }
256
254
 
257
255
  /**
@@ -267,8 +265,8 @@ class Builder {
267
265
  * @return {!Builder} A self reference.
268
266
  */
269
267
  usingServer(url) {
270
- this.url_ = url;
271
- return this;
268
+ this.url_ = url
269
+ return this
272
270
  }
273
271
 
274
272
  /**
@@ -276,7 +274,7 @@ class Builder {
276
274
  * configured to use.
277
275
  */
278
276
  getServerUrl() {
279
- return this.url_;
277
+ return this.url_
280
278
  }
281
279
 
282
280
  /**
@@ -288,8 +286,8 @@ class Builder {
288
286
  * @return {!Builder} A self reference.
289
287
  */
290
288
  usingWebDriverProxy(proxy) {
291
- this.proxy_ = proxy;
292
- return this;
289
+ this.proxy_ = proxy
290
+ return this
293
291
  }
294
292
 
295
293
  /**
@@ -297,7 +295,7 @@ class Builder {
297
295
  * HTTP connections, or `null` if not set.
298
296
  */
299
297
  getWebDriverProxy() {
300
- return this.proxy_;
298
+ return this.proxy_
301
299
  }
302
300
 
303
301
  /**
@@ -308,15 +306,15 @@ class Builder {
308
306
  * @return {!Builder} A self reference.
309
307
  */
310
308
  usingHttpAgent(agent) {
311
- this.agent_ = agent;
312
- return this;
309
+ this.agent_ = agent
310
+ return this
313
311
  }
314
312
 
315
313
  /**
316
314
  * @return {http.Agent} The http agent used for each request
317
315
  */
318
316
  getHttpAgent() {
319
- return this.agent_;
317
+ return this.agent_
320
318
  }
321
319
 
322
320
  /**
@@ -327,8 +325,8 @@ class Builder {
327
325
  * @return {!Builder} A self reference.
328
326
  */
329
327
  withCapabilities(capabilities) {
330
- this.capabilities_ = new Capabilities(capabilities);
331
- return this;
328
+ this.capabilities_ = new Capabilities(capabilities)
329
+ return this
332
330
  }
333
331
 
334
332
  /**
@@ -337,7 +335,7 @@ class Builder {
337
335
  * @return {!Capabilities} The current capabilities for this builder.
338
336
  */
339
337
  getCapabilities() {
340
- return this.capabilities_;
338
+ return this.capabilities_
341
339
  }
342
340
 
343
341
  /**
@@ -358,14 +356,14 @@ class Builder {
358
356
  * @return {!Builder} A self reference.
359
357
  */
360
358
  forBrowser(name, opt_version, opt_platform) {
361
- this.capabilities_.setBrowserName(name);
359
+ this.capabilities_.setBrowserName(name)
362
360
  if (opt_version) {
363
- this.capabilities_.setBrowserVersion(opt_version);
361
+ this.capabilities_.setBrowserVersion(opt_version)
364
362
  }
365
363
  if (opt_platform) {
366
- this.capabilities_.setPlatform(opt_platform);
364
+ this.capabilities_.setPlatform(opt_platform)
367
365
  }
368
- return this;
366
+ return this
369
367
  }
370
368
 
371
369
  /**
@@ -377,8 +375,8 @@ class Builder {
377
375
  * @return {!Builder} A self reference.
378
376
  */
379
377
  setProxy(config) {
380
- this.capabilities_.setProxy(config);
381
- return this;
378
+ this.capabilities_.setProxy(config)
379
+ return this
382
380
  }
383
381
 
384
382
  /**
@@ -389,8 +387,8 @@ class Builder {
389
387
  * @return {!Builder} A self reference.
390
388
  */
391
389
  setLoggingPrefs(prefs) {
392
- this.capabilities_.setLoggingPrefs(prefs);
393
- return this;
390
+ this.capabilities_.setLoggingPrefs(prefs)
391
+ return this
394
392
  }
395
393
 
396
394
  /**
@@ -402,8 +400,8 @@ class Builder {
402
400
  * @see capabilities.Capabilities#setAlertBehavior
403
401
  */
404
402
  setAlertBehavior(behavior) {
405
- this.capabilities_.setAlertBehavior(behavior);
406
- return this;
403
+ this.capabilities_.setAlertBehavior(behavior)
404
+ return this
407
405
  }
408
406
 
409
407
  /**
@@ -416,8 +414,22 @@ class Builder {
416
414
  * @return {!Builder} A self reference.
417
415
  */
418
416
  setChromeOptions(options) {
419
- this.chromeOptions_ = options;
420
- return this;
417
+ this.chromeOptions_ = options
418
+ return this
419
+ }
420
+
421
+ /**
422
+ * Sets Opera specific {@linkplain opera.Options options} for drivers
423
+ * created by this builder. Any logging or proxy settings defined on the given
424
+ * options will take precedence over those set through
425
+ * {@link #setLoggingPrefs} and {@link #setProxy}, respectively.
426
+ *
427
+ * @param {!opera.Options} options The OperaDriver options to use.
428
+ * @return {!Builder} A self reference.
429
+ */
430
+ setOperaOptions(options) {
431
+ this.operaOptions_ = options
432
+ return this
421
433
  }
422
434
 
423
435
  /**
@@ -425,7 +437,7 @@ class Builder {
425
437
  * for this builder.
426
438
  */
427
439
  getChromeOptions() {
428
- return this.chromeOptions_;
440
+ return this.chromeOptions_
429
441
  }
430
442
 
431
443
  /**
@@ -437,10 +449,10 @@ class Builder {
437
449
  */
438
450
  setChromeService(service) {
439
451
  if (service && !(service instanceof chrome.ServiceBuilder)) {
440
- throw TypeError('not a chrome.ServiceBuilder object');
452
+ throw TypeError('not a chrome.ServiceBuilder object')
441
453
  }
442
- this.chromeService_ = service;
443
- return this;
454
+ this.chromeService_ = service
455
+ return this
444
456
  }
445
457
 
446
458
  /**
@@ -453,8 +465,8 @@ class Builder {
453
465
  * @return {!Builder} A self reference.
454
466
  */
455
467
  setFirefoxOptions(options) {
456
- this.firefoxOptions_ = options;
457
- return this;
468
+ this.firefoxOptions_ = options
469
+ return this
458
470
  }
459
471
 
460
472
  /**
@@ -462,7 +474,7 @@ class Builder {
462
474
  * for this instance.
463
475
  */
464
476
  getFirefoxOptions() {
465
- return this.firefoxOptions_;
477
+ return this.firefoxOptions_
466
478
  }
467
479
 
468
480
  /**
@@ -474,10 +486,10 @@ class Builder {
474
486
  */
475
487
  setFirefoxService(service) {
476
488
  if (service && !(service instanceof firefox.ServiceBuilder)) {
477
- throw TypeError('not a firefox.ServiceBuilder object');
489
+ throw TypeError('not a firefox.ServiceBuilder object')
478
490
  }
479
- this.firefoxService_ = service;
480
- return this;
491
+ this.firefoxService_ = service
492
+ return this
481
493
  }
482
494
 
483
495
  /**
@@ -489,8 +501,8 @@ class Builder {
489
501
  * @return {!Builder} A self reference.
490
502
  */
491
503
  setIeOptions(options) {
492
- this.ieOptions_ = options;
493
- return this;
504
+ this.ieOptions_ = options
505
+ return this
494
506
  }
495
507
 
496
508
  /**
@@ -501,8 +513,8 @@ class Builder {
501
513
  * @return {!Builder} a self reference.
502
514
  */
503
515
  setIeService(service) {
504
- this.ieService_ = service;
505
- return this;
516
+ this.ieService_ = service
517
+ return this
506
518
  }
507
519
 
508
520
  /**
@@ -515,8 +527,8 @@ class Builder {
515
527
  * @return {!Builder} A self reference.
516
528
  */
517
529
  setEdgeOptions(options) {
518
- this.edgeOptions_ = options;
519
- return this;
530
+ this.edgeOptions_ = options
531
+ return this
520
532
  }
521
533
 
522
534
  /**
@@ -528,10 +540,25 @@ class Builder {
528
540
  */
529
541
  setEdgeService(service) {
530
542
  if (service && !(service instanceof edge.ServiceBuilder)) {
531
- throw TypeError('not a edge.ServiceBuilder object');
543
+ throw TypeError('not a edge.ServiceBuilder object')
544
+ }
545
+ this.edgeService_ = service
546
+ return this
547
+ }
548
+
549
+ /**
550
+ * Sets the {@link opera.ServiceBuilder} to use to manage the
551
+ * operaDriver child process when creating sessions locally.
552
+ *
553
+ * @param {opera.ServiceBuilder} service the service to use.
554
+ * @return {!Builder} a self reference.
555
+ */
556
+ setOperaService(service) {
557
+ if (service && !(service instanceof opera.ServiceBuilder)) {
558
+ throw TypeError('not a opera.ServiceBuilder object')
532
559
  }
533
- this.edgeService_ = service;
534
- return this;
560
+ this.operaService_ = service
561
+ return this
535
562
  }
536
563
 
537
564
  /**
@@ -543,8 +570,8 @@ class Builder {
543
570
  * @return {!Builder} A self reference.
544
571
  */
545
572
  setSafariOptions(options) {
546
- this.safariOptions_ = options;
547
- return this;
573
+ this.safariOptions_ = options
574
+ return this
548
575
  }
549
576
 
550
577
  /**
@@ -552,7 +579,7 @@ class Builder {
552
579
  * for this instance.
553
580
  */
554
581
  getSafariOptions() {
555
- return this.safariOptions_;
582
+ return this.safariOptions_
556
583
  }
557
584
 
558
585
  /**
@@ -571,131 +598,151 @@ class Builder {
571
598
  build() {
572
599
  // Create a copy for any changes we may need to make based on the current
573
600
  // environment.
574
- var capabilities = new Capabilities(this.capabilities_);
601
+ var capabilities = new Capabilities(this.capabilities_)
575
602
 
576
- var browser;
603
+ var browser
577
604
  if (!this.ignoreEnv_ && process.env.SELENIUM_BROWSER) {
578
- this.log_.fine(`SELENIUM_BROWSER=${process.env.SELENIUM_BROWSER}`);
579
- browser = process.env.SELENIUM_BROWSER.split(/:/, 3);
580
- capabilities.setBrowserName(browser[0]);
605
+ this.log_.fine(`SELENIUM_BROWSER=${process.env.SELENIUM_BROWSER}`)
606
+ browser = process.env.SELENIUM_BROWSER.split(/:/, 3)
607
+ capabilities.setBrowserName(browser[0])
581
608
 
582
- browser[1] && capabilities.setBrowserVersion(browser[1]);
583
- browser[2] && capabilities.setPlatform(browser[2]);
609
+ browser[1] && capabilities.setBrowserVersion(browser[1])
610
+ browser[2] && capabilities.setPlatform(browser[2])
584
611
  }
585
612
 
586
- browser = capabilities.get(Capability.BROWSER_NAME);
613
+ browser = capabilities.get(Capability.BROWSER_NAME)
587
614
 
588
615
  if (typeof browser !== 'string') {
589
616
  throw TypeError(
590
- `Target browser must be a string, but is <${typeof browser}>;` +
591
- ' did you forget to call forBrowser()?');
617
+ `Target browser must be a string, but is <${typeof browser}>;` +
618
+ ' did you forget to call forBrowser()?'
619
+ )
592
620
  }
593
621
 
594
622
  if (browser === 'ie') {
595
- browser = Browser.INTERNET_EXPLORER;
623
+ browser = Browser.INTERNET_EXPLORER
596
624
  }
597
625
 
598
626
  // Apply browser specific overrides.
599
627
  if (browser === Browser.CHROME && this.chromeOptions_) {
600
- capabilities.merge(this.chromeOptions_);
601
-
628
+ capabilities.merge(this.chromeOptions_)
602
629
  } else if (browser === Browser.FIREFOX && this.firefoxOptions_) {
603
- capabilities.merge(this.firefoxOptions_);
604
-
630
+ capabilities.merge(this.firefoxOptions_)
605
631
  } else if (browser === Browser.INTERNET_EXPLORER && this.ieOptions_) {
606
- capabilities.merge(this.ieOptions_);
607
-
632
+ capabilities.merge(this.ieOptions_)
608
633
  } else if (browser === Browser.SAFARI && this.safariOptions_) {
609
- capabilities.merge(this.safariOptions_);
610
-
634
+ capabilities.merge(this.safariOptions_)
611
635
  } else if (browser === Browser.EDGE && this.edgeOptions_) {
612
- capabilities.merge(this.edgeOptions_);
636
+ capabilities.merge(this.edgeOptions_)
637
+ } else if (browser === Browser.OPERA && this.operaOptions_) {
638
+ capabilities.merge(this.operaOptions_)
613
639
  }
614
640
 
615
641
  checkOptions(
616
- capabilities, 'chromeOptions', chrome.Options, 'setChromeOptions');
642
+ capabilities,
643
+ 'chromeOptions',
644
+ chrome.Options,
645
+ 'setChromeOptions'
646
+ )
617
647
  checkOptions(
618
- capabilities, 'moz:firefoxOptions', firefox.Options,
619
- 'setFirefoxOptions');
648
+ capabilities,
649
+ 'moz:firefoxOptions',
650
+ firefox.Options,
651
+ 'setFirefoxOptions'
652
+ )
620
653
  checkOptions(
621
- capabilities, 'safari.options', safari.Options, 'setSafariOptions');
654
+ capabilities,
655
+ 'safari.options',
656
+ safari.Options,
657
+ 'setSafariOptions'
658
+ )
622
659
 
623
660
  // Check for a remote browser.
624
- let url = this.url_;
661
+ let url = this.url_
625
662
  if (!this.ignoreEnv_) {
626
663
  if (process.env.SELENIUM_REMOTE_URL) {
627
- this.log_.fine(
628
- `SELENIUM_REMOTE_URL=${process.env.SELENIUM_REMOTE_URL}`);
629
- url = process.env.SELENIUM_REMOTE_URL;
664
+ this.log_.fine(`SELENIUM_REMOTE_URL=${process.env.SELENIUM_REMOTE_URL}`)
665
+ url = process.env.SELENIUM_REMOTE_URL
630
666
  } else if (process.env.SELENIUM_SERVER_JAR) {
631
- this.log_.fine(
632
- `SELENIUM_SERVER_JAR=${process.env.SELENIUM_SERVER_JAR}`);
633
- url = startSeleniumServer(process.env.SELENIUM_SERVER_JAR);
667
+ this.log_.fine(`SELENIUM_SERVER_JAR=${process.env.SELENIUM_SERVER_JAR}`)
668
+ url = startSeleniumServer(process.env.SELENIUM_SERVER_JAR)
634
669
  }
635
670
  }
636
671
 
637
672
  if (url) {
638
- this.log_.fine('Creating session on remote server');
639
- let client = Promise.resolve(url)
640
- .then(url => new _http.HttpClient(url, this.agent_, this.proxy_));
641
- let executor = new _http.Executor(client);
673
+ this.log_.fine('Creating session on remote server')
674
+ let client = Promise.resolve(url).then(
675
+ (url) => new _http.HttpClient(url, this.agent_, this.proxy_)
676
+ )
677
+ let executor = new _http.Executor(client)
642
678
 
643
679
  if (browser === Browser.CHROME) {
644
- const driver = ensureFileDetectorsAreEnabled(chrome.Driver);
645
- return createDriver(driver, capabilities, executor);
680
+ const driver = ensureFileDetectorsAreEnabled(chrome.Driver)
681
+ return createDriver(driver, capabilities, executor)
646
682
  }
647
683
 
648
684
  if (browser === Browser.FIREFOX) {
649
- const driver = ensureFileDetectorsAreEnabled(firefox.Driver);
650
- return createDriver(driver, capabilities, executor);
685
+ const driver = ensureFileDetectorsAreEnabled(firefox.Driver)
686
+ return createDriver(driver, capabilities, executor)
651
687
  }
652
- return createDriver(WebDriver, executor, capabilities);
688
+ return createDriver(WebDriver, executor, capabilities)
653
689
  }
654
690
 
655
691
  // Check for a native browser.
656
692
  switch (browser) {
657
693
  case Browser.CHROME: {
658
- let service = null;
694
+ let service = null
659
695
  if (this.chromeService_) {
660
- service = this.chromeService_.build();
696
+ service = this.chromeService_.build()
661
697
  }
662
- return createDriver(chrome.Driver, capabilities, service);
698
+ return createDriver(chrome.Driver, capabilities, service)
663
699
  }
664
700
 
665
701
  case Browser.FIREFOX: {
666
- let service = null;
702
+ let service = null
667
703
  if (this.firefoxService_) {
668
- service = this.firefoxService_.build();
704
+ service = this.firefoxService_.build()
669
705
  }
670
- return createDriver(firefox.Driver, capabilities, service);
706
+ return createDriver(firefox.Driver, capabilities, service)
671
707
  }
672
708
 
673
- case Browser.INTERNET_EXPLORER:
674
- let service = null;
709
+ case Browser.INTERNET_EXPLORER: {
710
+ let service = null
675
711
  if (this.ieService_) {
676
- service = this.ieService_.build();
712
+ service = this.ieService_.build()
677
713
  }
678
- return createDriver(ie.Driver, capabilities, service);
714
+ return createDriver(ie.Driver, capabilities, service)
715
+ }
679
716
 
680
717
  case Browser.EDGE: {
681
- let service = null;
718
+ let service = null
682
719
  if (this.edgeService_) {
683
- service = this.edgeService_.build();
720
+ service = this.edgeService_.build()
684
721
  }
685
- return createDriver(edge.Driver, capabilities, service);
722
+ return createDriver(edge.Driver, capabilities, service)
723
+ }
724
+
725
+ case Browser.OPERA: {
726
+ let service = null
727
+ if (this.operaService_) {
728
+ service = this.operaService_.build()
729
+ }
730
+ return createDriver(opera.Driver, capabilities, service)
686
731
  }
687
732
 
688
733
  case Browser.SAFARI:
689
- return createDriver(safari.Driver, capabilities);
734
+ return createDriver(safari.Driver, capabilities)
690
735
 
691
736
  default:
692
- throw new Error('Do not know how to build driver: ' + browser
693
- + '; did you forget to call usingServer(url)?');
737
+ throw new Error(
738
+ 'Do not know how to build driver: ' +
739
+ browser +
740
+ '; did you forget to call usingServer(url)?'
741
+ )
694
742
  }
695
743
  }
696
744
  }
697
745
 
698
-
699
746
  /**
700
747
  * In the 3.x releases, the various browser option classes
701
748
  * (e.g. firefox.Options) had to be manually set as an option using the
@@ -742,37 +789,37 @@ class Builder {
742
789
  * @throws {error.InvalidArgumentError}
743
790
  */
744
791
  function checkOptions(caps, key, optionType, setMethod) {
745
- let val = caps.get(key);
792
+ let val = caps.get(key)
746
793
  if (val instanceof optionType) {
747
794
  throw new error.InvalidArgumentError(
748
- 'Options class extends Capabilities and should not be set as key '
749
- + `"${key}"; set browser-specific options with `
750
- + `Builder.${setMethod}(). For more information, see the `
751
- + 'documentation attached to the function that threw this error');
795
+ 'Options class extends Capabilities and should not be set as key ' +
796
+ `"${key}"; set browser-specific options with ` +
797
+ `Builder.${setMethod}(). For more information, see the ` +
798
+ 'documentation attached to the function that threw this error'
799
+ )
752
800
  }
753
801
  }
754
802
 
755
-
756
803
  // PUBLIC API
757
804
 
758
-
759
- exports.Browser = capabilities.Browser;
760
- exports.Builder = Builder;
761
- exports.Button = input.Button;
762
- exports.By = by.By;
763
- exports.Capabilities = capabilities.Capabilities;
764
- exports.Capability = capabilities.Capability;
765
- exports.Condition = webdriver.Condition;
766
- exports.FileDetector = input.FileDetector;
767
- exports.Key = input.Key;
768
- exports.Origin = input.Origin;
769
- exports.Session = session.Session;
770
- exports.ThenableWebDriver = ThenableWebDriver;
771
- exports.WebDriver = webdriver.WebDriver;
772
- exports.WebElement = webdriver.WebElement;
773
- exports.WebElementCondition = webdriver.WebElementCondition;
774
- exports.WebElementPromise = webdriver.WebElementPromise;
775
- exports.error = error;
776
- exports.logging = logging;
777
- exports.promise = promise;
778
- exports.until = until;
805
+ exports.Browser = capabilities.Browser
806
+ exports.Builder = Builder
807
+ exports.Button = input.Button
808
+ exports.By = by.By
809
+ exports.withTagName = by.withTagName
810
+ exports.Capabilities = capabilities.Capabilities
811
+ exports.Capability = capabilities.Capability
812
+ exports.Condition = webdriver.Condition
813
+ exports.FileDetector = input.FileDetector
814
+ exports.Key = input.Key
815
+ exports.Origin = input.Origin
816
+ exports.Session = session.Session
817
+ exports.ThenableWebDriver = ThenableWebDriver
818
+ exports.WebDriver = webdriver.WebDriver
819
+ exports.WebElement = webdriver.WebElement
820
+ exports.WebElementCondition = webdriver.WebElementCondition
821
+ exports.WebElementPromise = webdriver.WebElementPromise
822
+ exports.error = error
823
+ exports.logging = logging
824
+ exports.promise = promise
825
+ exports.until = until