@appium/base-driver 9.3.2 → 9.3.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/LICENSE +1 -1
- package/build/lib/basedriver/capabilities.d.ts +59 -36
- package/build/lib/basedriver/capabilities.d.ts.map +1 -1
- package/build/lib/basedriver/capabilities.js +57 -45
- package/build/lib/basedriver/capabilities.js.map +1 -1
- package/build/lib/basedriver/commands/event.d.ts +5 -9
- package/build/lib/basedriver/commands/event.d.ts.map +1 -1
- package/build/lib/basedriver/commands/event.js +28 -49
- package/build/lib/basedriver/commands/event.js.map +1 -1
- package/build/lib/basedriver/commands/execute.d.ts +5 -11
- package/build/lib/basedriver/commands/execute.d.ts.map +1 -1
- package/build/lib/basedriver/commands/execute.js +15 -39
- package/build/lib/basedriver/commands/execute.js.map +1 -1
- package/build/lib/basedriver/commands/find.d.ts +5 -12
- package/build/lib/basedriver/commands/find.d.ts.map +1 -1
- package/build/lib/basedriver/commands/find.js +38 -98
- package/build/lib/basedriver/commands/find.js.map +1 -1
- package/build/lib/basedriver/commands/index.d.ts +7 -3
- package/build/lib/basedriver/commands/index.d.ts.map +1 -1
- package/build/lib/basedriver/commands/index.js +7 -28
- package/build/lib/basedriver/commands/index.js.map +1 -1
- package/build/lib/basedriver/commands/log.d.ts +5 -10
- package/build/lib/basedriver/commands/log.d.ts.map +1 -1
- package/build/lib/basedriver/commands/log.js +17 -50
- package/build/lib/basedriver/commands/log.js.map +1 -1
- package/build/lib/basedriver/commands/mixin.d.ts +12 -0
- package/build/lib/basedriver/commands/mixin.d.ts.map +1 -0
- package/build/lib/basedriver/commands/mixin.js +18 -0
- package/build/lib/basedriver/commands/mixin.js.map +1 -0
- package/build/lib/basedriver/commands/session.d.ts +5 -11
- package/build/lib/basedriver/commands/session.d.ts.map +1 -1
- package/build/lib/basedriver/commands/session.js +18 -53
- package/build/lib/basedriver/commands/session.js.map +1 -1
- package/build/lib/basedriver/commands/settings.d.ts +5 -9
- package/build/lib/basedriver/commands/settings.d.ts.map +1 -1
- package/build/lib/basedriver/commands/settings.js +14 -34
- package/build/lib/basedriver/commands/settings.js.map +1 -1
- package/build/lib/basedriver/commands/timeout.d.ts +5 -9
- package/build/lib/basedriver/commands/timeout.d.ts.map +1 -1
- package/build/lib/basedriver/commands/timeout.js +107 -129
- package/build/lib/basedriver/commands/timeout.js.map +1 -1
- package/build/lib/basedriver/core.d.ts +14 -20
- package/build/lib/basedriver/core.d.ts.map +1 -1
- package/build/lib/basedriver/core.js +32 -22
- package/build/lib/basedriver/core.js.map +1 -1
- package/build/lib/basedriver/device-settings.d.ts +11 -11
- package/build/lib/basedriver/device-settings.d.ts.map +1 -1
- package/build/lib/basedriver/device-settings.js +7 -8
- package/build/lib/basedriver/device-settings.js.map +1 -1
- package/build/lib/basedriver/driver.d.ts +23 -108
- package/build/lib/basedriver/driver.d.ts.map +1 -1
- package/build/lib/basedriver/driver.js +38 -135
- package/build/lib/basedriver/driver.js.map +1 -1
- package/build/lib/basedriver/helpers.d.ts +21 -98
- package/build/lib/basedriver/helpers.d.ts.map +1 -1
- package/build/lib/basedriver/helpers.js +178 -182
- package/build/lib/basedriver/helpers.js.map +1 -1
- package/build/lib/express/server.d.ts +3 -15
- package/build/lib/express/server.d.ts.map +1 -1
- package/build/lib/express/server.js +4 -2
- package/build/lib/express/server.js.map +1 -1
- package/build/lib/express/websocket.d.ts +5 -44
- package/build/lib/express/websocket.d.ts.map +1 -1
- package/build/lib/express/websocket.js +10 -39
- package/build/lib/express/websocket.js.map +1 -1
- package/build/lib/helpers/capabilities.d.ts +2 -2
- package/build/lib/helpers/capabilities.d.ts.map +1 -1
- package/build/lib/helpers/capabilities.js +2 -3
- package/build/lib/helpers/capabilities.js.map +1 -1
- package/build/lib/protocol/protocol.d.ts +1 -1
- package/build/lib/protocol/protocol.d.ts.map +1 -1
- package/build/lib/protocol/protocol.js +10 -2
- package/build/lib/protocol/protocol.js.map +1 -1
- package/build/lib/protocol/routes.d.ts +1 -0
- package/build/lib/protocol/routes.d.ts.map +1 -1
- package/build/lib/protocol/routes.js +12 -10
- package/build/lib/protocol/routes.js.map +1 -1
- package/lib/basedriver/capabilities.js +70 -56
- package/lib/basedriver/commands/event.ts +49 -0
- package/lib/basedriver/commands/execute.ts +40 -0
- package/lib/basedriver/commands/find.ts +80 -0
- package/lib/basedriver/commands/index.ts +7 -0
- package/lib/basedriver/commands/log.ts +34 -0
- package/lib/basedriver/commands/mixin.ts +15 -0
- package/lib/basedriver/commands/session.ts +36 -0
- package/lib/basedriver/commands/settings.ts +26 -0
- package/lib/basedriver/commands/timeout.ts +155 -0
- package/lib/basedriver/core.js +11 -28
- package/lib/basedriver/device-settings.js +9 -11
- package/lib/basedriver/{driver.js → driver.ts} +71 -180
- package/lib/basedriver/helpers.js +214 -212
- package/lib/express/server.js +4 -2
- package/lib/express/websocket.js +10 -39
- package/lib/helpers/capabilities.js +2 -3
- package/lib/protocol/protocol.js +11 -2
- package/lib/protocol/routes.js +12 -13
- package/package.json +11 -7
- package/lib/basedriver/commands/event.js +0 -63
- package/lib/basedriver/commands/execute.js +0 -45
- package/lib/basedriver/commands/find.js +0 -108
- package/lib/basedriver/commands/index.js +0 -35
- package/lib/basedriver/commands/log.js +0 -64
- package/lib/basedriver/commands/session.js +0 -57
- package/lib/basedriver/commands/settings.js +0 -38
- package/lib/basedriver/commands/timeout.js +0 -168
package/lib/protocol/routes.js
CHANGED
|
@@ -18,6 +18,7 @@ const SET_ALERT_TEXT_PAYLOAD_PARAMS = {
|
|
|
18
18
|
* define the routes, mapping of HTTP methods to particular driver commands, and
|
|
19
19
|
* any parameters that are expected in a request parameters can be `required` or
|
|
20
20
|
* `optional`
|
|
21
|
+
* @satisfies {import('@appium/types').MethodMap<import('../basedriver/driver').BaseDriver>}
|
|
21
22
|
*/
|
|
22
23
|
const METHOD_MAP = /** @type {const} */ ({
|
|
23
24
|
'/status': {
|
|
@@ -129,7 +130,11 @@ const METHOD_MAP = /** @type {const} */ ({
|
|
|
129
130
|
POST: {command: 'deactivateIMEEngine', deprecated: true},
|
|
130
131
|
},
|
|
131
132
|
'/session/:sessionId/ime/activate': {
|
|
132
|
-
POST: {
|
|
133
|
+
POST: {
|
|
134
|
+
command: 'activateIMEEngine',
|
|
135
|
+
payloadParams: {required: ['engine']},
|
|
136
|
+
deprecated: true,
|
|
137
|
+
},
|
|
133
138
|
},
|
|
134
139
|
'/session/:sessionId/frame': {
|
|
135
140
|
POST: {command: 'setFrame', payloadParams: {required: ['id']}},
|
|
@@ -356,7 +361,11 @@ const METHOD_MAP = /** @type {const} */ ({
|
|
|
356
361
|
DELETE: {command: 'releaseActions'},
|
|
357
362
|
},
|
|
358
363
|
'/session/:sessionId/touch/longclick': {
|
|
359
|
-
POST: {
|
|
364
|
+
POST: {
|
|
365
|
+
command: 'touchLongClick',
|
|
366
|
+
payloadParams: {required: ['elements']},
|
|
367
|
+
deprecated: true,
|
|
368
|
+
},
|
|
360
369
|
},
|
|
361
370
|
'/session/:sessionId/touch/flick': {
|
|
362
371
|
POST: {
|
|
@@ -922,7 +931,7 @@ const METHOD_MAP = /** @type {const} */ ({
|
|
|
922
931
|
let ALL_COMMANDS = [];
|
|
923
932
|
for (let v of _.values(METHOD_MAP)) {
|
|
924
933
|
for (let m of _.values(v)) {
|
|
925
|
-
if (m.command) {
|
|
934
|
+
if ('command' in m && m.command) {
|
|
926
935
|
ALL_COMMANDS.push(m.command);
|
|
927
936
|
}
|
|
928
937
|
}
|
|
@@ -1006,13 +1015,3 @@ function routeToCommandName(endpoint, method, basePath = DEFAULT_BASE_PATH) {
|
|
|
1006
1015
|
const NO_SESSION_ID_COMMANDS = ['createSession', 'getStatus', 'getSessions'];
|
|
1007
1016
|
|
|
1008
1017
|
export {METHOD_MAP, ALL_COMMANDS, NO_SESSION_ID_COMMANDS, routeToCommandName};
|
|
1009
|
-
|
|
1010
|
-
/**
|
|
1011
|
-
* This checks compat with the `MethodMap` interface.
|
|
1012
|
-
* @ignore
|
|
1013
|
-
*/
|
|
1014
|
-
// eslint-disable-next-line no-unused-vars
|
|
1015
|
-
const _validMethodMap =
|
|
1016
|
-
/** @type {import('@appium/types').MethodMap<import('@appium/types').ExternalDriver<import('@appium/types').BaseDriverCapConstraints>>} */ (
|
|
1017
|
-
METHOD_MAP
|
|
1018
|
-
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appium/base-driver",
|
|
3
|
-
"version": "9.3.
|
|
3
|
+
"version": "9.3.4",
|
|
4
4
|
"description": "Base driver class for Appium drivers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"automation",
|
|
@@ -40,11 +40,12 @@
|
|
|
40
40
|
"test": "npm run test:unit",
|
|
41
41
|
"test:e2e": "mocha -p --timeout 20s --slow 10s \"./test/e2e/**/*.spec.js\"",
|
|
42
42
|
"test:smoke": "node ./index.js",
|
|
43
|
-
"test:unit": "mocha \"./test/unit/**/*.spec.js\""
|
|
43
|
+
"test:unit": "mocha \"./test/unit/**/*.spec.js\"",
|
|
44
|
+
"test:types": "tsd"
|
|
44
45
|
},
|
|
45
46
|
"dependencies": {
|
|
46
|
-
"@appium/support": "^3.1.
|
|
47
|
-
"@appium/types": "^0.10.
|
|
47
|
+
"@appium/support": "^3.1.8",
|
|
48
|
+
"@appium/types": "^0.10.2",
|
|
48
49
|
"@colors/colors": "1.5.0",
|
|
49
50
|
"@types/async-lock": "1.4.0",
|
|
50
51
|
"@types/bluebird": "3.5.38",
|
|
@@ -60,12 +61,12 @@
|
|
|
60
61
|
"express": "4.18.2",
|
|
61
62
|
"http-status-codes": "2.2.0",
|
|
62
63
|
"lodash": "4.17.21",
|
|
63
|
-
"lru-cache": "7.
|
|
64
|
+
"lru-cache": "7.18.3",
|
|
64
65
|
"method-override": "3.0.0",
|
|
65
66
|
"morgan": "1.10.0",
|
|
66
67
|
"serve-favicon": "2.5.0",
|
|
67
68
|
"source-map-support": "0.5.21",
|
|
68
|
-
"type-fest": "3.
|
|
69
|
+
"type-fest": "3.7.1",
|
|
69
70
|
"validate.js": "0.13.1"
|
|
70
71
|
},
|
|
71
72
|
"engines": {
|
|
@@ -75,8 +76,11 @@
|
|
|
75
76
|
"publishConfig": {
|
|
76
77
|
"access": "public"
|
|
77
78
|
},
|
|
78
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "d514ebdd7ebd27bb236509d0a3d580f0f18a34e5",
|
|
79
80
|
"typedoc": {
|
|
80
81
|
"entryPoint": "./lib/index.js"
|
|
82
|
+
},
|
|
83
|
+
"tsd": {
|
|
84
|
+
"directory": "test/types"
|
|
81
85
|
}
|
|
82
86
|
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/* eslint-disable require-await */
|
|
2
|
-
// @ts-check
|
|
3
|
-
import _ from 'lodash';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @template {Constraints} C
|
|
7
|
-
* @param {import('./timeout').TimeoutBase<C>} Base
|
|
8
|
-
* @returns {EventBase<C>}
|
|
9
|
-
*/
|
|
10
|
-
export function EventMixin(Base) {
|
|
11
|
-
/**
|
|
12
|
-
* @implements {IEventCommands}
|
|
13
|
-
*/
|
|
14
|
-
class EventCommands extends Base {
|
|
15
|
-
/**
|
|
16
|
-
* Log a user-defined event in the event log.
|
|
17
|
-
*
|
|
18
|
-
* @param {string} vendor - a vendor prefix for the user, to ensure namespace
|
|
19
|
-
* separation
|
|
20
|
-
* @param {string} event - the event name
|
|
21
|
-
*/
|
|
22
|
-
async logCustomEvent(vendor, event) {
|
|
23
|
-
this.logEvent(`${vendor}:${event}`);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Get the event log
|
|
28
|
-
* @param {string|string[]} [type] - the event type to filter with.
|
|
29
|
-
* It returns all events if the type is not provided or empty string/array.
|
|
30
|
-
* @returns {Promise<import('@appium/types').EventHistory|Record<string,number>>} - the event history log object
|
|
31
|
-
*/
|
|
32
|
-
async getLogEvents(type) {
|
|
33
|
-
if (_.isEmpty(type)) {
|
|
34
|
-
return this.eventHistory;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const typeList = _.castArray(type);
|
|
38
|
-
|
|
39
|
-
return _.reduce(
|
|
40
|
-
this.eventHistory,
|
|
41
|
-
(acc, eventTimes, eventType) => {
|
|
42
|
-
if (typeList.includes(eventType)) {
|
|
43
|
-
acc[eventType] = eventTimes;
|
|
44
|
-
}
|
|
45
|
-
return acc;
|
|
46
|
-
},
|
|
47
|
-
{}
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return EventCommands;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* @typedef {import('@appium/types').Constraints} Constraints
|
|
57
|
-
* @typedef {import('@appium/types').IEventCommands} IEventCommands
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* @template {Constraints} C
|
|
62
|
-
* @typedef {import('../driver').BaseDriverBase<C, import('@appium/types').ITimeoutCommands & IEventCommands>} EventBase
|
|
63
|
-
*/
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import _ from 'lodash';
|
|
2
|
-
import {errors, validateExecuteMethodParams} from '../../protocol';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @template {Constraints} C
|
|
6
|
-
* @param {import('./session').SessionBase<C>} Base
|
|
7
|
-
* @returns {ExecuteBase<C>}
|
|
8
|
-
*/
|
|
9
|
-
export function ExecuteMixin(Base) {
|
|
10
|
-
/**
|
|
11
|
-
* @implements {IExecuteCommands}
|
|
12
|
-
*/
|
|
13
|
-
class ExecuteCommands extends Base {
|
|
14
|
-
/**
|
|
15
|
-
* @param {string} script
|
|
16
|
-
* @param {[Record<string, any>]|[]} protoArgs
|
|
17
|
-
*/
|
|
18
|
-
async executeMethod(script, protoArgs) {
|
|
19
|
-
const Driver = /** @type {DriverClass} */ (this.constructor);
|
|
20
|
-
const commandMetadata = {...Driver.executeMethodMap?.[script]};
|
|
21
|
-
if (!commandMetadata.command) {
|
|
22
|
-
const availableScripts = _.keys(Driver.executeMethodMap);
|
|
23
|
-
throw new errors.UnsupportedOperationError(
|
|
24
|
-
`Unsupported execute method '${script}'. Available methods ` +
|
|
25
|
-
`are: ${availableScripts.join(', ')}`
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
const args = validateExecuteMethodParams(protoArgs, commandMetadata.params);
|
|
29
|
-
return await this[commandMetadata.command](...args);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return ExecuteCommands;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @typedef {import('@appium/types').IExecuteCommands} IExecuteCommands
|
|
37
|
-
* @typedef {import('@appium/types').Driver} Driver
|
|
38
|
-
* @typedef {import('@appium/types').DriverClass} DriverClass
|
|
39
|
-
* @typedef {import('@appium/types').Constraints} Constraints
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* @template {Constraints} C
|
|
44
|
-
* @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
|
|
45
|
-
*/
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-unused-vars */
|
|
2
|
-
/* eslint-disable require-await */
|
|
3
|
-
// @ts-check
|
|
4
|
-
import {errors} from '../../protocol';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @template {Constraints} C
|
|
8
|
-
* @param {import('./event').EventBase<C>} Base
|
|
9
|
-
* @returns {FindBase<C>}
|
|
10
|
-
*/
|
|
11
|
-
export function FindMixin(Base) {
|
|
12
|
-
/**
|
|
13
|
-
* @implements {IFindCommands}
|
|
14
|
-
*/
|
|
15
|
-
class FindCommands extends Base {
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
* @returns {Promise<Element>}
|
|
19
|
-
*/
|
|
20
|
-
async findElement(strategy, selector) {
|
|
21
|
-
return await this.findElOrElsWithProcessing(strategy, selector, false);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
*
|
|
26
|
-
* @returns {Promise<Element[]>}
|
|
27
|
-
*/
|
|
28
|
-
async findElements(strategy, selector) {
|
|
29
|
-
return await this.findElOrElsWithProcessing(strategy, selector, true);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
*
|
|
34
|
-
* @returns {Promise<Element>}
|
|
35
|
-
*/
|
|
36
|
-
async findElementFromElement(strategy, selector, elementId) {
|
|
37
|
-
return await this.findElOrElsWithProcessing(strategy, selector, false, elementId);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
*
|
|
42
|
-
* @returns {Promise<Element[]>}
|
|
43
|
-
*/
|
|
44
|
-
async findElementsFromElement(strategy, selector, elementId) {
|
|
45
|
-
return await this.findElOrElsWithProcessing(strategy, selector, true, elementId);
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Returns an object which adheres to the way the JSON Wire Protocol represents elements:
|
|
49
|
-
*
|
|
50
|
-
* Override this for your own driver!
|
|
51
|
-
* @template {boolean} Mult
|
|
52
|
-
* @template [Ctx=any]
|
|
53
|
-
* @param {string} strategy
|
|
54
|
-
* @param {string} selector
|
|
55
|
-
* @param {Mult} mult
|
|
56
|
-
* @param {Ctx} [context]
|
|
57
|
-
* @returns {Promise<Mult extends true ? Element[] : Element>}
|
|
58
|
-
*/
|
|
59
|
-
async findElOrEls(strategy, selector, mult, context) {
|
|
60
|
-
throw new errors.NotImplementedError('Not implemented yet for find.');
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* @returns {Promise<string>}
|
|
65
|
-
*/
|
|
66
|
-
async getPageSource() {
|
|
67
|
-
throw new errors.NotImplementedError('Not implemented yet for find.');
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* @template {boolean} Mult
|
|
71
|
-
* @template [Ctx=any]
|
|
72
|
-
* @param {string} strategy
|
|
73
|
-
* @param {string} selector
|
|
74
|
-
* @param {Mult} mult
|
|
75
|
-
* @param {Ctx} [context]
|
|
76
|
-
* @returns {Promise<Mult extends true ? Element[] : Element>}
|
|
77
|
-
*/
|
|
78
|
-
async findElOrElsWithProcessing(strategy, selector, mult, context) {
|
|
79
|
-
this.validateLocatorStrategy(strategy);
|
|
80
|
-
try {
|
|
81
|
-
return await this.findElOrEls(strategy, selector, mult, context);
|
|
82
|
-
} catch (err) {
|
|
83
|
-
if (this.opts.printPageSourceOnFindFailure) {
|
|
84
|
-
const src = await this.getPageSource();
|
|
85
|
-
this.log.debug(`Error finding element${mult ? 's' : ''}: ${err.message}`);
|
|
86
|
-
this.log.debug(`Page source requested through 'printPageSourceOnFindFailure':`);
|
|
87
|
-
this.log.debug(src);
|
|
88
|
-
}
|
|
89
|
-
// still want the error to occur
|
|
90
|
-
throw err;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return FindCommands;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* @typedef {import('@appium/types').Element} Element
|
|
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
|
|
108
|
-
*/
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
import _ from 'lodash';
|
|
3
|
-
import {EventMixin} from './event';
|
|
4
|
-
import {FindMixin} from './find';
|
|
5
|
-
import {LogMixin} from './log';
|
|
6
|
-
import {SessionMixin} from './session';
|
|
7
|
-
import {SettingsMixin} from './settings';
|
|
8
|
-
import {TimeoutMixin} from './timeout';
|
|
9
|
-
import {ExecuteMixin} from './execute';
|
|
10
|
-
|
|
11
|
-
/**
|
|
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
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* @typedef {import('@appium/types').Constraints} Constraints
|
|
35
|
-
*/
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/* eslint-disable require-await */
|
|
2
|
-
// @ts-check
|
|
3
|
-
|
|
4
|
-
import _ from 'lodash';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @template {Constraints} C
|
|
8
|
-
* @param {import('./find').FindBase<C>} Base
|
|
9
|
-
* @returns {LogBase<C>}
|
|
10
|
-
*/
|
|
11
|
-
export function LogMixin(Base) {
|
|
12
|
-
/**
|
|
13
|
-
* @implements {ILogCommands<C>}
|
|
14
|
-
*/
|
|
15
|
-
class LogCommands extends Base {
|
|
16
|
-
/** @type {Readonly<import('@appium/types').LogDefRecord<C>>} */
|
|
17
|
-
supportedLogTypes;
|
|
18
|
-
|
|
19
|
-
constructor(...args) {
|
|
20
|
-
super(...args);
|
|
21
|
-
this.supportedLogTypes ??= {};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
async getLogTypes() {
|
|
25
|
-
this.log.debug('Retrieving supported log types');
|
|
26
|
-
return Object.keys(this.supportedLogTypes);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
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']>>}
|
|
33
|
-
*/
|
|
34
|
-
async getLog(logType) {
|
|
35
|
-
this.log.debug(`Retrieving '${String(logType)}' logs`);
|
|
36
|
-
|
|
37
|
-
if (!(logType in this.supportedLogTypes)) {
|
|
38
|
-
const logsTypesWithDescriptions = _.mapValues(this.supportedLogTypes, 'description');
|
|
39
|
-
throw new Error(
|
|
40
|
-
`Unsupported log type '${String(logType)}'. ` +
|
|
41
|
-
`Supported types: ${JSON.stringify(logsTypesWithDescriptions)}`
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return await this.supportedLogTypes[logType].getter(this);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return LogCommands;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
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
|
|
59
|
-
*/
|
|
60
|
-
|
|
61
|
-
/**
|
|
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
|
|
64
|
-
*/
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-unused-vars */
|
|
2
|
-
/* eslint-disable require-await */
|
|
3
|
-
// @ts-check
|
|
4
|
-
import _ from 'lodash';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @template {Constraints} C
|
|
8
|
-
* @param {import('./settings').SettingsBase<C>} Base
|
|
9
|
-
* @returns {SessionBase<C>}
|
|
10
|
-
*/
|
|
11
|
-
export function SessionMixin(Base) {
|
|
12
|
-
/**
|
|
13
|
-
* @implements {ISessionCommands}
|
|
14
|
-
*/
|
|
15
|
-
class SessionCommands extends Base {
|
|
16
|
-
/**
|
|
17
|
-
* @returns {Promise<MultiSessionData[]>}
|
|
18
|
-
*/
|
|
19
|
-
async getSessions() {
|
|
20
|
-
let ret = [];
|
|
21
|
-
|
|
22
|
-
if (this.sessionId) {
|
|
23
|
-
ret.push({
|
|
24
|
-
id: this.sessionId,
|
|
25
|
-
capabilities: this.caps,
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return ret;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Returns capabilities for the session and event history (if applicable)
|
|
34
|
-
* @returns {Promise<SingularSessionData>}
|
|
35
|
-
*/
|
|
36
|
-
async getSession() {
|
|
37
|
-
if (this.caps.eventTimings) {
|
|
38
|
-
return {...this.caps, events: this.eventHistory};
|
|
39
|
-
}
|
|
40
|
-
return this.caps;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return SessionCommands;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* @typedef {import('@appium/types').ISessionCommands} ISessionCommands
|
|
49
|
-
* @typedef {import('@appium/types').SingularSessionData} SingularSessionData
|
|
50
|
-
* @typedef {import('@appium/types').MultiSessionData} MultiSessionData
|
|
51
|
-
* @typedef {import('@appium/types').Constraints} Constraints
|
|
52
|
-
*/
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* @template {Constraints} C
|
|
56
|
-
* @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
|
|
57
|
-
*/
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @template {Constraints} C
|
|
5
|
-
* @param {import('./log').LogBase<C>} Base
|
|
6
|
-
* @returns {SettingsBase<C>}
|
|
7
|
-
*/
|
|
8
|
-
export function SettingsMixin(Base) {
|
|
9
|
-
/**
|
|
10
|
-
* @implements {ISettingsCommands}
|
|
11
|
-
*/
|
|
12
|
-
class SettingsCommands extends Base {
|
|
13
|
-
async updateSettings(newSettings) {
|
|
14
|
-
if (!this.settings) {
|
|
15
|
-
this.log.errorAndThrow('Cannot update settings; settings object not found');
|
|
16
|
-
}
|
|
17
|
-
return await this.settings.update(newSettings);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
async getSettings() {
|
|
21
|
-
if (!this.settings) {
|
|
22
|
-
this.log.errorAndThrow('Cannot get settings; settings object not found');
|
|
23
|
-
}
|
|
24
|
-
return await this.settings.getSettings();
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return SettingsCommands;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
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
|
|
38
|
-
*/
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
/* eslint-disable no-unused-vars */
|
|
4
|
-
/* eslint-disable require-await */
|
|
5
|
-
import {waitForCondition} from 'asyncbox';
|
|
6
|
-
import _ from 'lodash';
|
|
7
|
-
import {util} from '@appium/support';
|
|
8
|
-
import {errors} from '../../protocol';
|
|
9
|
-
|
|
10
|
-
const MIN_TIMEOUT = 0;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @template {Constraints} C
|
|
14
|
-
* @param {import('../driver').BaseDriverBase<C>} Base
|
|
15
|
-
* @returns {TimeoutBase<C>}
|
|
16
|
-
*/
|
|
17
|
-
export function TimeoutMixin(Base) {
|
|
18
|
-
/**
|
|
19
|
-
* @implements {ITimeoutCommands}
|
|
20
|
-
*/
|
|
21
|
-
class TimeoutCommands extends Base {
|
|
22
|
-
async timeouts(type, ms, script, pageLoad, implicit) {
|
|
23
|
-
if (util.hasValue(type) && util.hasValue(ms)) {
|
|
24
|
-
this.log.debug(`MJSONWP timeout arguments: ${JSON.stringify({type, ms})}}`);
|
|
25
|
-
|
|
26
|
-
switch (type) {
|
|
27
|
-
case 'command':
|
|
28
|
-
await this.newCommandTimeout(ms);
|
|
29
|
-
return;
|
|
30
|
-
case 'implicit':
|
|
31
|
-
await this.implicitWaitMJSONWP(ms);
|
|
32
|
-
return;
|
|
33
|
-
case 'page load':
|
|
34
|
-
await this.pageLoadTimeoutMJSONWP(ms);
|
|
35
|
-
return;
|
|
36
|
-
case 'script':
|
|
37
|
-
await this.scriptTimeoutMJSONWP(ms);
|
|
38
|
-
return;
|
|
39
|
-
default:
|
|
40
|
-
throw new Error(`'${type}' type is not supported for MJSONWP timeout`);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// Otherwise assume it is W3C protocol
|
|
45
|
-
this.log.debug(
|
|
46
|
-
`W3C timeout argument: ${JSON.stringify({
|
|
47
|
-
script,
|
|
48
|
-
pageLoad,
|
|
49
|
-
implicit,
|
|
50
|
-
})}}`
|
|
51
|
-
);
|
|
52
|
-
if (util.hasValue(script)) {
|
|
53
|
-
await this.scriptTimeoutW3C(script);
|
|
54
|
-
}
|
|
55
|
-
if (util.hasValue(pageLoad)) {
|
|
56
|
-
await this.pageLoadTimeoutW3C(pageLoad);
|
|
57
|
-
}
|
|
58
|
-
if (util.hasValue(implicit)) {
|
|
59
|
-
await this.implicitWaitW3C(implicit);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
async getTimeouts() {
|
|
64
|
-
return {
|
|
65
|
-
command: this.newCommandTimeoutMs,
|
|
66
|
-
implicit: this.implicitWaitMs,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// implicit
|
|
71
|
-
async implicitWaitW3C(ms) {
|
|
72
|
-
await this.implicitWait(ms);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
async implicitWaitMJSONWP(ms) {
|
|
76
|
-
await this.implicitWait(ms);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
async implicitWait(ms) {
|
|
80
|
-
await this.setImplicitWait(this.parseTimeoutArgument(ms));
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// pageLoad
|
|
84
|
-
async pageLoadTimeoutW3C(ms) {
|
|
85
|
-
throw new errors.NotImplementedError('Not implemented yet for pageLoad.');
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
async pageLoadTimeoutMJSONWP(ms) {
|
|
89
|
-
throw new errors.NotImplementedError('Not implemented yet for pageLoad.');
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// script
|
|
93
|
-
async scriptTimeoutW3C(ms) {
|
|
94
|
-
throw new errors.NotImplementedError('Not implemented yet for script.');
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
async scriptTimeoutMJSONWP(ms) {
|
|
98
|
-
throw new errors.NotImplementedError('Not implemented yet for script.');
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// command
|
|
102
|
-
async newCommandTimeout(ms) {
|
|
103
|
-
this.setNewCommandTimeout(this.parseTimeoutArgument(ms));
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
setImplicitWait(ms) {
|
|
107
|
-
// eslint-disable-line require-await
|
|
108
|
-
this.implicitWaitMs = ms;
|
|
109
|
-
this.log.debug(`Set implicit wait to ${ms}ms`);
|
|
110
|
-
if (this.managedDrivers && this.managedDrivers.length) {
|
|
111
|
-
this.log.debug('Setting implicit wait on managed drivers');
|
|
112
|
-
for (let driver of this.managedDrivers) {
|
|
113
|
-
if (_.isFunction(driver.setImplicitWait)) {
|
|
114
|
-
driver.setImplicitWait(ms);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
setNewCommandTimeout(ms) {
|
|
121
|
-
this.newCommandTimeoutMs = ms;
|
|
122
|
-
this.log.debug(`Set new command timeout to ${ms}ms`);
|
|
123
|
-
if (this.managedDrivers && this.managedDrivers.length) {
|
|
124
|
-
this.log.debug('Setting new command timeout on managed drivers');
|
|
125
|
-
for (let driver of this.managedDrivers) {
|
|
126
|
-
if (_.isFunction(driver.setNewCommandTimeout)) {
|
|
127
|
-
driver.setNewCommandTimeout(ms);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
async implicitWaitForCondition(condFn) {
|
|
134
|
-
this.log.debug(`Waiting up to ${this.implicitWaitMs} ms for condition`);
|
|
135
|
-
let wrappedCondFn = async (...args) => {
|
|
136
|
-
// reset command timeout
|
|
137
|
-
await this.clearNewCommandTimeout();
|
|
138
|
-
|
|
139
|
-
return await condFn(...args);
|
|
140
|
-
};
|
|
141
|
-
return await waitForCondition(wrappedCondFn, {
|
|
142
|
-
waitMs: this.implicitWaitMs,
|
|
143
|
-
intervalMs: 500,
|
|
144
|
-
logger: this.log,
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
parseTimeoutArgument(ms) {
|
|
149
|
-
let duration = parseInt(ms, 10);
|
|
150
|
-
if (_.isNaN(duration) || duration < MIN_TIMEOUT) {
|
|
151
|
-
throw new errors.UnknownError(`Invalid timeout value '${ms}'`);
|
|
152
|
-
}
|
|
153
|
-
return duration;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return TimeoutCommands;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
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
|
|
168
|
-
*/
|