@appium/base-driver 9.4.3 → 9.5.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/README.md +14 -7
- package/build/lib/basedriver/capabilities.d.ts +1 -1
- package/build/lib/basedriver/capabilities.d.ts.map +1 -1
- package/build/lib/basedriver/commands/bidi.d.ts +6 -0
- package/build/lib/basedriver/commands/bidi.d.ts.map +1 -0
- package/build/lib/basedriver/commands/bidi.js +22 -0
- package/build/lib/basedriver/commands/bidi.js.map +1 -0
- package/build/lib/basedriver/commands/index.d.ts +1 -0
- package/build/lib/basedriver/commands/index.d.ts.map +1 -1
- package/build/lib/basedriver/commands/index.js +1 -0
- package/build/lib/basedriver/commands/index.js.map +1 -1
- package/build/lib/basedriver/core.d.ts +12 -0
- package/build/lib/basedriver/core.d.ts.map +1 -1
- package/build/lib/basedriver/core.js +59 -1
- package/build/lib/basedriver/core.js.map +1 -1
- package/build/lib/basedriver/driver.d.ts.map +1 -1
- package/build/lib/basedriver/driver.js +3 -3
- package/build/lib/basedriver/driver.js.map +1 -1
- package/build/lib/basedriver/helpers.js +1 -1
- package/build/lib/basedriver/helpers.js.map +1 -1
- package/build/lib/index.d.ts +1 -1
- package/build/lib/index.d.ts.map +1 -1
- package/build/lib/index.js +15 -8
- package/build/lib/index.js.map +1 -1
- package/build/lib/jsonwp-status/status.d.ts +52 -52
- package/build/lib/protocol/bidi-commands.d.ts +31 -0
- package/build/lib/protocol/bidi-commands.d.ts.map +1 -0
- package/build/lib/protocol/bidi-commands.js +30 -0
- package/build/lib/protocol/bidi-commands.js.map +1 -0
- package/build/lib/protocol/errors.d.ts +13 -0
- package/build/lib/protocol/errors.d.ts.map +1 -1
- package/build/lib/protocol/errors.js +20 -0
- package/build/lib/protocol/errors.js.map +1 -1
- package/lib/basedriver/commands/bidi.ts +37 -0
- package/lib/basedriver/commands/index.ts +1 -0
- package/lib/basedriver/core.ts +79 -3
- package/lib/basedriver/driver.ts +17 -20
- package/lib/basedriver/helpers.js +1 -1
- package/lib/index.js +9 -4
- package/lib/protocol/bidi-commands.js +31 -0
- package/lib/protocol/errors.js +21 -0
- package/package.json +8 -11
package/lib/basedriver/driver.ts
CHANGED
|
@@ -37,7 +37,7 @@ export class BaseDriver<
|
|
|
37
37
|
Settings extends StringRecord = StringRecord,
|
|
38
38
|
CreateResult = DefaultCreateSessionResult<C>,
|
|
39
39
|
DeleteResult = DefaultDeleteSessionResult,
|
|
40
|
-
SessionData extends StringRecord = StringRecord
|
|
40
|
+
SessionData extends StringRecord = StringRecord,
|
|
41
41
|
>
|
|
42
42
|
extends DriverCore<C, Settings>
|
|
43
43
|
implements Driver<C, CArgs, Settings, CreateResult, DeleteResult, SessionData>
|
|
@@ -55,7 +55,6 @@ export class BaseDriver<
|
|
|
55
55
|
super(opts, shouldValidateCaps);
|
|
56
56
|
|
|
57
57
|
this.caps = {} as DriverCaps<C>;
|
|
58
|
-
|
|
59
58
|
this.cliArgs = {} as CArgs & ServerArgs;
|
|
60
59
|
}
|
|
61
60
|
|
|
@@ -114,7 +113,7 @@ export class BaseDriver<
|
|
|
114
113
|
// This is needed to prevent memory leaks
|
|
115
114
|
this.eventEmitter.removeListener(
|
|
116
115
|
ON_UNEXPECTED_SHUTDOWN_EVENT,
|
|
117
|
-
unexpectedShutdownListener
|
|
116
|
+
unexpectedShutdownListener,
|
|
118
117
|
);
|
|
119
118
|
unexpectedShutdownListener = null;
|
|
120
119
|
}
|
|
@@ -147,7 +146,7 @@ export class BaseDriver<
|
|
|
147
146
|
}
|
|
148
147
|
|
|
149
148
|
async startUnexpectedShutdown(
|
|
150
|
-
err: Error = new errors.NoSuchDriverError('The driver was unexpectedly shut down!')
|
|
149
|
+
err: Error = new errors.NoSuchDriverError('The driver was unexpectedly shut down!'),
|
|
151
150
|
) {
|
|
152
151
|
this.eventEmitter.emit(ON_UNEXPECTED_SHUTDOWN_EVENT, err); // allow others to listen for this
|
|
153
152
|
this.shutdownUnexpectedly = true;
|
|
@@ -170,7 +169,7 @@ export class BaseDriver<
|
|
|
170
169
|
this.noCommandTimer = setTimeout(async () => {
|
|
171
170
|
this.log.warn(
|
|
172
171
|
`Shutting down because we waited ` +
|
|
173
|
-
`${this.newCommandTimeoutMs / 1000.0} seconds for a command
|
|
172
|
+
`${this.newCommandTimeoutMs / 1000.0} seconds for a command`,
|
|
174
173
|
);
|
|
175
174
|
const errorMessage =
|
|
176
175
|
`New Command Timeout of ` +
|
|
@@ -234,23 +233,23 @@ export class BaseDriver<
|
|
|
234
233
|
w3cCapabilities2?: W3CDriverCaps<C>,
|
|
235
234
|
w3cCapabilities?: W3CDriverCaps<C>,
|
|
236
235
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
237
|
-
driverData?: DriverData[]
|
|
236
|
+
driverData?: DriverData[],
|
|
238
237
|
): Promise<CreateResult> {
|
|
239
238
|
if (this.sessionId !== null) {
|
|
240
239
|
throw new errors.SessionNotCreatedError(
|
|
241
|
-
'Cannot create a new session while one is in progress'
|
|
240
|
+
'Cannot create a new session while one is in progress',
|
|
242
241
|
);
|
|
243
242
|
}
|
|
244
243
|
|
|
245
244
|
this.log.debug();
|
|
246
245
|
|
|
247
246
|
const originalCaps = _.cloneDeep(
|
|
248
|
-
[w3cCapabilities, w3cCapabilities1, w3cCapabilities2].find(isW3cCaps)
|
|
247
|
+
[w3cCapabilities, w3cCapabilities1, w3cCapabilities2].find(isW3cCaps),
|
|
249
248
|
);
|
|
250
249
|
if (!originalCaps) {
|
|
251
250
|
throw new errors.SessionNotCreatedError(
|
|
252
251
|
'Appium only supports W3C-style capability objects. ' +
|
|
253
|
-
'Your client is sending an older capabilities format. Please update your client library.'
|
|
252
|
+
'Your client is sending an older capabilities format. Please update your client library.',
|
|
254
253
|
);
|
|
255
254
|
}
|
|
256
255
|
|
|
@@ -258,7 +257,7 @@ export class BaseDriver<
|
|
|
258
257
|
|
|
259
258
|
this.originalCaps = originalCaps;
|
|
260
259
|
this.log.debug(
|
|
261
|
-
`Creating session with W3C capabilities: ${JSON.stringify(originalCaps, null, 2)}
|
|
260
|
+
`Creating session with W3C capabilities: ${JSON.stringify(originalCaps, null, 2)}`,
|
|
262
261
|
);
|
|
263
262
|
|
|
264
263
|
let caps: DriverCaps<C>;
|
|
@@ -266,7 +265,7 @@ export class BaseDriver<
|
|
|
266
265
|
caps = processCapabilities(
|
|
267
266
|
originalCaps,
|
|
268
267
|
this._desiredCapConstraints,
|
|
269
|
-
this.shouldValidateCaps
|
|
268
|
+
this.shouldValidateCaps,
|
|
270
269
|
) as DriverCaps<C>;
|
|
271
270
|
caps = fixCaps(caps, this._desiredCapConstraints, this.log) as DriverCaps<C>;
|
|
272
271
|
} catch (e) {
|
|
@@ -287,7 +286,7 @@ export class BaseDriver<
|
|
|
287
286
|
throw new Error(
|
|
288
287
|
"The 'noReset' and 'fullReset' capabilities are mutually " +
|
|
289
288
|
'exclusive and should not both be set to true. You ' +
|
|
290
|
-
"probably meant to just use 'fullReset' on its own"
|
|
289
|
+
"probably meant to just use 'fullReset' on its own",
|
|
291
290
|
);
|
|
292
291
|
}
|
|
293
292
|
if (this.opts.noReset === true) {
|
|
@@ -354,9 +353,7 @@ export class BaseDriver<
|
|
|
354
353
|
logExtraCaps(caps: Capabilities<C>) {
|
|
355
354
|
const extraCaps = _.difference(_.keys(caps), _.keys(this._desiredCapConstraints));
|
|
356
355
|
if (extraCaps.length) {
|
|
357
|
-
this.log.warn(
|
|
358
|
-
`The following provided capabilities were not recognized by this driver:`
|
|
359
|
-
);
|
|
356
|
+
this.log.warn(`The following provided capabilities were not recognized by this driver:`);
|
|
360
357
|
for (const cap of extraCaps) {
|
|
361
358
|
this.log.warn(` ${cap}`);
|
|
362
359
|
}
|
|
@@ -371,11 +368,11 @@ export class BaseDriver<
|
|
|
371
368
|
try {
|
|
372
369
|
validateCaps(caps, this._desiredCapConstraints);
|
|
373
370
|
} catch (e) {
|
|
374
|
-
this.log.
|
|
371
|
+
throw this.log.errorWithException(
|
|
375
372
|
new errors.SessionNotCreatedError(
|
|
376
373
|
`The desiredCapabilities object was not valid for the ` +
|
|
377
|
-
`following reason(s): ${e.message}
|
|
378
|
-
)
|
|
374
|
+
`following reason(s): ${e.message}`,
|
|
375
|
+
),
|
|
379
376
|
);
|
|
380
377
|
}
|
|
381
378
|
|
|
@@ -386,14 +383,14 @@ export class BaseDriver<
|
|
|
386
383
|
|
|
387
384
|
async updateSettings(newSettings: Settings) {
|
|
388
385
|
if (!this.settings) {
|
|
389
|
-
this.log.
|
|
386
|
+
throw this.log.errorWithException('Cannot update settings; settings object not found');
|
|
390
387
|
}
|
|
391
388
|
return await this.settings.update(newSettings);
|
|
392
389
|
}
|
|
393
390
|
|
|
394
391
|
async getSettings() {
|
|
395
392
|
if (!this.settings) {
|
|
396
|
-
this.log.
|
|
393
|
+
throw this.log.errorWithException('Cannot get settings; settings object not found');
|
|
397
394
|
}
|
|
398
395
|
return this.settings.getSettings();
|
|
399
396
|
}
|
|
@@ -491,7 +491,7 @@ async function unzipApp(zipPath, dstRoot, supportedAppExtensions) {
|
|
|
491
491
|
})
|
|
492
492
|
).sort((a, b) => a.split(path.sep).length - b.split(path.sep).length);
|
|
493
493
|
if (_.isEmpty(sortedBundleItems)) {
|
|
494
|
-
logger.
|
|
494
|
+
throw logger.errorWithException(
|
|
495
495
|
`App unzipped OK, but we could not find any '${supportedAppExtensions}' ` +
|
|
496
496
|
util.pluralize('bundle', supportedAppExtensions.length, false) +
|
|
497
497
|
` in it. Make sure your archive contains at least one package having ` +
|
package/lib/index.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import B from 'bluebird';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
try {
|
|
4
|
+
B.config({
|
|
5
|
+
cancellation: true,
|
|
6
|
+
});
|
|
7
|
+
} catch (ign) {
|
|
8
|
+
// sometimes during testing this somehow gets required twice and results in an error about
|
|
9
|
+
// cancellation not being able to be enabled after promise has been configured
|
|
10
|
+
}
|
|
6
11
|
|
|
7
12
|
// BaseDriver exports
|
|
8
13
|
import {BaseDriver} from './basedriver/driver';
|
|
@@ -11,11 +16,11 @@ export {DeviceSettings} from './basedriver/device-settings';
|
|
|
11
16
|
|
|
12
17
|
export {BaseDriver};
|
|
13
18
|
export default BaseDriver;
|
|
19
|
+
export {MAX_LOG_BODY_LENGTH, DEFAULT_BASE_PATH, PROTOCOLS, W3C_ELEMENT_KEY} from './constants';
|
|
14
20
|
|
|
15
21
|
// MJSONWP exports
|
|
16
22
|
export * from './protocol';
|
|
17
23
|
export {errorFromMJSONWPStatusCode as errorFromCode} from './protocol';
|
|
18
|
-
export {DEFAULT_BASE_PATH, PROTOCOLS, W3C_ELEMENT_KEY} from './constants';
|
|
19
24
|
|
|
20
25
|
// Express exports
|
|
21
26
|
export {STATIC_DIR} from './express/static';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const SUBSCRIPTION_REQUEST_PARAMS = /** @type {const} */ ({
|
|
2
|
+
required: ['events'],
|
|
3
|
+
optional: ['contexts'],
|
|
4
|
+
});
|
|
5
|
+
|
|
6
|
+
const BIDI_COMMANDS = /** @type {const} */ ({
|
|
7
|
+
session: {
|
|
8
|
+
subscribe: {
|
|
9
|
+
command: 'bidiSubscribe',
|
|
10
|
+
params: SUBSCRIPTION_REQUEST_PARAMS,
|
|
11
|
+
},
|
|
12
|
+
unsubscribe: {
|
|
13
|
+
command: 'bidiUnsubscribe',
|
|
14
|
+
params: SUBSCRIPTION_REQUEST_PARAMS,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
browsingContext: {
|
|
18
|
+
navigate: {
|
|
19
|
+
command: 'bidiNavigate',
|
|
20
|
+
params: {
|
|
21
|
+
required: ['context', 'url'],
|
|
22
|
+
optional: ['wait'],
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// TODO add definitions for all bidi commands.
|
|
29
|
+
// spec link: https://w3c.github.io/webdriver-bidi/
|
|
30
|
+
|
|
31
|
+
export {BIDI_COMMANDS};
|
package/lib/protocol/errors.js
CHANGED
|
@@ -28,6 +28,27 @@ export class ProtocolError extends ES6Error {
|
|
|
28
28
|
set stacktrace(value) {
|
|
29
29
|
this._stacktrace = value;
|
|
30
30
|
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Get the Bidi protocol version of an error
|
|
34
|
+
* @param {string|number} id - the id used in the request for which this error forms the response
|
|
35
|
+
* @see https://w3c.github.io/webdriver-bidi/#protocol-definition
|
|
36
|
+
* @returns The object conforming to the shape of a BiDi error response
|
|
37
|
+
*/
|
|
38
|
+
bidiErrObject(id) {
|
|
39
|
+
// if we don't have an id, the client didn't send one, so we have nothing to send back.
|
|
40
|
+
// send back an empty string rather than making something up
|
|
41
|
+
if (_.isNil(id)) {
|
|
42
|
+
id = '';
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
id,
|
|
46
|
+
type: 'error',
|
|
47
|
+
error: this.error,
|
|
48
|
+
stacktrace: this.stacktrace,
|
|
49
|
+
message: this.message,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
31
52
|
}
|
|
32
53
|
|
|
33
54
|
// https://github.com/SeleniumHQ/selenium/blob/176b4a9e3082ac1926f2a436eb346760c37a5998/java/client/src/org/openqa/selenium/remote/ErrorCodes.java#L215
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appium/base-driver",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.5.0",
|
|
4
4
|
"description": "Base driver class for Appium drivers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"automation",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"test:types": "tsd"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@appium/support": "^4.
|
|
48
|
-
"@appium/types": "^0.
|
|
47
|
+
"@appium/support": "^4.2.0",
|
|
48
|
+
"@appium/types": "^0.16.0",
|
|
49
49
|
"@colors/colors": "1.6.0",
|
|
50
50
|
"@types/async-lock": "1.4.2",
|
|
51
51
|
"@types/bluebird": "3.5.42",
|
|
@@ -53,22 +53,22 @@
|
|
|
53
53
|
"@types/lodash": "4.14.202",
|
|
54
54
|
"@types/method-override": "0.0.35",
|
|
55
55
|
"@types/serve-favicon": "2.5.7",
|
|
56
|
-
"async-lock": "1.4.
|
|
56
|
+
"async-lock": "1.4.1",
|
|
57
57
|
"asyncbox": "3.0.0",
|
|
58
|
-
"axios": "1.6.
|
|
58
|
+
"axios": "1.6.3",
|
|
59
59
|
"bluebird": "3.7.2",
|
|
60
60
|
"body-parser": "1.20.2",
|
|
61
61
|
"es6-error": "4.1.1",
|
|
62
62
|
"express": "4.18.2",
|
|
63
63
|
"http-status-codes": "2.3.0",
|
|
64
64
|
"lodash": "4.17.21",
|
|
65
|
-
"lru-cache": "10.0
|
|
65
|
+
"lru-cache": "10.1.0",
|
|
66
66
|
"method-override": "3.0.0",
|
|
67
67
|
"morgan": "1.10.0",
|
|
68
68
|
"path-to-regexp": "6.2.1",
|
|
69
69
|
"serve-favicon": "2.5.0",
|
|
70
70
|
"source-map-support": "0.5.21",
|
|
71
|
-
"type-fest": "
|
|
71
|
+
"type-fest": "4.9.0",
|
|
72
72
|
"validate.js": "0.13.1"
|
|
73
73
|
},
|
|
74
74
|
"optionalDependencies": {
|
|
@@ -81,10 +81,7 @@
|
|
|
81
81
|
"publishConfig": {
|
|
82
82
|
"access": "public"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
85
|
-
"typedoc": {
|
|
86
|
-
"entryPoint": "./lib/index.js"
|
|
87
|
-
},
|
|
84
|
+
"gitHead": "76df4d600dcb7c867c37c3d7d302dc7fcc95ae09",
|
|
88
85
|
"tsd": {
|
|
89
86
|
"directory": "test/types"
|
|
90
87
|
}
|