webdriver 5.19.0 → 5.22.4
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/README.md +12 -0
- package/build/constants.js +3 -1
- package/build/request.js +15 -5
- package/package.json +5 -4
- package/webdriver.d.ts +6 -1
package/README.md
CHANGED
|
@@ -106,3 +106,15 @@ Count of request retries to the Selenium server.
|
|
|
106
106
|
|
|
107
107
|
Type: `Number`<br>
|
|
108
108
|
Default: *2*
|
|
109
|
+
|
|
110
|
+
### transformRequest
|
|
111
|
+
Function intercepting [HTTP request options](https://github.com/request/request#requestoptions-callback) before a WebDriver request is made
|
|
112
|
+
|
|
113
|
+
Type: `(RequestOptions) => RequestOptions`<br>
|
|
114
|
+
Default: *none*
|
|
115
|
+
|
|
116
|
+
### transformResponse
|
|
117
|
+
Function intercepting HTTP response objects after a WebDriver response has arrived
|
|
118
|
+
|
|
119
|
+
Type: `(Response, RequestOptions) => Response`<br>
|
|
120
|
+
Default: *none*
|
package/build/constants.js
CHANGED
package/build/request.js
CHANGED
|
@@ -62,9 +62,14 @@ class WebDriverRequest extends _events.default {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
makeRequest(options, sessionId) {
|
|
65
|
-
|
|
65
|
+
let fullRequestOptions = Object.assign({}, this.defaultOptions, this._createOptions(options, sessionId));
|
|
66
|
+
|
|
67
|
+
if (typeof options.transformRequest === 'function') {
|
|
68
|
+
fullRequestOptions = options.transformRequest(fullRequestOptions);
|
|
69
|
+
}
|
|
70
|
+
|
|
66
71
|
this.emit('request', fullRequestOptions);
|
|
67
|
-
return this._request(fullRequestOptions, options.connectionRetryCount);
|
|
72
|
+
return this._request(fullRequestOptions, options.transformResponse, options.connectionRetryCount);
|
|
68
73
|
}
|
|
69
74
|
|
|
70
75
|
_createOptions(options, sessionId) {
|
|
@@ -100,14 +105,19 @@ class WebDriverRequest extends _events.default {
|
|
|
100
105
|
return requestOptions;
|
|
101
106
|
}
|
|
102
107
|
|
|
103
|
-
_request(fullRequestOptions, totalRetryCount = 0, retryCount = 0) {
|
|
108
|
+
_request(fullRequestOptions, transformResponse, totalRetryCount = 0, retryCount = 0) {
|
|
104
109
|
log.info(`[${fullRequestOptions.method}] ${fullRequestOptions.uri.href}`);
|
|
105
110
|
|
|
106
111
|
if (fullRequestOptions.body && Object.keys(fullRequestOptions.body).length) {
|
|
107
112
|
log.info('DATA', fullRequestOptions.body);
|
|
108
113
|
}
|
|
109
114
|
|
|
110
|
-
return new Promise((resolve, reject) => (0, _request.default)(fullRequestOptions, (err, response
|
|
115
|
+
return new Promise((resolve, reject) => (0, _request.default)(fullRequestOptions, (err, response) => {
|
|
116
|
+
if (typeof transformResponse === 'function') {
|
|
117
|
+
response = transformResponse(response, fullRequestOptions);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
let body = response && response.body;
|
|
111
121
|
const error = err || (0, _utils.getErrorFromResponseBody)(body);
|
|
112
122
|
|
|
113
123
|
if (this.isHubCommand) {
|
|
@@ -151,7 +161,7 @@ class WebDriverRequest extends _events.default {
|
|
|
151
161
|
log.warn('Request failed due to', error.message);
|
|
152
162
|
log.info(`Retrying ${retryCount}/${totalRetryCount}`);
|
|
153
163
|
|
|
154
|
-
this._request(fullRequestOptions, totalRetryCount, retryCount).then(resolve, reject);
|
|
164
|
+
this._request(fullRequestOptions, transformResponse, totalRetryCount, retryCount).then(resolve, reject);
|
|
155
165
|
}));
|
|
156
166
|
}
|
|
157
167
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webdriver",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.22.4",
|
|
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,12 +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/protocols": "5.22.1",
|
|
36
37
|
"@wdio/utils": "5.18.6",
|
|
37
38
|
"lodash.merge": "^4.6.1",
|
|
38
39
|
"request": "^2.83.0"
|
|
39
40
|
},
|
|
40
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "1a093237fe927a5db470f8a839b342df02913804"
|
|
41
42
|
}
|
package/webdriver.d.ts
CHANGED
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
10
10
|
/// <reference types="node"/>
|
|
11
11
|
|
|
12
|
+
declare type HTTPRequestOptions = import('request').CoreOptions;
|
|
13
|
+
declare type HTTPResponse = import('request').Response;
|
|
14
|
+
|
|
12
15
|
declare namespace WebDriver {
|
|
13
16
|
type PageLoadingStrategy = 'none' | 'eager' | 'normal';
|
|
14
17
|
type ProxyTypes = 'pac' | 'noproxy' | 'autodetect' | 'system' | 'manual';
|
|
@@ -370,6 +373,8 @@ declare namespace WebDriver {
|
|
|
370
373
|
headers?: {
|
|
371
374
|
[name: string]: string;
|
|
372
375
|
};
|
|
376
|
+
transformRequest?: (requestOptions: HTTPRequestOptions) => HTTPRequestOptions;
|
|
377
|
+
transformResponse?: (response: HTTPResponse, requestOptions: HTTPRequestOptions) => HTTPResponse;
|
|
373
378
|
}
|
|
374
379
|
|
|
375
380
|
interface AttachSessionOptions extends Options {
|
|
@@ -575,7 +580,7 @@ declare namespace WebDriver {
|
|
|
575
580
|
* 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.
|
|
576
581
|
* https://w3c.github.io/webdriver/#dfn-switch-to-frame
|
|
577
582
|
*/
|
|
578
|
-
switchToFrame(id: (number|
|
|
583
|
+
switchToFrame(id: (number|object|null)): void;
|
|
579
584
|
|
|
580
585
|
/**
|
|
581
586
|
* [webdriver]
|