selenium-webdriver 4.0.0-alpha.5 → 4.0.0-beta.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 +35 -1
- package/LICENSE +1 -1
- package/NOTICE +1 -1
- package/README.md +4 -4
- package/chrome.js +72 -592
- package/chromium.js +829 -0
- package/devtools/CDPConnection.js +37 -0
- package/edge.js +124 -86
- package/example/chrome_android.js +16 -13
- package/example/chrome_mobile_emulation.js +18 -14
- package/example/firefox_channels.js +35 -28
- package/example/google_search.js +9 -9
- package/example/google_search_test.js +20 -22
- package/example/headless.js +27 -19
- package/example/logging.js +34 -38
- package/firefox.js +200 -200
- package/http/index.js +131 -115
- package/http/util.js +56 -64
- package/ie.js +180 -104
- package/index.js +246 -199
- package/io/exec.js +34 -39
- package/io/index.js +142 -152
- package/io/zip.js +75 -65
- package/lib/actions.js +140 -122
- package/lib/atoms/find-elements.js +124 -0
- package/lib/atoms/get-attribute.js +79 -59
- package/lib/atoms/is-displayed.js +72 -73
- package/lib/atoms/mutation-listener.js +38 -0
- package/lib/by.js +192 -65
- package/lib/capabilities.js +82 -78
- package/lib/command.js +20 -20
- package/lib/error.js +134 -168
- package/lib/http.js +337 -230
- package/lib/input.js +325 -302
- package/lib/logging.js +127 -138
- package/lib/promise.js +60 -66
- package/lib/proxy.js +31 -41
- package/lib/session.js +12 -15
- package/lib/symbols.js +3 -4
- package/lib/until.js +162 -160
- package/lib/webdriver.js +1024 -541
- package/net/index.js +30 -36
- package/net/portprober.js +31 -144
- package/opera.js +406 -0
- package/package.json +19 -12
- package/proxy.js +2 -2
- package/remote/index.js +190 -187
- package/safari.js +40 -49
- package/testing/index.js +166 -155
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
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
const Browser = capabilities.Browser
|
|
44
|
-
const Capabilities = capabilities.Capabilities
|
|
45
|
-
const Capability = capabilities.Capability
|
|
46
|
-
const
|
|
47
|
-
|
|
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.
|
|
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
|
-
|
|
601
|
+
const capabilities = new Capabilities(this.capabilities_)
|
|
575
602
|
|
|
576
|
-
|
|
603
|
+
let 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
|
-
|
|
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
|
-
|
|
642
|
+
capabilities,
|
|
643
|
+
'chromeOptions',
|
|
644
|
+
chrome.Options,
|
|
645
|
+
'setChromeOptions'
|
|
646
|
+
)
|
|
617
647
|
checkOptions(
|
|
618
|
-
|
|
619
|
-
|
|
648
|
+
capabilities,
|
|
649
|
+
'moz:firefoxOptions',
|
|
650
|
+
firefox.Options,
|
|
651
|
+
'setFirefoxOptions'
|
|
652
|
+
)
|
|
620
653
|
checkOptions(
|
|
621
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
641
|
-
|
|
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(
|
|
693
|
-
|
|
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
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
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.
|
|
760
|
-
exports.
|
|
761
|
-
exports.
|
|
762
|
-
exports.
|
|
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
|