webdriver 5.21.0 → 5.23.0
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/build/index.js +8 -15
- package/build/request.js +2 -2
- package/build/utils.js +7 -9
- package/package.json +6 -8
- package/webdriver.d.ts +30 -15
package/build/index.js
CHANGED
|
@@ -17,8 +17,6 @@ var _utils = require("@wdio/utils");
|
|
|
17
17
|
|
|
18
18
|
var _config = require("@wdio/config");
|
|
19
19
|
|
|
20
|
-
var _request = _interopRequireDefault(require("./request"));
|
|
21
|
-
|
|
22
20
|
var _constants = require("./constants");
|
|
23
21
|
|
|
24
22
|
var _utils2 = require("./utils");
|
|
@@ -48,7 +46,7 @@ class WebDriver {
|
|
|
48
46
|
const environmentPrototype = (0, _utils2.getEnvironmentVars)(environment);
|
|
49
47
|
const protocolCommands = (0, _utils2.getPrototype)(environment);
|
|
50
48
|
|
|
51
|
-
const prototype = _objectSpread({}, protocolCommands,
|
|
49
|
+
const prototype = _objectSpread(_objectSpread(_objectSpread({}, protocolCommands), environmentPrototype), userPrototype);
|
|
52
50
|
|
|
53
51
|
const monad = (0, _utils.webdriverMonad)(params, modifier, prototype);
|
|
54
52
|
return monad(sessionId, customCommandWrapper);
|
|
@@ -68,25 +66,20 @@ class WebDriver {
|
|
|
68
66
|
const environmentPrototype = (0, _utils2.getEnvironmentVars)(options);
|
|
69
67
|
const protocolCommands = (0, _utils2.getPrototype)(options);
|
|
70
68
|
|
|
71
|
-
const prototype = _objectSpread({}, protocolCommands,
|
|
69
|
+
const prototype = _objectSpread(_objectSpread(_objectSpread({}, protocolCommands), environmentPrototype), userPrototype);
|
|
72
70
|
|
|
73
71
|
const monad = (0, _utils.webdriverMonad)(options, modifier, prototype);
|
|
74
72
|
return monad(options.sessionId, commandWrapper);
|
|
75
73
|
}
|
|
76
74
|
|
|
77
75
|
static async reloadSession(instance) {
|
|
78
|
-
const {
|
|
79
|
-
|
|
80
|
-
jsonwpCaps
|
|
81
|
-
} = instance.options.requestedCapabilities;
|
|
82
|
-
const sessionRequest = new _request.default('POST', '/session', {
|
|
83
|
-
capabilities: w3cCaps,
|
|
84
|
-
desiredCapabilities: jsonwpCaps
|
|
76
|
+
const params = _objectSpread(_objectSpread({}, instance.options), {}, {
|
|
77
|
+
capabilities: instance.requestedCapabilities
|
|
85
78
|
});
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
-
instance.sessionId =
|
|
89
|
-
return
|
|
79
|
+
|
|
80
|
+
const sessionId = await (0, _utils2.startWebDriverSession)(params);
|
|
81
|
+
instance.sessionId = sessionId;
|
|
82
|
+
return sessionId;
|
|
90
83
|
}
|
|
91
84
|
|
|
92
85
|
static get WebDriver() {
|
package/build/request.js
CHANGED
|
@@ -75,7 +75,7 @@ class WebDriverRequest extends _events.default {
|
|
|
75
75
|
_createOptions(options, sessionId) {
|
|
76
76
|
const requestOptions = {
|
|
77
77
|
agent: options.agent || agents[options.protocol],
|
|
78
|
-
headers: _objectSpread({}, DEFAULT_HEADERS,
|
|
78
|
+
headers: _objectSpread(_objectSpread({}, DEFAULT_HEADERS), typeof options.headers === 'object' ? options.headers : {}),
|
|
79
79
|
qs: typeof options.queryParams === 'object' ? options.queryParams : {},
|
|
80
80
|
timeout: options.connectionRetryTimeout
|
|
81
81
|
};
|
|
@@ -83,7 +83,7 @@ class WebDriverRequest extends _events.default {
|
|
|
83
83
|
if (this.body && (Object.keys(this.body).length || this.method === 'POST')) {
|
|
84
84
|
const contentLength = Buffer.byteLength(JSON.stringify(this.body), 'utf8');
|
|
85
85
|
requestOptions.body = this.body;
|
|
86
|
-
requestOptions.headers = _objectSpread({}, requestOptions.headers, {
|
|
86
|
+
requestOptions.headers = _objectSpread(_objectSpread({}, requestOptions.headers), {
|
|
87
87
|
'Content-Length': contentLength
|
|
88
88
|
});
|
|
89
89
|
}
|
package/build/utils.js
CHANGED
|
@@ -46,10 +46,7 @@ async function startWebDriverSession(params) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
const sessionId = response.value.sessionId || response.sessionId;
|
|
49
|
-
params.requestedCapabilities =
|
|
50
|
-
w3cCaps,
|
|
51
|
-
jsonwpCaps
|
|
52
|
-
};
|
|
49
|
+
params.requestedCapabilities = params.capabilities;
|
|
53
50
|
params.capabilities = response.value.capabilities || response.value;
|
|
54
51
|
return sessionId;
|
|
55
52
|
}
|
|
@@ -117,7 +114,7 @@ function getErrorFromResponseBody(body) {
|
|
|
117
114
|
return new Error(body);
|
|
118
115
|
}
|
|
119
116
|
|
|
120
|
-
if (typeof body !== 'object' || !body.value) {
|
|
117
|
+
if (typeof body !== 'object' || !body.value && !body.error) {
|
|
121
118
|
return new Error('unknown error');
|
|
122
119
|
}
|
|
123
120
|
|
|
@@ -126,11 +123,12 @@ function getErrorFromResponseBody(body) {
|
|
|
126
123
|
|
|
127
124
|
class CustomRequestError extends Error {
|
|
128
125
|
constructor(body) {
|
|
129
|
-
|
|
126
|
+
const errorObj = body.value || body;
|
|
127
|
+
super(errorObj.message || errorObj.class || 'unknown error');
|
|
130
128
|
|
|
131
|
-
if (
|
|
132
|
-
this.name =
|
|
133
|
-
} else if (
|
|
129
|
+
if (errorObj.error) {
|
|
130
|
+
this.name = errorObj.error;
|
|
131
|
+
} else if (errorObj.message && errorObj.message.includes('stale element reference')) {
|
|
134
132
|
this.name = 'stale element reference';
|
|
135
133
|
}
|
|
136
134
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webdriver",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.23.0",
|
|
4
4
|
"description": "A Node.js bindings implementation for the W3C WebDriver and Mobile JSONWire Protocol",
|
|
5
5
|
"author": "Christian Bromann <christian@saucelabs.com>",
|
|
6
6
|
"homepage": "https://github.com/webdriverio/webdriverio/tree/master/packages/webdriver",
|
|
@@ -30,15 +30,13 @@
|
|
|
30
30
|
"url": "https://github.com/webdriverio/webdriverio/issues"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@
|
|
33
|
+
"@types/request": "^2.48.4",
|
|
34
|
+
"@wdio/config": "5.22.4",
|
|
34
35
|
"@wdio/logger": "5.16.10",
|
|
35
|
-
"@wdio/protocols": "5.
|
|
36
|
-
"@wdio/utils": "5.
|
|
36
|
+
"@wdio/protocols": "5.22.1",
|
|
37
|
+
"@wdio/utils": "5.23.0",
|
|
37
38
|
"lodash.merge": "^4.6.1",
|
|
38
39
|
"request": "^2.83.0"
|
|
39
40
|
},
|
|
40
|
-
"
|
|
41
|
-
"@types/request": "^2.48.4"
|
|
42
|
-
},
|
|
43
|
-
"gitHead": "ab9345349a58d41f36c504b9925353ab793b696f"
|
|
41
|
+
"gitHead": "a9b8098ad18074e05a72c0458a7845a41a40aa93"
|
|
44
42
|
}
|
package/webdriver.d.ts
CHANGED
|
@@ -364,6 +364,7 @@ declare namespace WebDriver {
|
|
|
364
364
|
[name: string]: string;
|
|
365
365
|
},
|
|
366
366
|
capabilities?: DesiredCapabilities;
|
|
367
|
+
requestedCapabilities?: DesiredCapabilities;
|
|
367
368
|
logLevel?: WebDriverLogTypes;
|
|
368
369
|
logOutput?: string | NodeJS.WritableStream
|
|
369
370
|
connectionRetryTimeout?: number;
|
|
@@ -401,13 +402,8 @@ declare namespace WebDriver {
|
|
|
401
402
|
): Promise<Client>;
|
|
402
403
|
|
|
403
404
|
interface ClientOptions {
|
|
404
|
-
capabilities: DesiredCapabilities;
|
|
405
405
|
isW3C: boolean;
|
|
406
406
|
isChrome: boolean;
|
|
407
|
-
isAndroid: boolean;
|
|
408
|
-
isMobile: boolean;
|
|
409
|
-
isIOS: boolean;
|
|
410
|
-
sessionId: string;
|
|
411
407
|
}
|
|
412
408
|
|
|
413
409
|
// object with no match
|
|
@@ -459,9 +455,28 @@ declare namespace WebDriver {
|
|
|
459
455
|
mjpegScalingFactor?: number,
|
|
460
456
|
}
|
|
461
457
|
|
|
458
|
+
interface BaseClient {
|
|
459
|
+
// id of WebDriver session
|
|
460
|
+
sessionId: string;
|
|
461
|
+
// assigned capabilities by the browser driver / WebDriver server
|
|
462
|
+
capabilities: DesiredCapabilities;
|
|
463
|
+
// original requested capabilities
|
|
464
|
+
requestedCapabilities: DesiredCapabilities;
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* browser flags
|
|
468
|
+
*/
|
|
469
|
+
// true if session runs on a mobile device
|
|
470
|
+
isMobile: boolean;
|
|
471
|
+
// true if mobile session runs on iOS
|
|
472
|
+
isIOS: boolean;
|
|
473
|
+
// true if mobile session runs on Android
|
|
474
|
+
isAndroid: boolean;
|
|
475
|
+
}
|
|
476
|
+
|
|
462
477
|
// generated typings
|
|
463
478
|
// webdriver types
|
|
464
|
-
interface Client {
|
|
479
|
+
interface Client extends BaseClient {
|
|
465
480
|
|
|
466
481
|
/**
|
|
467
482
|
* [webdriver]
|
|
@@ -580,7 +595,7 @@ declare namespace WebDriver {
|
|
|
580
595
|
* The Switch To Frame command is used to select the current top-level browsing context or a child browsing context of the current browsing context to use as the current browsing context for subsequent commands.
|
|
581
596
|
* https://w3c.github.io/webdriver/#dfn-switch-to-frame
|
|
582
597
|
*/
|
|
583
|
-
switchToFrame(id: (number|
|
|
598
|
+
switchToFrame(id: (number|object|null)): void;
|
|
584
599
|
|
|
585
600
|
/**
|
|
586
601
|
* [webdriver]
|
|
@@ -857,7 +872,7 @@ declare namespace WebDriver {
|
|
|
857
872
|
}
|
|
858
873
|
|
|
859
874
|
// appium types
|
|
860
|
-
interface Client {
|
|
875
|
+
interface Client extends BaseClient {
|
|
861
876
|
|
|
862
877
|
/**
|
|
863
878
|
* [appium]
|
|
@@ -1295,7 +1310,7 @@ declare namespace WebDriver {
|
|
|
1295
1310
|
}
|
|
1296
1311
|
|
|
1297
1312
|
// jsonwp types
|
|
1298
|
-
interface Client {
|
|
1313
|
+
interface Client extends BaseClient {
|
|
1299
1314
|
|
|
1300
1315
|
/**
|
|
1301
1316
|
* [jsonwp]
|
|
@@ -1964,7 +1979,7 @@ declare namespace WebDriver {
|
|
|
1964
1979
|
}
|
|
1965
1980
|
|
|
1966
1981
|
// mjsonwp types
|
|
1967
|
-
interface Client {
|
|
1982
|
+
interface Client extends BaseClient {
|
|
1968
1983
|
|
|
1969
1984
|
/**
|
|
1970
1985
|
* [mjsonwp]
|
|
@@ -2031,7 +2046,7 @@ declare namespace WebDriver {
|
|
|
2031
2046
|
}
|
|
2032
2047
|
|
|
2033
2048
|
// chromium types
|
|
2034
|
-
interface Client {
|
|
2049
|
+
interface Client extends BaseClient {
|
|
2035
2050
|
|
|
2036
2051
|
/**
|
|
2037
2052
|
* [chromium]
|
|
@@ -2203,7 +2218,7 @@ declare namespace WebDriver {
|
|
|
2203
2218
|
}
|
|
2204
2219
|
|
|
2205
2220
|
// saucelabs types
|
|
2206
|
-
interface Client {
|
|
2221
|
+
interface Client extends BaseClient {
|
|
2207
2222
|
|
|
2208
2223
|
/**
|
|
2209
2224
|
* [saucelabs]
|
|
@@ -2249,7 +2264,7 @@ declare namespace WebDriver {
|
|
|
2249
2264
|
}
|
|
2250
2265
|
|
|
2251
2266
|
// selenium types
|
|
2252
|
-
interface Client {
|
|
2267
|
+
interface Client extends BaseClient {
|
|
2253
2268
|
|
|
2254
2269
|
/**
|
|
2255
2270
|
* [selenium]
|
|
@@ -2288,11 +2303,11 @@ declare namespace WebDriver {
|
|
|
2288
2303
|
}
|
|
2289
2304
|
|
|
2290
2305
|
|
|
2291
|
-
interface ClientAsync extends AsyncClient { }
|
|
2306
|
+
interface ClientAsync extends AsyncClient, BaseClient { }
|
|
2292
2307
|
}
|
|
2293
2308
|
|
|
2294
2309
|
type AsyncClient = {
|
|
2295
|
-
[K in keyof WebDriver.Client]:
|
|
2310
|
+
[K in keyof Pick<WebDriver.Client, Exclude<keyof WebDriver.Client, keyof WebDriver.BaseClient>>]:
|
|
2296
2311
|
(...args: Parameters<WebDriver.Client[K]>) => Promise<ReturnType<WebDriver.Client[K]>>;
|
|
2297
2312
|
}
|
|
2298
2313
|
|