selenium-webdriver 4.0.0-rc-1 → 4.1.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 +51 -1
- package/LICENSE +1 -1
- package/NOTICE +1 -1
- package/chrome.js +10 -6
- package/chromium.js +75 -27
- package/devtools/CDPConnection.js +9 -4
- package/devtools/networkinterceptor.js +88 -0
- package/edge.js +8 -6
- package/example/google_search.js +1 -1
- package/firefox.js +39 -17
- package/http/index.js +13 -14
- package/http/util.js +14 -20
- package/index.js +26 -13
- package/io/index.js +58 -55
- package/io/zip.js +1 -3
- package/lib/atoms/find-elements.js +2 -2
- package/lib/atoms/get-attribute.js +25 -25
- package/lib/by.js +8 -9
- package/lib/capabilities.js +1 -1
- package/lib/command.js +6 -11
- package/lib/error.js +24 -19
- package/lib/http.js +64 -156
- package/lib/input.js +1 -1
- package/lib/promise.js +12 -17
- package/lib/proxy.js +15 -5
- package/lib/session.js +1 -1
- package/lib/webdriver.js +422 -176
- package/net/index.js +14 -7
- package/net/portprober.js +5 -4
- package/opera.js +19 -22
- package/package.json +1 -2
- package/remote/index.js +13 -10
- package/testing/index.js +16 -10
package/net/index.js
CHANGED
|
@@ -35,10 +35,10 @@ function getLoInterface() {
|
|
|
35
35
|
* @param {string} family The IP family (IPv4 or IPv6). Defaults to IPv4.
|
|
36
36
|
* @return {(string|undefined)} The located IP address or undefined.
|
|
37
37
|
*/
|
|
38
|
-
function
|
|
38
|
+
function getIPAddress(loopback, family) {
|
|
39
39
|
let interfaces
|
|
40
40
|
if (loopback) {
|
|
41
|
-
|
|
41
|
+
const lo = getLoInterface()
|
|
42
42
|
interfaces = lo ? [lo] : null
|
|
43
43
|
}
|
|
44
44
|
interfaces = interfaces || os.networkInterfaces()
|
|
@@ -63,8 +63,8 @@ function getAddress(loopback, family) {
|
|
|
63
63
|
* @param {string=} family The IP family to retrieve. Defaults to "IPv4".
|
|
64
64
|
* @return {(string|undefined)} The IP address or undefined if not available.
|
|
65
65
|
*/
|
|
66
|
-
|
|
67
|
-
return
|
|
66
|
+
function getAddress(family = 'IPv4') {
|
|
67
|
+
return getIPAddress(false, family)
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
/**
|
|
@@ -72,8 +72,8 @@ exports.getAddress = function (family = 'IPv4') {
|
|
|
72
72
|
* @param {string=} family The IP family to retrieve. Defaults to "IPv4".
|
|
73
73
|
* @return {(string|undefined)} The IP address or undefined if not available.
|
|
74
74
|
*/
|
|
75
|
-
|
|
76
|
-
return
|
|
75
|
+
function getLoopbackAddress(family = 'IPv4') {
|
|
76
|
+
return getIPAddress(true, family)
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
/**
|
|
@@ -84,7 +84,7 @@ exports.getLoopbackAddress = function (family = 'IPv4') {
|
|
|
84
84
|
* @return {{host: string, port: ?number}} A host and port. If no port is
|
|
85
85
|
* present in the argument `hostport`, port is null.
|
|
86
86
|
*/
|
|
87
|
-
|
|
87
|
+
function splitHostAndPort(hostport) {
|
|
88
88
|
let lastIndex = hostport.lastIndexOf(':')
|
|
89
89
|
if (lastIndex < 0) {
|
|
90
90
|
return { host: hostport, port: null }
|
|
@@ -105,3 +105,10 @@ exports.splitHostAndPort = function (hostport) {
|
|
|
105
105
|
let port = parseInt(hostport.slice(lastIndex + 1), 10)
|
|
106
106
|
return { host, port }
|
|
107
107
|
}
|
|
108
|
+
|
|
109
|
+
// PUBLIC API
|
|
110
|
+
module.exports = {
|
|
111
|
+
splitHostAndPort,
|
|
112
|
+
getLoopbackAddress,
|
|
113
|
+
getAddress,
|
|
114
|
+
}
|
package/net/portprober.js
CHANGED
|
@@ -29,7 +29,7 @@ const net = require('net')
|
|
|
29
29
|
*/
|
|
30
30
|
function isFree(port, opt_host) {
|
|
31
31
|
return new Promise((resolve, reject) => {
|
|
32
|
-
|
|
32
|
+
const server = net.createServer().on('error', function (e) {
|
|
33
33
|
if (e.code === 'EADDRINUSE' || e.code === 'EACCES') {
|
|
34
34
|
resolve(false)
|
|
35
35
|
} else {
|
|
@@ -70,6 +70,7 @@ function findFreePort(opt_host) {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
// PUBLIC API
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
module.exports = {
|
|
74
|
+
findFreePort,
|
|
75
|
+
isFree,
|
|
76
|
+
}
|
package/opera.js
CHANGED
|
@@ -72,12 +72,12 @@
|
|
|
72
72
|
|
|
73
73
|
'use strict'
|
|
74
74
|
|
|
75
|
-
const http = require('./http')
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
75
|
+
const http = require('./http')
|
|
76
|
+
const io = require('./io')
|
|
77
|
+
const capabilities = require('./lib/capabilities')
|
|
78
|
+
const Symbols = require('./lib/symbols')
|
|
79
|
+
const webdriver = require('./lib/webdriver')
|
|
80
|
+
const remote = require('./remote')
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
83
|
* Name of the OperaDriver executable.
|
|
@@ -153,7 +153,7 @@ class ServiceBuilder extends remote.DriverService.Builder {
|
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
/** @type {remote.DriverService} */
|
|
156
|
-
|
|
156
|
+
let defaultService = null
|
|
157
157
|
|
|
158
158
|
/**
|
|
159
159
|
* Sets the default service to use for new OperaDriver instances.
|
|
@@ -187,7 +187,7 @@ function getDefaultService() {
|
|
|
187
187
|
* @type {string}
|
|
188
188
|
* @const
|
|
189
189
|
*/
|
|
190
|
-
|
|
190
|
+
const OPTIONS_CAPABILITY_KEY = 'chromeOptions'
|
|
191
191
|
|
|
192
192
|
/**
|
|
193
193
|
* Class for managing {@linkplain Driver OperaDriver} specific options.
|
|
@@ -217,8 +217,8 @@ class Options {
|
|
|
217
217
|
* @return {!Options} The OperaDriver options.
|
|
218
218
|
*/
|
|
219
219
|
static fromCapabilities(caps) {
|
|
220
|
-
|
|
221
|
-
|
|
220
|
+
let options
|
|
221
|
+
const o = caps.get(OPTIONS_CAPABILITY_KEY)
|
|
222
222
|
if (o instanceof Options) {
|
|
223
223
|
options = o
|
|
224
224
|
} else if (o) {
|
|
@@ -249,8 +249,8 @@ class Options {
|
|
|
249
249
|
* @param {...(string|!Array.<string>)} var_args The arguments to add.
|
|
250
250
|
* @return {!Options} A self reference.
|
|
251
251
|
*/
|
|
252
|
-
addArguments(var_args) {
|
|
253
|
-
this.args_ = this.args_.concat.apply(this.args_,
|
|
252
|
+
addArguments(...var_args) {
|
|
253
|
+
this.args_ = this.args_.concat.apply(this.args_, var_args)
|
|
254
254
|
return this
|
|
255
255
|
}
|
|
256
256
|
|
|
@@ -262,11 +262,8 @@ class Options {
|
|
|
262
262
|
* extensions to add.
|
|
263
263
|
* @return {!Options} A self reference.
|
|
264
264
|
*/
|
|
265
|
-
addExtensions(var_args) {
|
|
266
|
-
this.extensions_ = this.extensions_.concat.apply(
|
|
267
|
-
this.extensions_,
|
|
268
|
-
arguments
|
|
269
|
-
)
|
|
265
|
+
addExtensions(...var_args) {
|
|
266
|
+
this.extensions_ = this.extensions_.concat.apply(this.extensions_, var_args)
|
|
270
267
|
return this
|
|
271
268
|
}
|
|
272
269
|
|
|
@@ -358,11 +355,11 @@ class Driver extends webdriver.WebDriver {
|
|
|
358
355
|
* @return {!Driver} A new driver instance.
|
|
359
356
|
*/
|
|
360
357
|
static createSession(opt_config, opt_service) {
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
358
|
+
const service = opt_service || getDefaultService()
|
|
359
|
+
const client = service.start().then((url) => new http.HttpClient(url))
|
|
360
|
+
const executor = new http.Executor(client)
|
|
364
361
|
|
|
365
|
-
|
|
362
|
+
let caps =
|
|
366
363
|
opt_config instanceof Options
|
|
367
364
|
? opt_config.toCapabilities()
|
|
368
365
|
: opt_config || capabilities.Capabilities.opera()
|
|
@@ -370,7 +367,7 @@ class Driver extends webdriver.WebDriver {
|
|
|
370
367
|
// On Linux, the OperaDriver does not look for Opera on the PATH, so we
|
|
371
368
|
// must explicitly find it. See: operachromiumdriver #9.
|
|
372
369
|
if (process.platform === 'linux') {
|
|
373
|
-
|
|
370
|
+
const options = Options.fromCapabilities(caps)
|
|
374
371
|
if (!options.binary_) {
|
|
375
372
|
let exe = io.findInPath('opera', true)
|
|
376
373
|
if (!exe) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "selenium-webdriver",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.1",
|
|
4
4
|
"description": "The official WebDriver JavaScript bindings from the Selenium project",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"jszip": "^3.6.0",
|
|
27
|
-
"rimraf": "^3.0.2",
|
|
28
27
|
"tmp": "^0.2.1",
|
|
29
28
|
"ws": ">=7.4.6"
|
|
30
29
|
},
|
package/remote/index.js
CHANGED
|
@@ -33,12 +33,12 @@ const portprober = require('../net/portprober')
|
|
|
33
33
|
/**
|
|
34
34
|
* @typedef {(string|!Array<string|number|!stream.Stream|null|undefined>)}
|
|
35
35
|
*/
|
|
36
|
-
|
|
36
|
+
let StdIoOptions // eslint-disable-line
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* @typedef {(string|!IThenable<string>)}
|
|
40
40
|
*/
|
|
41
|
-
|
|
41
|
+
let CommandLineFlag // eslint-disable-line
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* A record object that defines the configuration options for a DriverService
|
|
@@ -196,8 +196,8 @@ class DriverService {
|
|
|
196
196
|
return this.address_
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
-
|
|
200
|
-
|
|
199
|
+
const timeout = opt_timeoutMs || DriverService.DEFAULT_START_TIMEOUT_MS
|
|
200
|
+
const self = this
|
|
201
201
|
|
|
202
202
|
let resolveCommand
|
|
203
203
|
this.command_ = new Promise((resolve) => (resolveCommand = resolve))
|
|
@@ -464,7 +464,7 @@ class SeleniumServer extends DriverService {
|
|
|
464
464
|
throw Error('Path to the Selenium jar not specified')
|
|
465
465
|
}
|
|
466
466
|
|
|
467
|
-
|
|
467
|
+
const options = opt_options || {}
|
|
468
468
|
|
|
469
469
|
if (options.port < 0) {
|
|
470
470
|
throw Error('Port must be >= 0: ' + options.port)
|
|
@@ -567,7 +567,7 @@ SeleniumServer.Options = class {
|
|
|
567
567
|
* When a file path on the local machine running this script is entered with
|
|
568
568
|
* {@link webdriver.WebElement#sendKeys WebElement#sendKeys}, this file detector
|
|
569
569
|
* will transfer the specified file to the Selenium server's host; the sendKeys
|
|
570
|
-
* command will be updated to use the
|
|
570
|
+
* command will be updated to use the transferred file's path.
|
|
571
571
|
*
|
|
572
572
|
* __Note:__ This class depends on a non-standard command supported on the
|
|
573
573
|
* Java Selenium server. The file detector will fail if used with a server that
|
|
@@ -618,7 +618,10 @@ class FileDetector extends input.FileDetector {
|
|
|
618
618
|
|
|
619
619
|
// PUBLIC API
|
|
620
620
|
|
|
621
|
-
exports
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
621
|
+
module.exports = {
|
|
622
|
+
DriverService,
|
|
623
|
+
FileDetector,
|
|
624
|
+
SeleniumServer,
|
|
625
|
+
// Exported for API docs.
|
|
626
|
+
ServiceOptions,
|
|
627
|
+
}
|
package/testing/index.js
CHANGED
|
@@ -40,7 +40,7 @@ const ie = require('../ie')
|
|
|
40
40
|
const remote = require('../remote')
|
|
41
41
|
const safari = require('../safari')
|
|
42
42
|
const opera = require('../opera')
|
|
43
|
-
const { Browser } = require('../lib/capabilities')
|
|
43
|
+
const { Browser, Capabilities } = require('../lib/capabilities')
|
|
44
44
|
const { Builder } = require('../index')
|
|
45
45
|
|
|
46
46
|
/**
|
|
@@ -89,7 +89,7 @@ function warn(msg) {
|
|
|
89
89
|
* Extracts the browsers for a test suite to target from the `SELENIUM_BROWSER`
|
|
90
90
|
* environment variable.
|
|
91
91
|
*
|
|
92
|
-
* @return {
|
|
92
|
+
* @return {{name: string, version: string, platform: string}[]} the browsers to target.
|
|
93
93
|
*/
|
|
94
94
|
function getBrowsersToTestFromEnv() {
|
|
95
95
|
let browsers = process.env['SELENIUM_BROWSER']
|
|
@@ -236,8 +236,7 @@ function init(force = false) {
|
|
|
236
236
|
}
|
|
237
237
|
|
|
238
238
|
const TARGET_MAP = /** !WeakMap<!Environment, !TargetBrowser> */ new WeakMap()
|
|
239
|
-
const URL_MAP =
|
|
240
|
-
/** !WeakMap<!Environment, ?(string|remote.SeleniumServer)> */ new WeakMap()
|
|
239
|
+
const URL_MAP = /** !WeakMap<!Environment, ?(string|remote.SeleniumServer)> */ new WeakMap()
|
|
241
240
|
|
|
242
241
|
/**
|
|
243
242
|
* Defines the environment a {@linkplain suite test suite} is running against.
|
|
@@ -250,9 +249,9 @@ class Environment {
|
|
|
250
249
|
* Selenium server to test against.
|
|
251
250
|
*/
|
|
252
251
|
constructor(browser, url = undefined) {
|
|
253
|
-
browser = /** @type {!TargetBrowser} */ (
|
|
254
|
-
Object.
|
|
255
|
-
)
|
|
252
|
+
browser = /** @type {!TargetBrowser} */ (Object.seal(
|
|
253
|
+
Object.assign({}, browser)
|
|
254
|
+
))
|
|
256
255
|
|
|
257
256
|
TARGET_MAP.set(this, browser)
|
|
258
257
|
URL_MAP.set(this, url || null)
|
|
@@ -273,7 +272,7 @@ class Environment {
|
|
|
273
272
|
* @return {function(): boolean} a new predicate function.
|
|
274
273
|
*/
|
|
275
274
|
browsers(...browsersToIgnore) {
|
|
276
|
-
return () => browsersToIgnore.indexOf(this.browser.name)
|
|
275
|
+
return () => browsersToIgnore.indexOf(this.browser.name) !== -1
|
|
277
276
|
}
|
|
278
277
|
|
|
279
278
|
/**
|
|
@@ -287,12 +286,19 @@ class Environment {
|
|
|
287
286
|
const builder = new Builder()
|
|
288
287
|
builder.disableEnvironmentOverrides()
|
|
289
288
|
|
|
289
|
+
|
|
290
|
+
|
|
290
291
|
const realBuild = builder.build
|
|
291
292
|
builder.build = function () {
|
|
292
|
-
builder.forBrowser(browser.name, browser.version, browser.platform)
|
|
293
|
+
builder.forBrowser(browser.name, browser.version, browser.platform);
|
|
294
|
+
|
|
293
295
|
|
|
294
296
|
if (browser.capabilities) {
|
|
295
|
-
builder.getCapabilities().merge(browser.capabilities)
|
|
297
|
+
builder.getCapabilities().merge(browser.capabilities);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
if(browser.name === 'firefox') {
|
|
301
|
+
builder.setCapability('moz:debuggerAddress', true);
|
|
296
302
|
}
|
|
297
303
|
|
|
298
304
|
if (typeof urlOrServer === 'string') {
|