@appium/base-driver 8.7.2 → 9.0.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/lib/basedriver/capabilities.d.ts +11 -163
- package/build/lib/basedriver/capabilities.d.ts.map +1 -1
- package/build/lib/basedriver/capabilities.js +354 -236
- package/build/lib/basedriver/capabilities.js.map +1 -1
- package/build/lib/basedriver/commands/event.d.ts +7 -6
- package/build/lib/basedriver/commands/event.d.ts.map +1 -1
- package/build/lib/basedriver/commands/event.js +55 -35
- package/build/lib/basedriver/commands/event.js.map +1 -1
- package/build/lib/basedriver/commands/execute.d.ts +7 -6
- package/build/lib/basedriver/commands/execute.d.ts.map +1 -1
- package/build/lib/basedriver/commands/execute.js +66 -58
- package/build/lib/basedriver/commands/execute.js.map +1 -1
- package/build/lib/basedriver/commands/find.d.ts +9 -7
- package/build/lib/basedriver/commands/find.d.ts.map +1 -1
- package/build/lib/basedriver/commands/find.js +102 -54
- package/build/lib/basedriver/commands/find.js.map +1 -1
- package/build/lib/basedriver/commands/index.d.ts +3 -7
- package/build/lib/basedriver/commands/index.d.ts.map +1 -1
- package/build/lib/basedriver/commands/index.js +30 -33
- package/build/lib/basedriver/commands/index.js.map +1 -1
- package/build/lib/basedriver/commands/log.d.ts +8 -9
- package/build/lib/basedriver/commands/log.d.ts.map +1 -1
- package/build/lib/basedriver/commands/log.js +54 -38
- package/build/lib/basedriver/commands/log.js.map +1 -1
- package/build/lib/basedriver/commands/session.d.ts +7 -6
- package/build/lib/basedriver/commands/session.d.ts.map +1 -1
- package/build/lib/basedriver/commands/session.js +46 -39
- package/build/lib/basedriver/commands/session.js.map +1 -1
- package/build/lib/basedriver/commands/settings.d.ts +7 -7
- package/build/lib/basedriver/commands/settings.d.ts.map +1 -1
- package/build/lib/basedriver/commands/settings.js +35 -28
- package/build/lib/basedriver/commands/settings.js.map +1 -1
- package/build/lib/basedriver/commands/timeout.d.ts +7 -5
- package/build/lib/basedriver/commands/timeout.d.ts.map +1 -1
- package/build/lib/basedriver/commands/timeout.js +144 -162
- package/build/lib/basedriver/commands/timeout.js.map +1 -1
- package/build/lib/basedriver/core.d.ts +6 -157
- package/build/lib/basedriver/core.d.ts.map +1 -1
- package/build/lib/basedriver/core.js +361 -230
- package/build/lib/basedriver/core.js.map +1 -1
- package/build/lib/basedriver/desired-caps.js +80 -110
- package/build/lib/basedriver/desired-caps.js.map +1 -1
- package/build/lib/basedriver/device-settings.js +57 -62
- package/build/lib/basedriver/device-settings.js.map +1 -1
- package/build/lib/basedriver/driver.d.ts +21 -267
- package/build/lib/basedriver/driver.d.ts.map +1 -1
- package/build/lib/basedriver/driver.js +362 -258
- package/build/lib/basedriver/driver.js.map +1 -1
- package/build/lib/basedriver/helpers.js +500 -495
- package/build/lib/basedriver/helpers.js.map +1 -1
- package/build/lib/basedriver/logger.d.ts +1 -1
- package/build/lib/basedriver/logger.d.ts.map +1 -1
- package/build/lib/basedriver/logger.js +5 -15
- package/build/lib/basedriver/logger.js.map +1 -1
- package/build/lib/constants.js +14 -14
- package/build/lib/constants.js.map +1 -1
- package/build/lib/express/crash.js +8 -15
- package/build/lib/express/crash.js.map +1 -1
- package/build/lib/express/express-logging.js +49 -59
- package/build/lib/express/express-logging.js.map +1 -1
- package/build/lib/express/idempotency.js +125 -177
- package/build/lib/express/idempotency.js.map +1 -1
- package/build/lib/express/logger.d.ts +1 -1
- package/build/lib/express/logger.d.ts.map +1 -1
- package/build/lib/express/logger.js +5 -15
- package/build/lib/express/logger.js.map +1 -1
- package/build/lib/express/middleware.js +82 -107
- package/build/lib/express/middleware.js.map +1 -1
- package/build/lib/express/server.d.ts +17 -5
- package/build/lib/express/server.d.ts.map +1 -1
- package/build/lib/express/server.js +259 -224
- package/build/lib/express/server.js.map +1 -1
- package/build/lib/express/static.js +64 -81
- package/build/lib/express/static.js.map +1 -1
- package/build/lib/express/websocket.js +115 -87
- package/build/lib/express/websocket.js.map +1 -1
- package/build/lib/helpers/capabilities.d.ts +1 -59
- package/build/lib/helpers/capabilities.d.ts.map +1 -1
- package/build/lib/helpers/capabilities.js +72 -69
- package/build/lib/helpers/capabilities.js.map +1 -1
- package/build/lib/index.js +64 -180
- package/build/lib/index.js.map +1 -1
- package/build/lib/jsonwp-proxy/protocol-converter.js +215 -227
- package/build/lib/jsonwp-proxy/protocol-converter.js.map +1 -1
- package/build/lib/jsonwp-proxy/proxy.d.ts.map +1 -1
- package/build/lib/jsonwp-proxy/proxy.js +355 -393
- package/build/lib/jsonwp-proxy/proxy.js.map +1 -1
- package/build/lib/jsonwp-status/status.js +119 -130
- package/build/lib/jsonwp-status/status.js.map +1 -1
- package/build/lib/protocol/errors.d.ts +135 -32
- package/build/lib/protocol/errors.d.ts.map +1 -1
- package/build/lib/protocol/errors.js +871 -919
- package/build/lib/protocol/errors.js.map +1 -1
- package/build/lib/protocol/helpers.js +37 -37
- package/build/lib/protocol/helpers.js.map +1 -1
- package/build/lib/protocol/index.js +22 -109
- package/build/lib/protocol/index.js.map +1 -1
- package/build/lib/protocol/protocol.js +394 -350
- package/build/lib/protocol/protocol.js.map +1 -1
- package/build/lib/protocol/routes.d.ts +1238 -4
- package/build/lib/protocol/routes.d.ts.map +1 -1
- package/build/lib/protocol/routes.js +964 -1327
- package/build/lib/protocol/routes.js.map +1 -1
- package/build/lib/protocol/validators.js +32 -39
- package/build/lib/protocol/validators.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/lib/basedriver/capabilities.js +80 -39
- package/lib/basedriver/commands/event.js +10 -5
- package/lib/basedriver/commands/execute.js +14 -9
- package/lib/basedriver/commands/find.js +18 -12
- package/lib/basedriver/commands/index.js +21 -16
- package/lib/basedriver/commands/log.js +24 -18
- package/lib/basedriver/commands/session.js +10 -5
- package/lib/basedriver/commands/settings.js +9 -6
- package/lib/basedriver/commands/timeout.js +10 -4
- package/lib/basedriver/core.js +2 -3
- package/lib/basedriver/driver.js +29 -18
- package/lib/express/server.js +6 -3
- package/lib/protocol/errors.js +155 -44
- package/lib/protocol/routes.js +11 -7
- package/package.json +14 -16
|
@@ -2,8 +2,9 @@ import _ from 'lodash';
|
|
|
2
2
|
import {errors, makeArgs, checkParams} from '../../protocol';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* @
|
|
6
|
-
* @
|
|
5
|
+
* @template {Constraints} C
|
|
6
|
+
* @param {import('./session').SessionBase<C>} Base
|
|
7
|
+
* @returns {ExecuteBase<C>}
|
|
7
8
|
*/
|
|
8
9
|
export function ExecuteMixin(Base) {
|
|
9
10
|
/**
|
|
@@ -33,9 +34,9 @@ export function ExecuteMixin(Base) {
|
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
const Driver = /** @type {DriverClass} */ (this.constructor);
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
const commandMetadata = {...Driver.executeMethodMap?.[script]};
|
|
38
|
+
if (!commandMetadata.command) {
|
|
39
|
+
const availableScripts = _.keys(Driver.executeMethodMap);
|
|
39
40
|
throw new errors.UnsupportedOperationError(
|
|
40
41
|
`Unsupported execute method '${script}'. Available methods ` +
|
|
41
42
|
`are: ${availableScripts.join(', ')}`
|
|
@@ -50,16 +51,20 @@ export function ExecuteMixin(Base) {
|
|
|
50
51
|
checkParams(commandMetadata.params, args, null);
|
|
51
52
|
}
|
|
52
53
|
argsToApply = makeArgs({}, args, commandMetadata.params, null);
|
|
53
|
-
return await this[
|
|
54
|
+
return await this[commandMetadata.command](...argsToApply);
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
57
|
return ExecuteCommands;
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
/**
|
|
60
|
-
* @typedef {import('@appium/types').
|
|
61
|
+
* @typedef {import('@appium/types').IExecuteCommands} IExecuteCommands
|
|
61
62
|
* @typedef {import('@appium/types').Driver} Driver
|
|
62
63
|
* @typedef {import('@appium/types').DriverClass} DriverClass
|
|
63
|
-
* @typedef {import('
|
|
64
|
-
|
|
64
|
+
* @typedef {import('@appium/types').Constraints} Constraints
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @template {Constraints} C
|
|
69
|
+
* @typedef {import('../driver').BaseDriverBase<C, import('@appium/types').ITimeoutCommands & import('@appium/types').IEventCommands & import('@appium/types').IFindCommands & import('@appium/types').ILogCommands<C> & import('@appium/types').ISettingsCommands & import('@appium/types').ISessionCommands & IExecuteCommands>} ExecuteBase
|
|
65
70
|
*/
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
import {errors} from '../../protocol';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
* @param {EventBase} Base
|
|
9
|
-
* @returns {FindBase}
|
|
7
|
+
* @template {Constraints} C
|
|
8
|
+
* @param {import('./event').EventBase<C>} Base
|
|
9
|
+
* @returns {FindBase<C>}
|
|
10
10
|
*/
|
|
11
11
|
export function FindMixin(Base) {
|
|
12
12
|
/**
|
|
@@ -44,16 +44,16 @@ export function FindMixin(Base) {
|
|
|
44
44
|
async findElementsFromElement(strategy, selector, elementId) {
|
|
45
45
|
return await this.findElOrElsWithProcessing(strategy, selector, true, elementId);
|
|
46
46
|
}
|
|
47
|
-
// Override the following function for your own driver, and the rest is taken
|
|
48
|
-
// care of!
|
|
49
|
-
// Returns an object which adheres to the way the JSON Wire Protocol represents elements:
|
|
50
|
-
// { ELEMENT: # } eg: { ELEMENT: 3 } or { ELEMENT: 1.023 }
|
|
51
47
|
/**
|
|
48
|
+
* Returns an object which adheres to the way the JSON Wire Protocol represents elements:
|
|
49
|
+
*
|
|
50
|
+
* Override this for your own driver!
|
|
52
51
|
* @template {boolean} Mult
|
|
52
|
+
* @template [Ctx=any]
|
|
53
53
|
* @param {string} strategy
|
|
54
54
|
* @param {string} selector
|
|
55
55
|
* @param {Mult} mult
|
|
56
|
-
* @param {
|
|
56
|
+
* @param {Ctx} [context]
|
|
57
57
|
* @returns {Promise<Mult extends true ? Element[] : Element>}
|
|
58
58
|
*/
|
|
59
59
|
async findElOrEls(strategy, selector, mult, context) {
|
|
@@ -68,10 +68,11 @@ export function FindMixin(Base) {
|
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
70
|
* @template {boolean} Mult
|
|
71
|
+
* @template [Ctx=any]
|
|
71
72
|
* @param {string} strategy
|
|
72
73
|
* @param {string} selector
|
|
73
74
|
* @param {Mult} mult
|
|
74
|
-
* @param {
|
|
75
|
+
* @param {Ctx} [context]
|
|
75
76
|
* @returns {Promise<Mult extends true ? Element[] : Element>}
|
|
76
77
|
*/
|
|
77
78
|
async findElOrElsWithProcessing(strategy, selector, mult, context) {
|
|
@@ -96,7 +97,12 @@ export function FindMixin(Base) {
|
|
|
96
97
|
|
|
97
98
|
/**
|
|
98
99
|
* @typedef {import('@appium/types').Element} Element
|
|
99
|
-
* @typedef {import('@appium/types').
|
|
100
|
-
* @typedef {import('
|
|
101
|
-
* @typedef {import('
|
|
100
|
+
* @typedef {import('@appium/types').Constraints} Constraints
|
|
101
|
+
* @typedef {import('@appium/types').IFindCommands} IFindCommands
|
|
102
|
+
* @typedef {import('@appium/types').ITimeoutCommands} ITimeoutCommands
|
|
103
|
+
* @typedef {import('@appium/types').IEventCommands} IEventCommands
|
|
104
|
+
*/
|
|
105
|
+
/**
|
|
106
|
+
* @template {Constraints} C
|
|
107
|
+
* @typedef {import('../driver').BaseDriverBase<C, ITimeoutCommands & IEventCommands & IFindCommands>} FindBase
|
|
102
108
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
|
|
2
|
+
import _ from 'lodash';
|
|
3
3
|
import {EventMixin} from './event';
|
|
4
4
|
import {FindMixin} from './find';
|
|
5
5
|
import {LogMixin} from './log';
|
|
@@ -9,22 +9,27 @@ import {TimeoutMixin} from './timeout';
|
|
|
9
9
|
import {ExecuteMixin} from './execute';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* Applies all the mixins to the `BaseDriverBase` class.
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* Applies all the mixins to the `BaseDriverBase` class; returns a `BaseDriver` class definition.
|
|
13
|
+
* Each mixin is applied in the order it is listed here, and each type is a union with the previous.
|
|
14
|
+
*
|
|
15
|
+
* @template {Constraints} C
|
|
16
|
+
* @param {BaseDriverBase<C>} Base
|
|
17
|
+
*/
|
|
18
|
+
export const createBaseDriverClass = _.flow(
|
|
19
|
+
TimeoutMixin,
|
|
20
|
+
EventMixin,
|
|
21
|
+
FindMixin,
|
|
22
|
+
LogMixin,
|
|
23
|
+
SettingsMixin,
|
|
24
|
+
SessionMixin,
|
|
25
|
+
ExecuteMixin
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @template {Constraints} C
|
|
30
|
+
* @typedef {import('../driver').BaseDriverBase<C>} BaseDriverBase
|
|
15
31
|
*/
|
|
16
|
-
export function createBaseDriverClass(Base) {
|
|
17
|
-
const WithTimeoutCommands = TimeoutMixin(Base);
|
|
18
|
-
const WithEventCommands = EventMixin(WithTimeoutCommands);
|
|
19
|
-
const WithFindCommands = FindMixin(WithEventCommands);
|
|
20
|
-
const WithLogCommands = LogMixin(WithFindCommands);
|
|
21
|
-
const WithSettingsCommands = SettingsMixin(WithLogCommands);
|
|
22
|
-
const WithSessionCommands = SessionMixin(WithSettingsCommands);
|
|
23
|
-
const WithExecuteCommands = ExecuteMixin(WithSessionCommands);
|
|
24
|
-
return WithExecuteCommands;
|
|
25
|
-
}
|
|
26
32
|
|
|
27
33
|
/**
|
|
28
|
-
* @
|
|
29
|
-
* @typedef {import('../driver').BaseDriverBase<T>} BaseDriverBase
|
|
34
|
+
* @typedef {import('@appium/types').Constraints} Constraints
|
|
30
35
|
*/
|
|
@@ -4,37 +4,40 @@
|
|
|
4
4
|
import _ from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
* @param {FindBase} Base
|
|
9
|
-
* @returns {LogBase}
|
|
7
|
+
* @template {Constraints} C
|
|
8
|
+
* @param {import('./find').FindBase<C>} Base
|
|
9
|
+
* @returns {LogBase<C>}
|
|
10
10
|
*/
|
|
11
11
|
export function LogMixin(Base) {
|
|
12
12
|
/**
|
|
13
|
-
* @implements {ILogCommands}
|
|
13
|
+
* @implements {ILogCommands<C>}
|
|
14
14
|
*/
|
|
15
15
|
class LogCommands extends Base {
|
|
16
|
+
/** @type {Readonly<import('@appium/types').LogDefRecord<C>>} */
|
|
17
|
+
supportedLogTypes;
|
|
18
|
+
|
|
16
19
|
constructor(...args) {
|
|
17
20
|
super(...args);
|
|
18
|
-
|
|
19
|
-
this.supportedLogTypes = this.supportedLogTypes ?? {};
|
|
21
|
+
this.supportedLogTypes ??= {};
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
async getLogTypes() {
|
|
23
25
|
this.log.debug('Retrieving supported log types');
|
|
24
|
-
return
|
|
26
|
+
return Object.keys(this.supportedLogTypes);
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
/**
|
|
28
|
-
* @this {Driver}
|
|
29
|
-
* @param {
|
|
30
|
+
* @this {import('@appium/types').Driver<C>}
|
|
31
|
+
* @param {keyof typeof this.supportedLogTypes} logType
|
|
32
|
+
* @returns {Promise<import('type-fest').AsyncReturnType<typeof this.supportedLogTypes[keyof typeof this.supportedLogTypes]['getter']>>}
|
|
30
33
|
*/
|
|
31
34
|
async getLog(logType) {
|
|
32
|
-
this.log.debug(`Retrieving '${logType}' logs`);
|
|
35
|
+
this.log.debug(`Retrieving '${String(logType)}' logs`);
|
|
33
36
|
|
|
34
|
-
if (!(
|
|
37
|
+
if (!(logType in this.supportedLogTypes)) {
|
|
35
38
|
const logsTypesWithDescriptions = _.mapValues(this.supportedLogTypes, 'description');
|
|
36
39
|
throw new Error(
|
|
37
|
-
`Unsupported log type '${logType}'. ` +
|
|
40
|
+
`Unsupported log type '${String(logType)}'. ` +
|
|
38
41
|
`Supported types: ${JSON.stringify(logsTypesWithDescriptions)}`
|
|
39
42
|
);
|
|
40
43
|
}
|
|
@@ -46,13 +49,16 @@ export function LogMixin(Base) {
|
|
|
46
49
|
}
|
|
47
50
|
|
|
48
51
|
/**
|
|
49
|
-
* @typedef {import('@appium/types').
|
|
50
|
-
* @typedef {import('@appium/types').
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
* @typedef {import('@appium/types').Constraints} Constraints
|
|
53
|
+
* @typedef {import('@appium/types').StringRecord} StringRecord
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @template {Constraints} C
|
|
58
|
+
* @typedef {import('@appium/types').ILogCommands<C>} ILogCommands
|
|
53
59
|
*/
|
|
54
60
|
|
|
55
61
|
/**
|
|
56
|
-
* @template
|
|
57
|
-
* @typedef {import('@appium/types').
|
|
62
|
+
* @template {Constraints} C
|
|
63
|
+
* @typedef {import('../driver').BaseDriverBase<C, import('@appium/types').ITimeoutCommands & import('@appium/types').IEventCommands & import('@appium/types').IFindCommands & ILogCommands<C>>} LogBase
|
|
58
64
|
*/
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
import _ from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* @
|
|
8
|
-
* @
|
|
7
|
+
* @template {Constraints} C
|
|
8
|
+
* @param {import('./settings').SettingsBase<C>} Base
|
|
9
|
+
* @returns {SessionBase<C>}
|
|
9
10
|
*/
|
|
10
11
|
export function SessionMixin(Base) {
|
|
11
12
|
/**
|
|
@@ -43,9 +44,13 @@ export function SessionMixin(Base) {
|
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
/**
|
|
46
|
-
* @typedef {import('@appium/types').
|
|
47
|
+
* @typedef {import('@appium/types').ISessionCommands} ISessionCommands
|
|
47
48
|
* @typedef {import('@appium/types').SingularSessionData} SingularSessionData
|
|
48
49
|
* @typedef {import('@appium/types').MultiSessionData} MultiSessionData
|
|
49
|
-
* @typedef {import('
|
|
50
|
-
|
|
50
|
+
* @typedef {import('@appium/types').Constraints} Constraints
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @template {Constraints} C
|
|
55
|
+
* @typedef {import('../driver').BaseDriverBase<C, import('@appium/types').ITimeoutCommands & import('@appium/types').IEventCommands & import('@appium/types').IFindCommands & import('@appium/types').ILogCommands<C> & import('@appium/types').ISettingsCommands & ISessionCommands>} SessionBase
|
|
51
56
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* @param {
|
|
6
|
-
* @returns {SettingsBase}
|
|
4
|
+
* @template {Constraints} C
|
|
5
|
+
* @param {import('./log').LogBase<C>} Base
|
|
6
|
+
* @returns {SettingsBase<C>}
|
|
7
7
|
*/
|
|
8
8
|
export function SettingsMixin(Base) {
|
|
9
9
|
/**
|
|
@@ -29,7 +29,10 @@ export function SettingsMixin(Base) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
* @typedef {import('@appium/types').
|
|
33
|
-
* @typedef {import('
|
|
34
|
-
|
|
32
|
+
* @typedef {import('@appium/types').Constraints} Constraints
|
|
33
|
+
* @typedef {import('@appium/types').ISettingsCommands} ISettingsCommands
|
|
34
|
+
*/
|
|
35
|
+
/**
|
|
36
|
+
* @template {Constraints} C
|
|
37
|
+
* @typedef {import('../driver').BaseDriverBase<C, import('@appium/types').ITimeoutCommands & import('@appium/types').IEventCommands & import('@appium/types').IFindCommands & import('@appium/types').ILogCommands<C> & ISettingsCommands>} SettingsBase
|
|
35
38
|
*/
|
|
@@ -10,8 +10,9 @@ import {errors} from '../../protocol';
|
|
|
10
10
|
const MIN_TIMEOUT = 0;
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* @
|
|
14
|
-
* @
|
|
13
|
+
* @template {Constraints} C
|
|
14
|
+
* @param {import('../driver').BaseDriverBase<C>} Base
|
|
15
|
+
* @returns {TimeoutBase<C>}
|
|
15
16
|
*/
|
|
16
17
|
export function TimeoutMixin(Base) {
|
|
17
18
|
/**
|
|
@@ -157,6 +158,11 @@ export function TimeoutMixin(Base) {
|
|
|
157
158
|
}
|
|
158
159
|
|
|
159
160
|
/**
|
|
160
|
-
* @typedef {import('@appium/types').
|
|
161
|
-
* @typedef {import('
|
|
161
|
+
* @typedef {import('@appium/types').ITimeoutCommands} ITimeoutCommands
|
|
162
|
+
* @typedef {import('@appium/types').Constraints} Constraints
|
|
163
|
+
*/
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* @template {Constraints} C
|
|
167
|
+
* @typedef {import('../driver').BaseDriverBase<C, ITimeoutCommands>} TimeoutBase
|
|
162
168
|
*/
|
package/lib/basedriver/core.js
CHANGED
|
@@ -29,7 +29,7 @@ class DriverCore {
|
|
|
29
29
|
*/
|
|
30
30
|
static baseVersion = BASEDRIVER_VER;
|
|
31
31
|
|
|
32
|
-
/** @type {ExecuteMethodMap} */
|
|
32
|
+
/** @type {import('@appium/types').ExecuteMethodMap<DriverCore>} */
|
|
33
33
|
static executeMethodMap = {};
|
|
34
34
|
|
|
35
35
|
/**
|
|
@@ -171,7 +171,7 @@ class DriverCore {
|
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
/**
|
|
174
|
-
* This property controls the way
|
|
174
|
+
* This property controls the way the `executeCommand` method
|
|
175
175
|
* handles new driver commands received from the client.
|
|
176
176
|
* Override it for inherited classes only in special cases.
|
|
177
177
|
*
|
|
@@ -420,7 +420,6 @@ export {DriverCore};
|
|
|
420
420
|
/**
|
|
421
421
|
* @typedef {import('@appium/types').Driver} Driver
|
|
422
422
|
* @typedef {import('@appium/types').Constraints} Constraints
|
|
423
|
-
* @typedef {import('@appium/types').ExecuteMethodMap} ExecuteMethodMap
|
|
424
423
|
* @typedef {import('@appium/types').ServerArgs} ServerArgs
|
|
425
424
|
* @typedef {import('@appium/types').EventHistory} EventHistory
|
|
426
425
|
* @typedef {import('@appium/types').AppiumLogger} AppiumLogger
|
package/lib/basedriver/driver.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
validateCaps,
|
|
6
|
-
APPIUM_OPTS_CAP,
|
|
7
6
|
PREFIXED_APPIUM_OPTS_CAP,
|
|
8
7
|
processCapabilities,
|
|
9
8
|
promoteAppiumOptions,
|
|
@@ -27,12 +26,12 @@ const ON_UNEXPECTED_SHUTDOWN_EVENT = 'onUnexpectedShutdown';
|
|
|
27
26
|
/**
|
|
28
27
|
* @implements {SessionHandler<C>}
|
|
29
28
|
* @template {Constraints} C
|
|
30
|
-
* @template {StringRecord} [
|
|
29
|
+
* @template {StringRecord} [CArgs=StringRecord]
|
|
31
30
|
* @extends {DriverCore<C>}
|
|
32
31
|
*/
|
|
33
32
|
export class BaseDriverCore extends DriverCore {
|
|
34
33
|
/**
|
|
35
|
-
* @type {
|
|
34
|
+
* @type {CArgs & ServerArgs}
|
|
36
35
|
*/
|
|
37
36
|
cliArgs;
|
|
38
37
|
|
|
@@ -56,6 +55,25 @@ export class BaseDriverCore extends DriverCore {
|
|
|
56
55
|
*/
|
|
57
56
|
opts;
|
|
58
57
|
|
|
58
|
+
/**
|
|
59
|
+
*
|
|
60
|
+
* @param {DriverOpts<C>} opts
|
|
61
|
+
* @param {boolean} shouldValidateCaps
|
|
62
|
+
*/
|
|
63
|
+
constructor(opts = /** @type {DriverOpts<C>} */ ({}), shouldValidateCaps = true) {
|
|
64
|
+
super(opts, shouldValidateCaps);
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* This must be assigned here because the declaration of {@linkcode BaseDriverCore.opts} above
|
|
68
|
+
* blows away {@linkcode DriverCore.opts}.
|
|
69
|
+
*/
|
|
70
|
+
this.opts = opts;
|
|
71
|
+
|
|
72
|
+
this.caps = {};
|
|
73
|
+
|
|
74
|
+
this.cliArgs = /** @type {CArgs & ServerArgs} */ ({});
|
|
75
|
+
}
|
|
76
|
+
|
|
59
77
|
/**
|
|
60
78
|
* Contains the base constraints plus whatever the subclass wants to add.
|
|
61
79
|
*
|
|
@@ -69,8 +87,6 @@ export class BaseDriverCore extends DriverCore {
|
|
|
69
87
|
return Object.freeze(_.merge({}, BASE_DESIRED_CAP_CONSTRAINTS, this.desiredCapConstraints));
|
|
70
88
|
}
|
|
71
89
|
|
|
72
|
-
static BASE_DESIRED_CAP_CONSTRAINTS = BASE_DESIRED_CAP_CONSTRAINTS;
|
|
73
|
-
|
|
74
90
|
// This is the main command handler for the driver. It wraps command
|
|
75
91
|
// execution with timeout logic, checking that we have a valid session,
|
|
76
92
|
// and ensuring that we execute commands one at a time. This method is called
|
|
@@ -282,16 +298,10 @@ export class BaseDriverCore extends DriverCore {
|
|
|
282
298
|
let caps;
|
|
283
299
|
try {
|
|
284
300
|
caps = processCapabilities(
|
|
285
|
-
originalCaps,
|
|
301
|
+
promoteAppiumOptions(originalCaps),
|
|
286
302
|
this._desiredCapConstraints,
|
|
287
303
|
this.shouldValidateCaps
|
|
288
304
|
);
|
|
289
|
-
if (caps[APPIUM_OPTS_CAP]) {
|
|
290
|
-
this.log.debug(
|
|
291
|
-
`Found ${PREFIXED_APPIUM_OPTS_CAP} capability present; will promote items inside to caps`
|
|
292
|
-
);
|
|
293
|
-
caps = promoteAppiumOptions(caps);
|
|
294
|
-
}
|
|
295
305
|
caps = fixCaps(caps, this._desiredCapConstraints, this.log);
|
|
296
306
|
} catch (e) {
|
|
297
307
|
throw new errors.SessionNotCreatedError(e.message);
|
|
@@ -361,7 +371,7 @@ export class BaseDriverCore extends DriverCore {
|
|
|
361
371
|
|
|
362
372
|
/**
|
|
363
373
|
*
|
|
364
|
-
* @param {Capabilities} caps
|
|
374
|
+
* @param {Capabilities<C>} caps
|
|
365
375
|
*/
|
|
366
376
|
logExtraCaps(caps) {
|
|
367
377
|
let extraCaps = _.difference(_.keys(caps), _.keys(this._desiredCapConstraints));
|
|
@@ -412,7 +422,6 @@ export default BaseDriver;
|
|
|
412
422
|
|
|
413
423
|
/**
|
|
414
424
|
* @typedef {import('@appium/types').HTTPMethod} HTTPMethod
|
|
415
|
-
* @typedef {import('@appium/types').ExternalDriver} ExternalDriver
|
|
416
425
|
* @typedef {import('@appium/types').DriverData} DriverData
|
|
417
426
|
* @typedef {import('@appium/types').Constraints} Constraints
|
|
418
427
|
* @typedef {import('@appium/types').Constraint} Constraint
|
|
@@ -430,9 +439,10 @@ export default BaseDriver;
|
|
|
430
439
|
|
|
431
440
|
/**
|
|
432
441
|
* This is used to extend {@linkcode BaseDriverCore} by the mixins and also external drivers.
|
|
442
|
+
* @template {Constraints} C
|
|
433
443
|
* @template [Proto={}]
|
|
434
444
|
* @template [Static={}]
|
|
435
|
-
* @typedef {import('@appium/types').Class<BaseDriverCore & Proto,import('@appium/types').DriverStatic & Static>} BaseDriverBase
|
|
445
|
+
* @typedef {import('@appium/types').Class<BaseDriverCore<C> & Proto,import('@appium/types').DriverStatic & Static>} BaseDriverBase
|
|
436
446
|
*/
|
|
437
447
|
|
|
438
448
|
/**
|
|
@@ -453,13 +463,14 @@ export default BaseDriver;
|
|
|
453
463
|
*/
|
|
454
464
|
|
|
455
465
|
/**
|
|
456
|
-
* @template {Constraints} C
|
|
457
|
-
* @
|
|
466
|
+
* @template {Constraints} [C=BaseDriverCapConstraints]
|
|
467
|
+
* @template {StringRecord} [CArgs=StringRecord]
|
|
468
|
+
* @typedef {import('@appium/types').Driver<C, CArgs>} Driver
|
|
458
469
|
*/
|
|
459
470
|
|
|
460
471
|
/**
|
|
461
472
|
* @template {Constraints} C
|
|
462
|
-
* @typedef {import('@appium/types').
|
|
473
|
+
* @typedef {import('@appium/types').ExternalDriver<C>} ExternalDriver
|
|
463
474
|
*/
|
|
464
475
|
|
|
465
476
|
/**
|
package/lib/express/server.js
CHANGED
|
@@ -40,7 +40,7 @@ async function server(opts) {
|
|
|
40
40
|
routeConfiguringFunction,
|
|
41
41
|
port,
|
|
42
42
|
hostname,
|
|
43
|
-
cliArgs,
|
|
43
|
+
cliArgs = {},
|
|
44
44
|
allowCors = true,
|
|
45
45
|
basePath = DEFAULT_BASE_PATH,
|
|
46
46
|
extraMethodMap = {},
|
|
@@ -277,7 +277,10 @@ export {server, configureServer, normalizeBasePath};
|
|
|
277
277
|
/**
|
|
278
278
|
* @typedef {import('@appium/types').AppiumServer} AppiumServer
|
|
279
279
|
* @typedef {import('@appium/types').AppiumServerSocket} AppiumServerSocket
|
|
280
|
-
|
|
280
|
+
*/
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* @typedef {import('@appium/types').MethodMap<import('@appium/types').ExternalDriver>} MethodMap
|
|
281
284
|
*/
|
|
282
285
|
|
|
283
286
|
/**
|
|
@@ -293,7 +296,7 @@ export {server, configureServer, normalizeBasePath};
|
|
|
293
296
|
* @typedef ServerOpts
|
|
294
297
|
* @property {RouteConfiguringFunction} routeConfiguringFunction
|
|
295
298
|
* @property {number} port
|
|
296
|
-
* @property {import('@appium/types').ServerArgs} cliArgs
|
|
299
|
+
* @property {import('@appium/types').ServerArgs} [cliArgs]
|
|
297
300
|
* @property {string} [hostname]
|
|
298
301
|
* @property {boolean} [allowCors]
|
|
299
302
|
* @property {string} [basePath]
|