webdriver 6.0.16 → 6.1.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 +15 -1
- package/build/constants.js +1 -1
- package/build/request.js +34 -21
- package/build/utils.js +6 -5
- package/package.json +7 -7
- package/webdriver.d.ts +7 -2
package/README.md
CHANGED
|
@@ -99,7 +99,7 @@ Default: `null`
|
|
|
99
99
|
Timeout for any WebDriver request to a driver or grid.
|
|
100
100
|
|
|
101
101
|
Type: `Number`<br>
|
|
102
|
-
Default: *
|
|
102
|
+
Default: *120000*
|
|
103
103
|
|
|
104
104
|
### connectionRetryCount
|
|
105
105
|
Count of request retries to the Selenium server.
|
|
@@ -107,6 +107,20 @@ Count of request retries to the Selenium server.
|
|
|
107
107
|
Type: `Number`<br>
|
|
108
108
|
Default: *2*
|
|
109
109
|
|
|
110
|
+
### agent
|
|
111
|
+
|
|
112
|
+
Allows you to use a custom` http`/`https`/`http2` [agent](https://www.npmjs.com/package/got#agent) to make requests.
|
|
113
|
+
|
|
114
|
+
Type: `Object`<br>
|
|
115
|
+
Default:
|
|
116
|
+
|
|
117
|
+
```js
|
|
118
|
+
{
|
|
119
|
+
http: new http.Agent({ keepAlive: true }),
|
|
120
|
+
https: new https.Agent({ keepAlive: true })
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
110
124
|
### transformRequest
|
|
111
125
|
Function intercepting [HTTP request options](https://github.com/sindresorhus/got#options) before a WebDriver request is made
|
|
112
126
|
|
package/build/constants.js
CHANGED
package/build/request.js
CHANGED
|
@@ -76,7 +76,7 @@ class WebDriverRequest extends _events.default {
|
|
|
76
76
|
|
|
77
77
|
_createOptions(options, sessionId) {
|
|
78
78
|
const requestOptions = {
|
|
79
|
-
agent: options.agent || agents
|
|
79
|
+
agent: options.agent || agents,
|
|
80
80
|
headers: _objectSpread({}, DEFAULT_HEADERS, {}, typeof options.headers === 'object' ? options.headers : {}),
|
|
81
81
|
searchParams: typeof options.queryParams === 'object' ? options.queryParams : {},
|
|
82
82
|
timeout: options.connectionRetryTimeout
|
|
@@ -95,7 +95,8 @@ class WebDriverRequest extends _events.default {
|
|
|
95
95
|
requestOptions.uri = new URL(`${options.protocol}://` + `${options.hostname}:${options.port}` + (this.isHubCommand ? this.endpoint : _path.default.join(options.path, this.endpoint.replace(':sessionId', sessionId))));
|
|
96
96
|
|
|
97
97
|
if (this.endpoint === '/session' && options.user && options.key) {
|
|
98
|
-
requestOptions.
|
|
98
|
+
requestOptions.username = options.user;
|
|
99
|
+
requestOptions.password = options.key;
|
|
99
100
|
}
|
|
100
101
|
|
|
101
102
|
requestOptions.rejectUnauthorized = !(process.env.STRICT_SSL === 'false' || process.env.strict_ssl === 'false');
|
|
@@ -109,7 +110,36 @@ class WebDriverRequest extends _events.default {
|
|
|
109
110
|
log.info('DATA', (0, _utils.transformCommandLogResult)(fullRequestOptions.json));
|
|
110
111
|
}
|
|
111
112
|
|
|
112
|
-
|
|
113
|
+
const retry = (error, msg) => {
|
|
114
|
+
if (retryCount >= totalRetryCount || error.message.includes('invalid session id')) {
|
|
115
|
+
log.error(`Request failed with status ${response.statusCode} due to ${error}`);
|
|
116
|
+
this.emit('response', {
|
|
117
|
+
error
|
|
118
|
+
});
|
|
119
|
+
error.statusCode = response.statusCode;
|
|
120
|
+
error.statusMessage = response.statusMessage;
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
++retryCount;
|
|
125
|
+
this.emit('retry', {
|
|
126
|
+
error,
|
|
127
|
+
retryCount
|
|
128
|
+
});
|
|
129
|
+
log.warn(msg);
|
|
130
|
+
log.info(`Retrying ${retryCount}/${totalRetryCount}`);
|
|
131
|
+
return this._request(fullRequestOptions, transformResponse, totalRetryCount, retryCount);
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
let response = await (0, _got.default)(fullRequestOptions.uri, _objectSpread({}, fullRequestOptions)).catch(err => err);
|
|
135
|
+
|
|
136
|
+
if (response instanceof Error) {
|
|
137
|
+
if (response.code === 'ETIMEDOUT') {
|
|
138
|
+
return retry(response, 'Request timed out! Consider increasing the "connectionRetryTimeout" option.');
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
throw response;
|
|
142
|
+
}
|
|
113
143
|
|
|
114
144
|
if (typeof transformResponse === 'function') {
|
|
115
145
|
response = transformResponse(response, fullRequestOptions);
|
|
@@ -142,24 +172,7 @@ class WebDriverRequest extends _events.default {
|
|
|
142
172
|
throw error;
|
|
143
173
|
}
|
|
144
174
|
|
|
145
|
-
|
|
146
|
-
log.error(`Request failed with status ${response.statusCode} due to ${error}`);
|
|
147
|
-
this.emit('response', {
|
|
148
|
-
error
|
|
149
|
-
});
|
|
150
|
-
error.statusCode = response.statusCode;
|
|
151
|
-
error.statusMessage = response.statusMessage;
|
|
152
|
-
throw error;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
++retryCount;
|
|
156
|
-
this.emit('retry', {
|
|
157
|
-
error,
|
|
158
|
-
retryCount
|
|
159
|
-
});
|
|
160
|
-
log.warn(`Request failed with status ${response.statusCode} due to ${error.message}`);
|
|
161
|
-
log.info(`Retrying ${retryCount}/${totalRetryCount}`);
|
|
162
|
-
return this._request(fullRequestOptions, transformResponse, totalRetryCount, retryCount);
|
|
175
|
+
return retry(error, `Request failed with status ${response.statusCode} due to ${error.message}`);
|
|
163
176
|
}
|
|
164
177
|
|
|
165
178
|
}
|
package/build/utils.js
CHANGED
|
@@ -117,7 +117,7 @@ function getErrorFromResponseBody(body) {
|
|
|
117
117
|
return new Error(body);
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
if (typeof body !== 'object' || !body.value) {
|
|
120
|
+
if (typeof body !== 'object' || !body.value && !body.error) {
|
|
121
121
|
return new Error('unknown error');
|
|
122
122
|
}
|
|
123
123
|
|
|
@@ -126,11 +126,12 @@ function getErrorFromResponseBody(body) {
|
|
|
126
126
|
|
|
127
127
|
class CustomRequestError extends Error {
|
|
128
128
|
constructor(body) {
|
|
129
|
-
|
|
129
|
+
const errorObj = body.value || body;
|
|
130
|
+
super(errorObj.message || errorObj.class || 'unknown error');
|
|
130
131
|
|
|
131
|
-
if (
|
|
132
|
-
this.name =
|
|
133
|
-
} else if (
|
|
132
|
+
if (errorObj.error) {
|
|
133
|
+
this.name = errorObj.error;
|
|
134
|
+
} else if (errorObj.message && errorObj.message.includes('stale element reference')) {
|
|
134
135
|
this.name = 'stale element reference';
|
|
135
136
|
}
|
|
136
137
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webdriver",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.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,15 +30,15 @@
|
|
|
30
30
|
"url": "https://github.com/webdriverio/webdriverio/issues"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@wdio/config": "6.
|
|
33
|
+
"@wdio/config": "6.1.2",
|
|
34
34
|
"@wdio/logger": "6.0.16",
|
|
35
|
-
"@wdio/protocols": "6.
|
|
36
|
-
"@wdio/utils": "6.0
|
|
37
|
-
"got": "^
|
|
35
|
+
"@wdio/protocols": "6.1.2",
|
|
36
|
+
"@wdio/utils": "6.1.0",
|
|
37
|
+
"got": "^11.0.2",
|
|
38
38
|
"lodash.merge": "^4.6.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@types/got": "^9.6.
|
|
41
|
+
"@types/got": "^9.6.10"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "e186dd1169872769741244602b0c68f5932c7d1a"
|
|
44
44
|
}
|
package/webdriver.d.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
11
11
|
/// <reference types="node"/>
|
|
12
12
|
|
|
13
|
-
declare type HTTPRequestOptions = import('got').
|
|
13
|
+
declare type HTTPRequestOptions = import('got').Options;
|
|
14
14
|
declare type HTTPResponse = import('got').Response;
|
|
15
15
|
|
|
16
16
|
declare namespace WebDriver {
|
|
@@ -499,6 +499,11 @@ declare namespace WebDriver {
|
|
|
499
499
|
* Level of logging verbosity.
|
|
500
500
|
*/
|
|
501
501
|
logLevel?: WebDriverLogTypes;
|
|
502
|
+
/**
|
|
503
|
+
* Set specific log levels per logger
|
|
504
|
+
* use 'silent' level to disable logger
|
|
505
|
+
*/
|
|
506
|
+
logLevels?: object;
|
|
502
507
|
/**
|
|
503
508
|
* Timeout for any WebDriver request to a driver or grid.
|
|
504
509
|
*/
|
|
@@ -887,7 +892,7 @@ declare namespace WebDriver {
|
|
|
887
892
|
* The Element Send Keys command scrolls into view the form control element and then sends the provided keys to the element. In case the element is not keyboard-interactable, an element not interactable error is returned.<br><br>The key input state used for input may be cleared mid-way through "typing" by sending the null key, which is U+E000 (NULL).
|
|
888
893
|
* https://w3c.github.io/webdriver/#dfn-element-send-keys
|
|
889
894
|
*/
|
|
890
|
-
elementSendKeys(elementId: string, text: string
|
|
895
|
+
elementSendKeys(elementId: string, text: string): void;
|
|
891
896
|
|
|
892
897
|
/**
|
|
893
898
|
* [webdriver]
|