@appium/types 0.4.1 → 0.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/build/action.js +84 -0
- package/build/appium-config.js +8 -0
- package/build/capabilities.d.ts +105 -26
- package/build/capabilities.d.ts.map +1 -1
- package/build/capabilities.js +2 -0
- package/build/config.js +3 -0
- package/build/constraints.d.ts +53 -0
- package/build/constraints.d.ts.map +1 -0
- package/build/constraints.js +54 -0
- package/build/driver.d.ts +39 -35
- package/build/driver.d.ts.map +1 -1
- package/build/driver.js +2 -0
- package/build/index.d.ts +4 -4
- package/build/index.d.ts.map +1 -1
- package/build/index.js +23 -0
- package/build/plugin.js +2 -0
- package/lib/capabilities.ts +164 -32
- package/lib/constraints.ts +53 -0
- package/lib/driver.ts +65 -43
- package/lib/index.ts +32 -24
- package/package.json +6 -5
package/build/action.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module
|
|
4
|
+
* Portions Copyright (c) 2017 Igor Muchychka
|
|
5
|
+
* @see https://github.com/w3c-webdriver/w3c-webdriver
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.Key = void 0;
|
|
9
|
+
/**
|
|
10
|
+
* @group Actions
|
|
11
|
+
*/
|
|
12
|
+
var Key;
|
|
13
|
+
(function (Key) {
|
|
14
|
+
Key["NULL"] = "\uE000";
|
|
15
|
+
Key["CANCEL"] = "\uE001";
|
|
16
|
+
Key["HELP"] = "\uE002";
|
|
17
|
+
Key["BACKSPACE"] = "\uE003";
|
|
18
|
+
Key["TAB"] = "\uE004";
|
|
19
|
+
Key["CLEAR"] = "\uE005";
|
|
20
|
+
Key["RETURN"] = "\uE006";
|
|
21
|
+
Key["ENTER"] = "\uE007";
|
|
22
|
+
Key["SHIFT"] = "\uE008";
|
|
23
|
+
Key["CONTROL"] = "\uE009";
|
|
24
|
+
Key["ALT"] = "\uE00A";
|
|
25
|
+
Key["PAUSE"] = "\uE00B";
|
|
26
|
+
Key["ESCAPE"] = "\uE00C";
|
|
27
|
+
Key["SPACE"] = "\uE00D";
|
|
28
|
+
Key["PAGE_UP"] = "\uE00E";
|
|
29
|
+
Key["PAGE_DOWN"] = "\uE00F";
|
|
30
|
+
Key["END"] = "\uE010";
|
|
31
|
+
Key["HOME"] = "\uE011";
|
|
32
|
+
Key["LEFT"] = "\uE012";
|
|
33
|
+
Key["UP"] = "\uE013";
|
|
34
|
+
Key["RIGHT"] = "\uE014";
|
|
35
|
+
Key["DOWN"] = "\uE015";
|
|
36
|
+
Key["INSERT"] = "\uE016";
|
|
37
|
+
Key["DELETE"] = "\uE017";
|
|
38
|
+
Key["SEMICOLON"] = "\uE018";
|
|
39
|
+
Key["EQUALS"] = "\uE019";
|
|
40
|
+
Key["NUMPAD0"] = "\uE01A";
|
|
41
|
+
Key["NUMPAD1"] = "\uE01B";
|
|
42
|
+
Key["NUMPAD2"] = "\uE01C";
|
|
43
|
+
Key["NUMPAD3"] = "\uE01D";
|
|
44
|
+
Key["NUMPAD4"] = "\uE01E";
|
|
45
|
+
Key["NUMPAD5"] = "\uE01F";
|
|
46
|
+
Key["NUMPAD6"] = "\uE020";
|
|
47
|
+
Key["NUMPAD7"] = "\uE021";
|
|
48
|
+
Key["NUMPAD8"] = "\uE022";
|
|
49
|
+
Key["NUMPAD9"] = "\uE023";
|
|
50
|
+
Key["MULTIPLY"] = "\uE024";
|
|
51
|
+
Key["ADD"] = "\uE025";
|
|
52
|
+
Key["SEPARATOR"] = "\uE026";
|
|
53
|
+
Key["SUBTRACT"] = "\uE027";
|
|
54
|
+
Key["DECIMAL"] = "\uE028";
|
|
55
|
+
Key["DIVIDE"] = "\uE029";
|
|
56
|
+
Key["F1"] = "\uE031";
|
|
57
|
+
Key["F2"] = "\uE032";
|
|
58
|
+
Key["F3"] = "\uE033";
|
|
59
|
+
Key["F4"] = "\uE034";
|
|
60
|
+
Key["F5"] = "\uE035";
|
|
61
|
+
Key["F6"] = "\uE036";
|
|
62
|
+
Key["F7"] = "\uE037";
|
|
63
|
+
Key["F8"] = "\uE038";
|
|
64
|
+
Key["F9"] = "\uE039";
|
|
65
|
+
Key["F10"] = "\uE03A";
|
|
66
|
+
Key["F11"] = "\uE03B";
|
|
67
|
+
Key["F12"] = "\uE03C";
|
|
68
|
+
Key["META"] = "\uE03D";
|
|
69
|
+
Key["ZENKAKUHANKAKU"] = "\uE040";
|
|
70
|
+
Key["R_SHIFT"] = "\uE050";
|
|
71
|
+
Key["R_CONTROL"] = "\uE051";
|
|
72
|
+
Key["R_ALT"] = "\uE052";
|
|
73
|
+
Key["R_META"] = "\uE053";
|
|
74
|
+
Key["R_PAGEUP"] = "\uE054";
|
|
75
|
+
Key["R_PAGEDOWN"] = "\uE055";
|
|
76
|
+
Key["R_END"] = "\uE056";
|
|
77
|
+
Key["R_HOME"] = "\uE057";
|
|
78
|
+
Key["R_ARROWLEFT"] = "\uE058";
|
|
79
|
+
Key["R_ARROWUP"] = "\uE059";
|
|
80
|
+
Key["R_ARROWRIGHT"] = "\uE05A";
|
|
81
|
+
Key["R_ARROWDOWN"] = "\uE05B";
|
|
82
|
+
Key["R_INSERT"] = "\uE05C";
|
|
83
|
+
Key["R_DELETE"] = "\uE05D";
|
|
84
|
+
})(Key = exports.Key || (exports.Key = {}));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/**
|
|
4
|
+
* This file was automatically generated by json-schema-to-typescript.
|
|
5
|
+
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
6
|
+
* and run json-schema-to-typescript to regenerate this file.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/build/capabilities.d.ts
CHANGED
|
@@ -1,47 +1,126 @@
|
|
|
1
1
|
import type { Capabilities as WdioCaps } from '@wdio/types';
|
|
2
|
+
import { StringRecord, Constraint, Constraints } from '.';
|
|
3
|
+
import { BaseDriverCapConstraints } from './constraints';
|
|
4
|
+
export declare type StandardCapabilities = WdioCaps.Capabilities;
|
|
5
|
+
export declare type W3C_APPIUM_PREFIX = 'appium';
|
|
2
6
|
/**
|
|
3
|
-
*
|
|
7
|
+
* Base capabilities as derived from {@linkcode BaseDriverCapConstraints}.
|
|
4
8
|
*/
|
|
5
|
-
declare type
|
|
9
|
+
export declare type BaseCapabilities = ConstraintsToCaps<BaseDriverCapConstraints>;
|
|
6
10
|
/**
|
|
7
|
-
*
|
|
11
|
+
* Like {@linkcode BaseCapabilities}, except all Appium-specific keys are namespaced.
|
|
8
12
|
*/
|
|
9
|
-
declare type
|
|
13
|
+
export declare type BaseNSCapabilities = CapsToNSCaps<ConstraintsToCaps<BaseDriverCapConstraints>>;
|
|
10
14
|
/**
|
|
11
|
-
*
|
|
15
|
+
* These may (or should) be reused by drivers.
|
|
12
16
|
*/
|
|
13
|
-
declare type
|
|
17
|
+
export declare type AppiumAndroidCapabilities = WdioCaps.AppiumAndroidCapabilities;
|
|
18
|
+
export declare type AppiumIOSCapabilities = WdioCaps.AppiumIOSCapabilities;
|
|
19
|
+
export declare type AppiumXCUICommandTimeouts = WdioCaps.AppiumXCUICommandTimeouts;
|
|
20
|
+
export declare type AppiumXCUIProcessArguments = WdioCaps.AppiumXCUIProcessArguments;
|
|
21
|
+
export declare type AppiumXCUISafariGlobalPreferences = WdioCaps.AppiumXCUISafariGlobalPreferences;
|
|
22
|
+
export declare type AppiumXCUITestCapabilities = WdioCaps.AppiumXCUITestCapabilities;
|
|
14
23
|
/**
|
|
15
|
-
*
|
|
16
|
-
* All properties are optional.
|
|
24
|
+
* Given a {@linkcode Constraint} `C` and a type `T`, see if `inclusion`/`inclusionCaseInsensitive` is present, and create a union of its allowed literals; otherwise just use `T`.
|
|
17
25
|
*/
|
|
18
|
-
declare type
|
|
26
|
+
declare type ConstraintChoice<C extends Constraint, T> = C['inclusionCaseInsensitive'] extends ReadonlyArray<T> ? AnyCase<C['inclusionCaseInsensitive'][number]> : C['inclusion'] extends ReadonlyArray<T> ? C['inclusion'][number] : T;
|
|
19
27
|
/**
|
|
20
|
-
*
|
|
28
|
+
* Given {@linkcode Constraint} `C`, determine the associated type of the capability.
|
|
29
|
+
*
|
|
30
|
+
* Notes:
|
|
21
31
|
*
|
|
22
|
-
*
|
|
32
|
+
* - Only `number` and `string` values can have "choices" (`inclusion`/`inclusionCaseInesnsitive`) associated with them.
|
|
33
|
+
* - If `isArray` is `true`, the type is always of type `string[]`. If this is incorrect, then it will be `any[]`.
|
|
34
|
+
* - There is no way to express the shape of an object if `ifObject` is `true`.
|
|
23
35
|
*/
|
|
24
|
-
|
|
36
|
+
declare type ConstraintToCapKind<C extends Constraint> = C['isString'] extends true ? ConstraintChoice<C, string> : C['isNumber'] extends true ? ConstraintChoice<C, number> : C['isBoolean'] extends true ? boolean : C['isArray'] extends true ? string[] : C['isObject'] extends true ? object : any;
|
|
25
37
|
/**
|
|
26
|
-
*
|
|
38
|
+
* Given {@linkcode Constraint} `C`, determine if it is required or optional.
|
|
39
|
+
*
|
|
40
|
+
* In practice, _all_ capabilities are considered optional per types, but various errors might be thrown if some are not present.
|
|
27
41
|
*/
|
|
28
|
-
export declare type
|
|
42
|
+
export declare type ConstraintToCap<C extends Constraint> = C['presence'] extends true | {
|
|
43
|
+
allowEmpty: boolean;
|
|
44
|
+
} ? ConstraintToCapKind<C> : ConstraintToCapKind<C> | undefined;
|
|
29
45
|
/**
|
|
30
|
-
*
|
|
31
|
-
* In practice, the properties `appium:platformName` and `appium:automationName` are required by Appium _somewhere_ in this object; this cannot be expressed in TypeScript.
|
|
46
|
+
* Given `string` `T`, this is a case-insensitive version of `T`.
|
|
32
47
|
*/
|
|
33
|
-
export declare type
|
|
34
|
-
|
|
35
|
-
|
|
48
|
+
export declare type AnyCase<T extends string> = string extends T ? string : T extends `${infer F1}${infer F2}${infer R}` ? `${Uppercase<F1> | Lowercase<F1>}${Uppercase<F2> | Lowercase<F2>}${AnyCase<R>}` : T extends `${infer F}${infer R}` ? `${Uppercase<F> | Lowercase<F>}${AnyCase<R>}` : '';
|
|
49
|
+
/**
|
|
50
|
+
* Given {@linkcode StringRecord} `T` and namespace string `NS`, a type with the key names prefixed by `${NS}:` _except_ for standard capabilities. `NS` defaults to `appium`.
|
|
51
|
+
*
|
|
52
|
+
* If `T` is already namespaced, well, it'll get _double_-namespaced.
|
|
53
|
+
*/
|
|
54
|
+
export declare type CapsToNSCaps<T extends StringRecord, NS extends string = W3C_APPIUM_PREFIX> = {
|
|
55
|
+
[K in keyof T as K extends keyof StandardCapabilities ? K : NamespacedString<K & string, NS>]: T[K];
|
|
36
56
|
};
|
|
57
|
+
export declare type NamespacedString<S extends string, NS extends string = W3C_APPIUM_PREFIX> = `${NS}:${S}`;
|
|
37
58
|
/**
|
|
38
|
-
*
|
|
59
|
+
* Converts {@linkcode Constraint} `C` to a {@linkcode Capabilities} object.
|
|
39
60
|
*/
|
|
40
|
-
export declare type
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
61
|
+
export declare type ConstraintsToCaps<C extends Constraints> = {
|
|
62
|
+
-readonly [K in keyof C]: ConstraintToCap<C[K]>;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Given some constraints, return the entire set of supported capabilities it supports (including whatever is in its desired caps).
|
|
66
|
+
*
|
|
67
|
+
* Does not contain {@linkcode BaseCapabilities}; see {@linkcode DriverCaps}.
|
|
68
|
+
*/
|
|
69
|
+
export declare type Capabilities<C extends Constraints = BaseDriverCapConstraints, Extra extends StringRecord | void = void> = Partial<ConstraintsToCaps<C> & Extra>;
|
|
70
|
+
/**
|
|
71
|
+
* Like {@linkcode Capabilities}, except W3C-style.
|
|
72
|
+
*
|
|
73
|
+
* Does not contain {@linkcode BaseCapabilities}; see {@linkcode W3CDriverCaps}.
|
|
74
|
+
*/
|
|
75
|
+
export declare type W3CCapabilities<C extends Constraints = BaseDriverCapConstraints, Extra extends StringRecord | void = void> = {
|
|
76
|
+
alwaysMatch: NSCapabilities<C, Extra>;
|
|
77
|
+
firstMatch: NSCapabilities<C, Extra>[];
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Namespaced caps (where appropriate).
|
|
81
|
+
*
|
|
82
|
+
* Does not contain {@linkcode BaseCapabilities}; see {@linkcode NSDriverCaps}.
|
|
83
|
+
*/
|
|
84
|
+
export declare type NSCapabilities<C extends Constraints = BaseDriverCapConstraints, Extra extends StringRecord | void = void, NS extends string = W3C_APPIUM_PREFIX> = Partial<CapsToNSCaps<ConstraintsToCaps<C> & Extra, NS>>;
|
|
85
|
+
/**
|
|
86
|
+
* Capabilities for drivers extending `BaseDriver`.
|
|
87
|
+
*
|
|
88
|
+
* Includes {@linkcode BaseCapabilities}.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```ts
|
|
92
|
+
* class MyDriver extends BaseDriver {
|
|
93
|
+
* async createSession (w3ccaps: W3CDriverCaps<MyDriverConstraints>, ...args: any[]) {
|
|
94
|
+
* const [
|
|
95
|
+
* sessionId: string,
|
|
96
|
+
* caps: DriverCaps<MyDriverConstraints>
|
|
97
|
+
* ] = await super.createSession(w3ccaps, ...args);
|
|
98
|
+
* // ...
|
|
99
|
+
* }
|
|
100
|
+
* }
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
export declare type DriverCaps<C extends Constraints, Extra extends StringRecord | void = void> = Capabilities<BaseDriverCapConstraints & C, Extra>;
|
|
104
|
+
/**
|
|
105
|
+
* W3C-style capabilities for drivers extending `BaseDriver`.
|
|
106
|
+
*
|
|
107
|
+
* Includes {@linkcode BaseCapabilities}.
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```ts
|
|
111
|
+
* class MyDriver extends BaseDriver {
|
|
112
|
+
* async createSession (w3ccaps: W3CDriverCaps<MyDriverConstraints>, ...args: any[]) {
|
|
113
|
+
* // ...
|
|
114
|
+
* }
|
|
115
|
+
* }
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
export declare type W3CDriverCaps<C extends Constraints, Extra extends StringRecord | void = void> = W3CCapabilities<BaseDriverCapConstraints & C, Extra>;
|
|
119
|
+
/**
|
|
120
|
+
* Namespaced capabilities for drivers extending `BaseDriver`.
|
|
121
|
+
*
|
|
122
|
+
* Includes {@linkcode BaseCapabilities}.
|
|
123
|
+
*/
|
|
124
|
+
export declare type NSDriverCaps<C extends Constraints, Extra extends StringRecord | void = void> = NSCapabilities<BaseDriverCapConstraints & C, Extra>;
|
|
46
125
|
export {};
|
|
47
126
|
//# sourceMappingURL=capabilities.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../lib/capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,IAAI,QAAQ,EAAC,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../lib/capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,IAAI,QAAQ,EAAC,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAC,YAAY,EAAE,UAAU,EAAE,WAAW,EAAC,MAAM,GAAG,CAAC;AACxD,OAAO,EAAC,wBAAwB,EAAC,MAAM,eAAe,CAAC;AAEvD,oBAAY,oBAAoB,GAAG,QAAQ,CAAC,YAAY,CAAC;AACzD,oBAAY,iBAAiB,GAAG,QAAQ,CAAC;AAEzC;;GAEG;AACH,oBAAY,gBAAgB,GAAG,iBAAiB,CAAC,wBAAwB,CAAC,CAAC;AAE3E;;GAEG;AACH,oBAAY,kBAAkB,GAAG,YAAY,CAAC,iBAAiB,CAAC,wBAAwB,CAAC,CAAC,CAAC;AAE3F;;GAEG;AACH,oBAAY,yBAAyB,GAAG,QAAQ,CAAC,yBAAyB,CAAC;A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+
readonly platformName: {
|
|
3
|
+
readonly presence: true;
|
|
4
|
+
readonly isString: true;
|
|
5
|
+
};
|
|
6
|
+
readonly app: {
|
|
7
|
+
readonly isString: true;
|
|
8
|
+
};
|
|
9
|
+
readonly deviceName: {
|
|
10
|
+
readonly isString: true;
|
|
11
|
+
};
|
|
12
|
+
readonly platformVersion: {
|
|
13
|
+
readonly isString: true;
|
|
14
|
+
};
|
|
15
|
+
readonly newCommandTimeout: {
|
|
16
|
+
readonly isNumber: true;
|
|
17
|
+
};
|
|
18
|
+
readonly automationName: {
|
|
19
|
+
readonly isString: true;
|
|
20
|
+
};
|
|
21
|
+
readonly autoLaunch: {
|
|
22
|
+
readonly isBoolean: true;
|
|
23
|
+
};
|
|
24
|
+
readonly udid: {
|
|
25
|
+
readonly isString: true;
|
|
26
|
+
};
|
|
27
|
+
readonly orientation: {
|
|
28
|
+
readonly inclusion: readonly ["LANDSCAPE", "PORTRAIT"];
|
|
29
|
+
};
|
|
30
|
+
readonly autoWebview: {
|
|
31
|
+
readonly isBoolean: true;
|
|
32
|
+
};
|
|
33
|
+
readonly noReset: {
|
|
34
|
+
readonly isBoolean: true;
|
|
35
|
+
};
|
|
36
|
+
readonly fullReset: {
|
|
37
|
+
readonly isBoolean: true;
|
|
38
|
+
};
|
|
39
|
+
readonly language: {
|
|
40
|
+
readonly isString: true;
|
|
41
|
+
};
|
|
42
|
+
readonly locale: {
|
|
43
|
+
readonly isString: true;
|
|
44
|
+
};
|
|
45
|
+
readonly eventTimings: {
|
|
46
|
+
readonly isBoolean: true;
|
|
47
|
+
};
|
|
48
|
+
readonly printPageSourceOnFindFailure: {
|
|
49
|
+
readonly isBoolean: true;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
export declare type BaseDriverCapConstraints = typeof BASE_DESIRED_CAP_CONSTRAINTS;
|
|
53
|
+
//# sourceMappingURL=constraints.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constraints.d.ts","sourceRoot":"","sources":["../lib/constraints.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkD/B,CAAC;AAEX,oBAAY,wBAAwB,GAAG,OAAO,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BASE_DESIRED_CAP_CONSTRAINTS = void 0;
|
|
4
|
+
exports.BASE_DESIRED_CAP_CONSTRAINTS = {
|
|
5
|
+
platformName: {
|
|
6
|
+
presence: true,
|
|
7
|
+
isString: true,
|
|
8
|
+
},
|
|
9
|
+
app: {
|
|
10
|
+
isString: true,
|
|
11
|
+
},
|
|
12
|
+
deviceName: {
|
|
13
|
+
isString: true,
|
|
14
|
+
},
|
|
15
|
+
platformVersion: {
|
|
16
|
+
isString: true,
|
|
17
|
+
},
|
|
18
|
+
newCommandTimeout: {
|
|
19
|
+
isNumber: true,
|
|
20
|
+
},
|
|
21
|
+
automationName: {
|
|
22
|
+
isString: true,
|
|
23
|
+
},
|
|
24
|
+
autoLaunch: {
|
|
25
|
+
isBoolean: true,
|
|
26
|
+
},
|
|
27
|
+
udid: {
|
|
28
|
+
isString: true,
|
|
29
|
+
},
|
|
30
|
+
orientation: {
|
|
31
|
+
inclusion: ['LANDSCAPE', 'PORTRAIT'],
|
|
32
|
+
},
|
|
33
|
+
autoWebview: {
|
|
34
|
+
isBoolean: true,
|
|
35
|
+
},
|
|
36
|
+
noReset: {
|
|
37
|
+
isBoolean: true,
|
|
38
|
+
},
|
|
39
|
+
fullReset: {
|
|
40
|
+
isBoolean: true,
|
|
41
|
+
},
|
|
42
|
+
language: {
|
|
43
|
+
isString: true,
|
|
44
|
+
},
|
|
45
|
+
locale: {
|
|
46
|
+
isString: true,
|
|
47
|
+
},
|
|
48
|
+
eventTimings: {
|
|
49
|
+
isBoolean: true,
|
|
50
|
+
},
|
|
51
|
+
printPageSourceOnFindFailure: {
|
|
52
|
+
isBoolean: true,
|
|
53
|
+
},
|
|
54
|
+
};
|
package/build/driver.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { EventEmitter } from 'events';
|
|
3
3
|
import { Element, ActionSequence } from './action';
|
|
4
|
-
import { HTTPMethod,
|
|
5
|
-
import { W3CCapabilities } from './capabilities';
|
|
4
|
+
import { HTTPMethod, AppiumServer, UpdateServerCallback, Class, MethodMap, AppiumLogger, StringRecord, ConstraintsToCaps, BaseDriverCapConstraints, W3CCapabilities, Capabilities } from '.';
|
|
6
5
|
import { ServerArgs } from './config';
|
|
7
6
|
export interface TimeoutCommands {
|
|
8
7
|
timeouts(type: string, ms: number | string, script?: number, pageLoad?: number, implicit?: number | string): Promise<void>;
|
|
@@ -29,7 +28,7 @@ export interface SessionCommands {
|
|
|
29
28
|
getSession(): Promise<SingularSessionData>;
|
|
30
29
|
}
|
|
31
30
|
export interface ExecuteCommands {
|
|
32
|
-
executeMethod(script: string, args: [
|
|
31
|
+
executeMethod(script: string, args: [StringRecord] | []): Promise<any>;
|
|
33
32
|
}
|
|
34
33
|
export interface ExecuteMethodDef {
|
|
35
34
|
command: string;
|
|
@@ -39,12 +38,13 @@ export interface ExecuteMethodDef {
|
|
|
39
38
|
};
|
|
40
39
|
}
|
|
41
40
|
export declare type ExecuteMethodMap = Record<string, ExecuteMethodDef>;
|
|
42
|
-
export interface MultiSessionData {
|
|
41
|
+
export interface MultiSessionData<C extends Constraints = BaseDriverCapConstraints, Extra extends StringRecord | void = void> {
|
|
43
42
|
id: string;
|
|
44
|
-
capabilities: Capabilities
|
|
43
|
+
capabilities: Capabilities<C, Extra>;
|
|
45
44
|
}
|
|
46
|
-
export declare type SingularSessionData = Capabilities & {
|
|
45
|
+
export declare type SingularSessionData<C extends Constraints = BaseDriverCapConstraints, Extra extends StringRecord | void = void> = Capabilities<C, Extra> & {
|
|
47
46
|
events?: EventHistory;
|
|
47
|
+
error?: string;
|
|
48
48
|
};
|
|
49
49
|
export interface FindCommands {
|
|
50
50
|
findElement(strategy: string, selector: string): Promise<Element>;
|
|
@@ -68,11 +68,11 @@ export interface LogCommands {
|
|
|
68
68
|
getLog(logType: string): Promise<any[]>;
|
|
69
69
|
}
|
|
70
70
|
export interface SettingsCommands {
|
|
71
|
-
updateSettings: (settings:
|
|
72
|
-
getSettings(): Promise<
|
|
71
|
+
updateSettings: (settings: StringRecord) => Promise<void>;
|
|
72
|
+
getSettings(): Promise<StringRecord>;
|
|
73
73
|
}
|
|
74
|
-
export interface SessionHandler<CreateResult, DeleteResult> {
|
|
75
|
-
createSession(w3cCaps1: W3CCapabilities, w3cCaps2?: W3CCapabilities, w3cCaps?: W3CCapabilities, driverData?: DriverData[]): Promise<CreateResult>;
|
|
74
|
+
export interface SessionHandler<CreateResult, DeleteResult, C extends Constraints = BaseDriverCapConstraints, Extra extends StringRecord | void = void> {
|
|
75
|
+
createSession(w3cCaps1: W3CCapabilities<C, Extra>, w3cCaps2?: W3CCapabilities<C, Extra>, w3cCaps?: W3CCapabilities<C, Extra>, driverData?: DriverData[]): Promise<CreateResult>;
|
|
76
76
|
deleteSession(sessionId?: string, driverData?: DriverData[]): Promise<DeleteResult>;
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
@@ -93,25 +93,25 @@ export declare type DriverData = Record<string, unknown>;
|
|
|
93
93
|
* }
|
|
94
94
|
*/
|
|
95
95
|
export interface Constraint {
|
|
96
|
-
presence?: boolean | {
|
|
96
|
+
readonly presence?: boolean | Readonly<{
|
|
97
97
|
allowEmpty: boolean;
|
|
98
|
-
}
|
|
99
|
-
isString?: boolean;
|
|
100
|
-
isNumber?: boolean;
|
|
101
|
-
isBoolean?: boolean;
|
|
102
|
-
isObject?: boolean;
|
|
103
|
-
isArray?: boolean;
|
|
104
|
-
deprecated?: boolean;
|
|
105
|
-
inclusion?: any[]
|
|
106
|
-
inclusionCaseInsensitive?: any[]
|
|
98
|
+
}>;
|
|
99
|
+
readonly isString?: boolean;
|
|
100
|
+
readonly isNumber?: boolean;
|
|
101
|
+
readonly isBoolean?: boolean;
|
|
102
|
+
readonly isObject?: boolean;
|
|
103
|
+
readonly isArray?: boolean;
|
|
104
|
+
readonly deprecated?: boolean;
|
|
105
|
+
readonly inclusion?: Readonly<[any, ...any[]]>;
|
|
106
|
+
readonly inclusionCaseInsensitive?: Readonly<[any, ...any[]]>;
|
|
107
107
|
}
|
|
108
|
-
export declare type Constraints = Record<string, Constraint
|
|
109
|
-
export interface DriverHelpers {
|
|
108
|
+
export declare type Constraints = Readonly<Record<string, Constraint>>;
|
|
109
|
+
export interface DriverHelpers<C extends Constraints> {
|
|
110
110
|
configureApp: (app: string, supportedAppExtensions: string[]) => Promise<string>;
|
|
111
111
|
isPackageOrBundle: (app: string) => boolean;
|
|
112
112
|
duplicateKeys: <T>(input: T, firstKey: string, secondKey: string) => T;
|
|
113
113
|
parseCapsArray: (cap: string | string[]) => string[];
|
|
114
|
-
generateDriverLogPrefix: (obj: Core
|
|
114
|
+
generateDriverLogPrefix: (obj: Core<C>, sessionId?: string) => string;
|
|
115
115
|
}
|
|
116
116
|
export declare type SettingsUpdateListener<T extends Record<string, unknown> = Record<string, unknown>> = (prop: keyof T, newValue: unknown, curValue: unknown) => Promise<void>;
|
|
117
117
|
export interface DeviceSettings<T = any> {
|
|
@@ -193,15 +193,13 @@ export interface EventHistoryCommand {
|
|
|
193
193
|
*
|
|
194
194
|
* This should not be used directly by external code.
|
|
195
195
|
*/
|
|
196
|
-
export interface Core {
|
|
196
|
+
export interface Core<C extends Constraints = BaseDriverCapConstraints> {
|
|
197
197
|
shouldValidateCaps: boolean;
|
|
198
198
|
sessionId: string | null;
|
|
199
|
-
opts: DriverOpts
|
|
199
|
+
opts: DriverOpts<C>;
|
|
200
200
|
initialOpts: ServerArgs;
|
|
201
|
-
caps?: Capabilities;
|
|
202
|
-
originalCaps?: W3CCapabilities;
|
|
203
201
|
protocol?: string;
|
|
204
|
-
helpers: DriverHelpers
|
|
202
|
+
helpers: DriverHelpers<C>;
|
|
205
203
|
basePath: string;
|
|
206
204
|
relaxedSecurityEnabled: boolean;
|
|
207
205
|
allowInsecure: string[];
|
|
@@ -232,21 +230,23 @@ export interface Core {
|
|
|
232
230
|
getManagedDrivers(): Driver[];
|
|
233
231
|
clearNewCommandTimeout(): Promise<void>;
|
|
234
232
|
logEvent(eventName: string): void;
|
|
235
|
-
driverForSession(sessionId: string): Core | null;
|
|
233
|
+
driverForSession(sessionId: string): Core<C> | null;
|
|
236
234
|
}
|
|
237
235
|
/**
|
|
238
236
|
* `BaseDriver` implements this. It contains default behavior;
|
|
239
237
|
* external drivers are expected to implement {@linkcode ExternalDriver} instead.
|
|
240
238
|
*/
|
|
241
|
-
export interface Driver extends SessionCommands, LogCommands, FindCommands, SettingsCommands, TimeoutCommands, EventCommands, SessionHandler<[string, any], void>, ExecuteCommands, Core {
|
|
242
|
-
cliArgs?:
|
|
239
|
+
export interface Driver<C extends Constraints = BaseDriverCapConstraints, A extends StringRecord = StringRecord> extends SessionCommands, LogCommands, FindCommands, SettingsCommands, TimeoutCommands, EventCommands, SessionHandler<[string, any], void, C>, ExecuteCommands, Core {
|
|
240
|
+
cliArgs?: A;
|
|
243
241
|
executeCommand(cmd: string, ...args: any[]): Promise<any>;
|
|
244
242
|
startUnexpectedShutdown(err?: Error): Promise<void>;
|
|
245
243
|
startNewCommandTimeout(): Promise<void>;
|
|
246
244
|
reset(): Promise<void>;
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
245
|
+
caps?: Capabilities<C>;
|
|
246
|
+
originalCaps?: W3CCapabilities<C>;
|
|
247
|
+
desiredCapConstraints: C;
|
|
248
|
+
validateDesiredCaps(caps: Capabilities<C>): boolean;
|
|
249
|
+
logExtraCaps(caps: Capabilities<C>): void;
|
|
250
250
|
assignServer?(server: AppiumServer, host: string, port: number, path: string): void;
|
|
251
251
|
}
|
|
252
252
|
/**
|
|
@@ -424,12 +424,16 @@ export interface DriverStatic {
|
|
|
424
424
|
* This is likely unusable by external consumers, but YMMV!
|
|
425
425
|
*/
|
|
426
426
|
export declare type DriverClass<D extends Driver = ExternalDriver, S extends DriverStatic = DriverStatic> = Class<D, S, [] | [Partial<ServerArgs>] | [Partial<ServerArgs>, boolean]>;
|
|
427
|
+
export interface ExtraDriverOpts {
|
|
428
|
+
fastReset?: boolean;
|
|
429
|
+
skipUninstall?: boolean;
|
|
430
|
+
}
|
|
427
431
|
/**
|
|
428
432
|
* Options as passed into a driver constructor, which is just a union of {@linkcode ServerArgs} and {@linkcode Capabilities}.
|
|
429
433
|
*
|
|
430
434
|
* The combination happens within Appium prior to calling the constructor.
|
|
431
435
|
*/
|
|
432
|
-
export declare type DriverOpts = ServerArgs &
|
|
436
|
+
export declare type DriverOpts<C extends Constraints = BaseDriverCapConstraints> = ServerArgs & ExtraDriverOpts & Partial<ConstraintsToCaps<C>>;
|
|
433
437
|
export declare type DriverCommand<TArgs = any, TReturn = unknown> = (...args: TArgs[]) => Promise<TReturn>;
|
|
434
438
|
export declare type DriverCommands<TArgs = any, TReturn = unknown> = Record<string, DriverCommand<TArgs, TReturn>>;
|
|
435
439
|
/**
|