@appium/base-driver 10.6.0 → 10.7.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 +1 -1
- package/build/lib/basedriver/capabilities.d.ts.map +1 -1
- package/build/lib/basedriver/capabilities.js +15 -7
- package/build/lib/basedriver/capabilities.js.map +1 -1
- package/build/lib/basedriver/commands/bidi.js +1 -1
- package/build/lib/basedriver/commands/event.js.map +1 -1
- package/build/lib/basedriver/commands/execute.js.map +1 -1
- package/build/lib/basedriver/commands/find.d.ts.map +1 -1
- package/build/lib/basedriver/commands/find.js +2 -1
- package/build/lib/basedriver/commands/find.js.map +1 -1
- package/build/lib/basedriver/commands/timeout.js +4 -4
- package/build/lib/basedriver/commands/timeout.js.map +1 -1
- package/build/lib/basedriver/core.d.ts.map +1 -1
- package/build/lib/basedriver/core.js +5 -2
- package/build/lib/basedriver/core.js.map +1 -1
- package/build/lib/basedriver/device-settings.d.ts.map +1 -1
- package/build/lib/basedriver/device-settings.js.map +1 -1
- package/build/lib/basedriver/driver.d.ts.map +1 -1
- package/build/lib/basedriver/driver.js +23 -24
- package/build/lib/basedriver/driver.js.map +1 -1
- package/build/lib/basedriver/extension-core.d.ts.map +1 -1
- package/build/lib/basedriver/extension-core.js +11 -5
- package/build/lib/basedriver/extension-core.js.map +1 -1
- package/build/lib/basedriver/helpers.d.ts.map +1 -1
- package/build/lib/basedriver/helpers.js +20 -4
- package/build/lib/basedriver/helpers.js.map +1 -1
- package/build/lib/basedriver/ipc.d.ts.map +1 -1
- package/build/lib/basedriver/ipc.js +6 -4
- package/build/lib/basedriver/ipc.js.map +1 -1
- package/build/lib/basedriver/validation.d.ts.map +1 -1
- package/build/lib/basedriver/validation.js +3 -2
- package/build/lib/basedriver/validation.js.map +1 -1
- package/build/lib/express/express-logging.d.ts +0 -1
- package/build/lib/express/express-logging.d.ts.map +1 -1
- package/build/lib/express/express-logging.js +9 -8
- package/build/lib/express/express-logging.js.map +1 -1
- package/build/lib/express/idempotency.js.map +1 -1
- package/build/lib/express/middleware.d.ts.map +1 -1
- package/build/lib/express/middleware.js.map +1 -1
- package/build/lib/express/server.d.ts +1 -1
- package/build/lib/express/server.d.ts.map +1 -1
- package/build/lib/express/server.js +19 -20
- package/build/lib/express/server.js.map +1 -1
- package/build/lib/express/websocket.d.ts.map +1 -1
- package/build/lib/express/websocket.js.map +1 -1
- package/build/lib/helpers/capabilities.d.ts.map +1 -1
- package/build/lib/helpers/capabilities.js.map +1 -1
- package/build/lib/helpers/levenshtein-match.d.ts.map +1 -1
- package/build/lib/helpers/levenshtein-match.js +4 -1
- package/build/lib/helpers/levenshtein-match.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 +3 -2
- package/build/lib/index.js.map +1 -1
- package/build/lib/jsonwp-proxy/protocol-converter.d.ts.map +1 -1
- package/build/lib/jsonwp-proxy/protocol-converter.js +14 -7
- 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 +17 -11
- package/build/lib/jsonwp-proxy/proxy.js.map +1 -1
- package/build/lib/protocol/errors.d.ts.map +1 -1
- package/build/lib/protocol/errors.js +13 -13
- package/build/lib/protocol/errors.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 +35 -18
- package/build/lib/protocol/protocol.js.map +1 -1
- package/build/lib/protocol/routes.d.ts.map +1 -1
- package/build/lib/protocol/routes.js +7 -5
- package/build/lib/protocol/routes.js.map +1 -1
- package/build/lib/test-pages/crash.d.ts.map +1 -0
- package/build/lib/test-pages/crash.js.map +1 -0
- package/build/lib/test-pages/env.d.ts +5 -0
- package/build/lib/test-pages/env.d.ts.map +1 -0
- package/build/lib/test-pages/env.js +12 -0
- package/build/lib/test-pages/env.js.map +1 -0
- package/build/lib/{express/static.d.ts → test-pages/handlers.d.ts} +1 -2
- package/build/lib/test-pages/handlers.d.ts.map +1 -0
- package/build/lib/{express/static.js → test-pages/handlers.js} +7 -17
- package/build/lib/test-pages/handlers.js.map +1 -0
- package/build/lib/test-pages/index.d.ts +6 -0
- package/build/lib/test-pages/index.d.ts.map +1 -0
- package/build/lib/test-pages/index.js +35 -0
- package/build/lib/test-pages/index.js.map +1 -0
- package/build/lib/test-pages/static-dir.d.ts +8 -0
- package/build/lib/test-pages/static-dir.d.ts.map +1 -0
- package/build/lib/test-pages/static-dir.js +24 -0
- package/build/lib/test-pages/static-dir.js.map +1 -0
- package/build/lib/test-pages/template.d.ts +3 -0
- package/build/lib/test-pages/template.d.ts.map +1 -0
- package/build/lib/test-pages/template.js +19 -0
- package/build/lib/test-pages/template.js.map +1 -0
- package/build/lib/utils.d.ts +0 -2
- package/build/lib/utils.d.ts.map +1 -1
- package/build/lib/utils.js +0 -16
- package/build/lib/utils.js.map +1 -1
- package/lib/basedriver/capabilities.ts +72 -66
- package/lib/basedriver/commands/bidi.ts +1 -1
- package/lib/basedriver/commands/event.ts +10 -5
- package/lib/basedriver/commands/execute.ts +12 -9
- package/lib/basedriver/commands/find.ts +20 -12
- package/lib/basedriver/commands/log.ts +2 -2
- package/lib/basedriver/commands/timeout.ts +17 -8
- package/lib/basedriver/core.ts +14 -14
- package/lib/basedriver/device-settings.ts +4 -8
- package/lib/basedriver/driver.ts +50 -40
- package/lib/basedriver/extension-core.ts +33 -17
- package/lib/basedriver/helpers.ts +57 -26
- package/lib/basedriver/ipc.ts +37 -18
- package/lib/basedriver/validation.ts +13 -6
- package/lib/express/express-logging.ts +14 -17
- package/lib/express/idempotency.ts +6 -6
- package/lib/express/middleware.ts +10 -12
- package/lib/express/server.ts +53 -61
- package/lib/express/websocket.ts +5 -7
- package/lib/helpers/capabilities.ts +5 -4
- package/lib/helpers/extension-command-name.ts +1 -1
- package/lib/helpers/levenshtein-match.ts +20 -11
- package/lib/index.js +2 -1
- package/lib/jsonwp-proxy/protocol-converter.ts +51 -27
- package/lib/jsonwp-proxy/proxy.ts +42 -42
- package/lib/protocol/errors.ts +47 -67
- package/lib/protocol/protocol.ts +116 -72
- package/lib/protocol/routes.ts +9 -9
- package/lib/test-pages/env.ts +9 -0
- package/lib/{express/static.ts → test-pages/handlers.ts} +7 -27
- package/lib/test-pages/index.ts +34 -0
- package/lib/test-pages/static-dir.ts +19 -0
- package/lib/test-pages/template.ts +17 -0
- package/lib/utils.ts +3 -23
- package/package.json +9 -10
- package/tsconfig.json +1 -0
- package/build/lib/express/crash.d.ts.map +0 -1
- package/build/lib/express/crash.js.map +0 -1
- package/build/lib/express/static.d.ts.map +0 -1
- package/build/lib/express/static.js.map +0 -1
- /package/build/lib/{express → test-pages}/crash.d.ts +0 -0
- /package/build/lib/{express → test-pages}/crash.js +0 -0
- /package/lib/{express → test-pages}/crash.ts +0 -0
- /package/{static → test-fixtures/static}/appium.png +0 -0
- /package/{static → test-fixtures/static}/favicon.ico +0 -0
- /package/{static → test-fixtures/static}/js/jquery.min.js +0 -0
- /package/{static → test-fixtures/static}/test/frameset.html +0 -0
- /package/{static → test-fixtures/static}/test/guinea-pig-app-banner.html +0 -0
- /package/{static → test-fixtures/static}/test/guinea-pig-scrollable.html +0 -0
- /package/{static → test-fixtures/static}/test/guinea-pig.html +0 -0
- /package/{static → test-fixtures/static}/test/guinea-pig2.html +0 -0
- /package/{static → test-fixtures/static}/test/guinea-pig3.html +0 -0
- /package/{static → test-fixtures/static}/test/guinea-pig4.html +0 -0
- /package/{static → test-fixtures/static}/test/guinea-pig5.html +0 -0
- /package/{static → test-fixtures/static}/test/iframes.html +0 -0
- /package/{static → test-fixtures/static}/test/shadow-dom.html +0 -0
- /package/{static → test-fixtures/static}/test/subframe1.html +0 -0
- /package/{static → test-fixtures/static}/test/subframe2.html +0 -0
- /package/{static → test-fixtures/static}/test/subframe3.html +0 -0
- /package/{static → test-fixtures/static}/test/touch.html +0 -0
- /package/{static → test-fixtures/static}/test/welcome.html +0 -0
package/build/lib/utils.js
CHANGED
|
@@ -5,7 +5,6 @@ exports.omit = omit;
|
|
|
5
5
|
exports.omitKeys = omitKeys;
|
|
6
6
|
exports.pick = pick;
|
|
7
7
|
exports.pickBy = pickBy;
|
|
8
|
-
exports.compileLodashTemplate = compileLodashTemplate;
|
|
9
8
|
const support_1 = require("@appium/support");
|
|
10
9
|
/**
|
|
11
10
|
* Deep-merge plain objects into a clone of `target`. Skips null/undefined sources.
|
|
@@ -53,19 +52,4 @@ function pick(obj, keys) {
|
|
|
53
52
|
function pickBy(obj, predicate) {
|
|
54
53
|
return Object.fromEntries(Object.entries(obj).filter(([key, value]) => predicate(value, key)));
|
|
55
54
|
}
|
|
56
|
-
/** Compile a lodash-style template string (`<%= expression %>`) into a render function. */
|
|
57
|
-
function compileLodashTemplate(template) {
|
|
58
|
-
const parts = [];
|
|
59
|
-
let lastIndex = 0;
|
|
60
|
-
const re = /<%=\s*([\s\S]+?)\s*%>/g;
|
|
61
|
-
let match;
|
|
62
|
-
while ((match = re.exec(template)) !== null) {
|
|
63
|
-
parts.push(JSON.stringify(template.slice(lastIndex, match.index)));
|
|
64
|
-
parts.push(`String(${match[1]})`);
|
|
65
|
-
lastIndex = match.index + match[0].length;
|
|
66
|
-
}
|
|
67
|
-
parts.push(JSON.stringify(template.slice(lastIndex)));
|
|
68
|
-
const fn = new Function('obj', `with (obj) { return ${parts.join(' + ')}; }`);
|
|
69
|
-
return (params) => fn(params);
|
|
70
|
-
}
|
|
71
55
|
//# sourceMappingURL=utils.js.map
|
package/build/lib/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../lib/utils.ts"],"names":[],"mappings":";;AAMA,8CAsBC;AAGD,oBAKC;AAGD,4BAMC;AAGD,oBAMC;AAGD,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../lib/utils.ts"],"names":[],"mappings":";;AAMA,8CAsBC;AAGD,oBAKC;AAGD,4BAMC;AAGD,oBAMC;AAGD,wBAOC;AAhED,6CAAqC;AAErC;;;GAGG;AACH,SAAgB,iBAAiB,CAC/B,MAAS,EACT,GAAG,OAAsC;IAEzC,MAAM,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IACvC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;YACnB,SAAS;QACX,CAAC;QACD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAClD,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAc,CAAC,CAAC;YACxC,IAAI,cAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,cAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC9D,MAAM,CAAC,GAAc,CAAC,GAAG,iBAAiB,CACxC,QAAmC,EACnC,KAAgC,CACnB,CAAC;YAClB,CAAC;iBAAM,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBAC/B,MAAM,CAAC,GAAc,CAAC,GAAG,KAAmB,CAAC;YAC/C,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,wFAAwF;AACxF,SAAgB,IAAI,CAAoC,GAAM,EAAE,GAAW;IACzE,IAAI,CAAC,cAAI,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7B,OAAO,GAAG,CAAC;IACb,CAAC;IACD,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC,CAAM,CAAC;AACjF,CAAC;AAED,4DAA4D;AAC5D,SAAgB,QAAQ,CAAoC,GAAM,EAAE,IAAuB;IACzF,IAAI,CAAC,cAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClD,OAAO,GAAG,CAAC;IACb,CAAC;IACD,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;IACjC,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAM,CAAC;AAC1F,CAAC;AAED,kEAAkE;AAClE,SAAgB,IAAI,CAClB,GAAM,EACN,IAAuB;IAEvB,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;IACjC,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAe,CAAC;AAClG,CAAC;AAED,qEAAqE;AACrE,SAAgB,MAAM,CACpB,GAAM,EACN,SAAuD;IAEvD,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,KAAmB,EAAE,GAAc,CAAC,CAAC,CAC/E,CAAC;AAClB,CAAC"}
|
|
@@ -5,10 +5,7 @@ import type {
|
|
|
5
5
|
W3CCapabilities,
|
|
6
6
|
StandardCapabilities,
|
|
7
7
|
} from '@appium/types';
|
|
8
|
-
import type {
|
|
9
|
-
KeyAsString,
|
|
10
|
-
MergeExclusive,
|
|
11
|
-
} from 'type-fest';
|
|
8
|
+
import type {KeyAsString, MergeExclusive} from 'type-fest';
|
|
12
9
|
import {validator} from './validation';
|
|
13
10
|
import {util} from '@appium/support';
|
|
14
11
|
import {omit, pickBy} from '../utils';
|
|
@@ -39,22 +36,22 @@ export function mergeCaps<
|
|
|
39
36
|
T extends Constraints,
|
|
40
37
|
U extends Constraints,
|
|
41
38
|
Primary extends Capabilities<T>,
|
|
42
|
-
Secondary extends Capabilities<U
|
|
39
|
+
Secondary extends Capabilities<U>,
|
|
43
40
|
>(
|
|
44
41
|
primary: Primary | undefined = {} as Primary,
|
|
45
|
-
secondary: Secondary | undefined = {} as Secondary
|
|
42
|
+
secondary: Secondary | undefined = {} as Secondary,
|
|
46
43
|
): MergeExclusive<Primary, Secondary> {
|
|
47
|
-
const result =
|
|
44
|
+
const result = {
|
|
48
45
|
...primary,
|
|
49
|
-
}
|
|
46
|
+
} as MergeExclusive<Primary, Secondary>;
|
|
50
47
|
|
|
51
48
|
for (const [name, value] of Object.entries(secondary)) {
|
|
52
49
|
// Overwriting is not allowed. Primary and secondary must have different properties (w3c rule 4.4)
|
|
53
50
|
if (primary[name] !== undefined) {
|
|
54
51
|
throw new errors.InvalidArgumentError(
|
|
55
52
|
`property '${name}' should not exist on both primary (${JSON.stringify(
|
|
56
|
-
primary
|
|
57
|
-
)}) and secondary (${JSON.stringify(secondary)}) object
|
|
53
|
+
primary,
|
|
54
|
+
)}) and secondary (${JSON.stringify(secondary)}) object`,
|
|
58
55
|
);
|
|
59
56
|
}
|
|
60
57
|
result[name as keyof typeof result] = value;
|
|
@@ -69,7 +66,7 @@ export function mergeCaps<
|
|
|
69
66
|
export function validateCaps<C extends Constraints>(
|
|
70
67
|
caps: Capabilities<C>,
|
|
71
68
|
constraints: C | undefined = {} as C,
|
|
72
|
-
opts: ValidateCapsOpts | undefined = {}
|
|
69
|
+
opts: ValidateCapsOpts | undefined = {},
|
|
73
70
|
): Capabilities<C> {
|
|
74
71
|
const {skipPresenceConstraint} = opts;
|
|
75
72
|
|
|
@@ -84,21 +81,27 @@ export function validateCaps<C extends Constraints>(
|
|
|
84
81
|
return [key, omit(constraint as Record<string, unknown>, 'presence')];
|
|
85
82
|
}
|
|
86
83
|
if ((constraint as {presence?: unknown}).presence === true) {
|
|
87
|
-
return [
|
|
84
|
+
return [
|
|
85
|
+
key,
|
|
86
|
+
{
|
|
87
|
+
...omit(constraint as Record<string, unknown>, 'presence'),
|
|
88
|
+
presence: {allowEmpty: false},
|
|
89
|
+
},
|
|
90
|
+
];
|
|
88
91
|
}
|
|
89
92
|
return [key, constraint];
|
|
90
|
-
})
|
|
93
|
+
}),
|
|
91
94
|
) as C;
|
|
92
95
|
|
|
93
96
|
const validationErrors = validator.validate(
|
|
94
97
|
pickBy(caps, (value) => util.hasValue(value)),
|
|
95
|
-
constraints
|
|
98
|
+
constraints,
|
|
96
99
|
);
|
|
97
100
|
|
|
98
101
|
if (validationErrors) {
|
|
99
102
|
const message: string[] = [];
|
|
100
103
|
for (const [attribute, reasons] of Object.entries(validationErrors)) {
|
|
101
|
-
for (const reason of
|
|
104
|
+
for (const reason of reasons as string[]) {
|
|
102
105
|
message.push(`'${attribute}' ${reason}`);
|
|
103
106
|
}
|
|
104
107
|
}
|
|
@@ -114,22 +117,20 @@ export function validateCaps<C extends Constraints>(
|
|
|
114
117
|
* @see https://www.w3.org/TR/webdriver2/#dfn-table-of-standard-capabilities)
|
|
115
118
|
*/
|
|
116
119
|
export const STANDARD_CAPS = Object.freeze(
|
|
117
|
-
new Set(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
]) as KeyAsString<StandardCapabilities>[]
|
|
132
|
-
)
|
|
120
|
+
new Set([
|
|
121
|
+
'browserName',
|
|
122
|
+
'browserVersion',
|
|
123
|
+
'platformName',
|
|
124
|
+
'acceptInsecureCerts',
|
|
125
|
+
'pageLoadStrategy',
|
|
126
|
+
'proxy',
|
|
127
|
+
'setWindowRect',
|
|
128
|
+
'timeouts',
|
|
129
|
+
'strictFileInteractability',
|
|
130
|
+
'unhandledPromptBehavior',
|
|
131
|
+
'userAgent',
|
|
132
|
+
'webSocketUrl',
|
|
133
|
+
] as KeyAsString<StandardCapabilities>[]),
|
|
133
134
|
);
|
|
134
135
|
|
|
135
136
|
const STANDARD_CAPS_LOWER = new Set([...STANDARD_CAPS].map((cap) => cap.toLowerCase()));
|
|
@@ -147,7 +148,9 @@ export function isStandardCap(cap: string): boolean {
|
|
|
147
148
|
* @see https://www.w3.org/TR/webdriver/#dfn-extension-capabilities
|
|
148
149
|
* @internal
|
|
149
150
|
*/
|
|
150
|
-
export function stripAppiumPrefixes<C extends Constraints>(
|
|
151
|
+
export function stripAppiumPrefixes<C extends Constraints>(
|
|
152
|
+
caps: NSCapabilities<C>,
|
|
153
|
+
): Capabilities<C> {
|
|
151
154
|
// split into prefixed and non-prefixed.
|
|
152
155
|
// non-prefixed should be standard caps at this point
|
|
153
156
|
const capKeys = Object.keys(caps);
|
|
@@ -156,13 +159,15 @@ export function stripAppiumPrefixes<C extends Constraints>(caps: NSCapabilities<
|
|
|
156
159
|
|
|
157
160
|
// initialize this with the k/v pairs of the non-prefixed caps
|
|
158
161
|
const strippedCaps: Record<string, unknown> = Object.fromEntries(
|
|
159
|
-
nonPrefixedCaps.map((cap) => [cap, caps[cap as keyof typeof caps]])
|
|
162
|
+
nonPrefixedCaps.map((cap) => [cap, caps[cap as keyof typeof caps]]),
|
|
160
163
|
) as Capabilities<C>;
|
|
161
164
|
const badPrefixedCaps: string[] = [];
|
|
162
165
|
|
|
163
166
|
// Strip out the 'appium:' prefix
|
|
164
167
|
for (const prefixedCap of prefixedCaps) {
|
|
165
|
-
const strippedCapName = prefixedCap.substring(APPIUM_VENDOR_PREFIX.length) as KeyAsString<
|
|
168
|
+
const strippedCapName = prefixedCap.substring(APPIUM_VENDOR_PREFIX.length) as KeyAsString<
|
|
169
|
+
Capabilities<C>
|
|
170
|
+
>;
|
|
166
171
|
|
|
167
172
|
// If it's standard capability that was prefixed, add it to an array of incorrectly prefixed capabilities
|
|
168
173
|
if (isStandardCap(strippedCapName)) {
|
|
@@ -172,7 +177,7 @@ export function stripAppiumPrefixes<C extends Constraints>(caps: NSCapabilities<
|
|
|
172
177
|
} else {
|
|
173
178
|
log.warn(
|
|
174
179
|
`Ignoring capability '${prefixedCap}=${caps[prefixedCap as keyof typeof caps]}' and ` +
|
|
175
|
-
`using capability '${strippedCapName}=${strippedCaps[strippedCapName]}'
|
|
180
|
+
`using capability '${strippedCapName}=${strippedCaps[strippedCapName]}'`,
|
|
176
181
|
);
|
|
177
182
|
}
|
|
178
183
|
} else {
|
|
@@ -184,8 +189,8 @@ export function stripAppiumPrefixes<C extends Constraints>(caps: NSCapabilities<
|
|
|
184
189
|
if (badPrefixedCaps.length > 0) {
|
|
185
190
|
log.warn(
|
|
186
191
|
`The capabilities ${JSON.stringify(
|
|
187
|
-
badPrefixedCaps
|
|
188
|
-
)} are standard capabilities and do not require "appium:" prefix
|
|
192
|
+
badPrefixedCaps,
|
|
193
|
+
)} are standard capabilities and do not require "appium:" prefix`,
|
|
189
194
|
);
|
|
190
195
|
}
|
|
191
196
|
return strippedCaps as Capabilities<C>;
|
|
@@ -194,20 +199,18 @@ export function stripAppiumPrefixes<C extends Constraints>(caps: NSCapabilities<
|
|
|
194
199
|
/**
|
|
195
200
|
* Get an array of all the unprefixed caps that are being used in 'alwaysMatch' and all of the 'firstMatch' object
|
|
196
201
|
*/
|
|
197
|
-
export function findNonPrefixedCaps<C extends Constraints>(
|
|
198
|
-
{
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}: W3CCapabilities<C>
|
|
202
|
-
): string[] {
|
|
202
|
+
export function findNonPrefixedCaps<C extends Constraints>({
|
|
203
|
+
alwaysMatch = {},
|
|
204
|
+
firstMatch = [],
|
|
205
|
+
}: W3CCapabilities<C>): string[] {
|
|
203
206
|
return util.uniq(
|
|
204
207
|
[alwaysMatch, ...firstMatch].reduce<string[]>(
|
|
205
208
|
(unprefixedCaps, caps) => [
|
|
206
209
|
...unprefixedCaps,
|
|
207
210
|
...Object.keys(caps).filter((cap) => !cap.includes(':') && !isStandardCap(cap)),
|
|
208
211
|
],
|
|
209
|
-
[]
|
|
210
|
-
)
|
|
212
|
+
[],
|
|
213
|
+
),
|
|
211
214
|
);
|
|
212
215
|
}
|
|
213
216
|
|
|
@@ -218,12 +221,12 @@ export function findNonPrefixedCaps<C extends Constraints>(
|
|
|
218
221
|
export function parseCaps<C extends Constraints>(
|
|
219
222
|
caps: W3CCapabilities<C>,
|
|
220
223
|
constraints: C | undefined = {} as C,
|
|
221
|
-
shouldValidateCaps: boolean | undefined = true
|
|
224
|
+
shouldValidateCaps: boolean | undefined = true,
|
|
222
225
|
): ParsedCaps<C> {
|
|
223
226
|
// If capabilities request is not an object, return error (#1.1)
|
|
224
227
|
if (!util.isPlainObject(caps)) {
|
|
225
228
|
throw new errors.InvalidArgumentError(
|
|
226
|
-
'The capabilities argument was not valid for the following reason(s): "capabilities" must be a JSON object.'
|
|
229
|
+
'The capabilities argument was not valid for the following reason(s): "capabilities" must be a JSON object.',
|
|
227
230
|
);
|
|
228
231
|
}
|
|
229
232
|
|
|
@@ -237,7 +240,7 @@ export function parseCaps<C extends Constraints>(
|
|
|
237
240
|
// Reject 'firstMatch' argument if it's not an array (#3.2)
|
|
238
241
|
if (!Array.isArray(allFirstMatchCaps)) {
|
|
239
242
|
throw new errors.InvalidArgumentError(
|
|
240
|
-
'The capabilities.firstMatch argument was not valid for the following reason(s): "capabilities.firstMatch" must be a JSON array or undefined'
|
|
243
|
+
'The capabilities.firstMatch argument was not valid for the following reason(s): "capabilities.firstMatch" must be a JSON array or undefined',
|
|
241
244
|
);
|
|
242
245
|
}
|
|
243
246
|
|
|
@@ -246,7 +249,7 @@ export function parseCaps<C extends Constraints>(
|
|
|
246
249
|
if (allFirstMatchCaps.length === 0) {
|
|
247
250
|
log.warn(
|
|
248
251
|
`The firstMatch array in the given capabilities has no entries. Adding an empty entry for now, ` +
|
|
249
|
-
`but it will require one or more entries as W3C spec
|
|
252
|
+
`but it will require one or more entries as W3C spec.`,
|
|
250
253
|
);
|
|
251
254
|
allFirstMatchCaps.push({});
|
|
252
255
|
}
|
|
@@ -255,7 +258,7 @@ export function parseCaps<C extends Constraints>(
|
|
|
255
258
|
const nonPrefixedCaps = findNonPrefixedCaps(caps);
|
|
256
259
|
if (!util.isEmpty(nonPrefixedCaps)) {
|
|
257
260
|
throw new errors.InvalidArgumentError(
|
|
258
|
-
`All non-standard capabilities should have a vendor prefix. The following capabilities did not have one: ${nonPrefixedCaps}
|
|
261
|
+
`All non-standard capabilities should have a vendor prefix. The following capabilities did not have one: ${nonPrefixedCaps}`,
|
|
259
262
|
);
|
|
260
263
|
}
|
|
261
264
|
|
|
@@ -272,7 +275,7 @@ export function parseCaps<C extends Constraints>(
|
|
|
272
275
|
// Remove the 'presence' constraint for any keys that are already present in 'requiredCaps'
|
|
273
276
|
// since we know that this constraint has already passed
|
|
274
277
|
const filteredConstraints = Object.fromEntries(
|
|
275
|
-
Object.entries(constraints ?? {}).filter(([key]) => !(key in strippedRequiredCaps))
|
|
278
|
+
Object.entries(constraints ?? {}).filter(([key]) => !(key in strippedRequiredCaps)),
|
|
276
279
|
) as C;
|
|
277
280
|
|
|
278
281
|
// Validate all of the first match capabilities and return an array with only the valid caps (see spec #5)
|
|
@@ -320,13 +323,10 @@ export function parseCaps<C extends Constraints>(
|
|
|
320
323
|
/**
|
|
321
324
|
* Calls parseCaps and just returns the matchedCaps variable
|
|
322
325
|
*/
|
|
323
|
-
export function processCapabilities<
|
|
324
|
-
C extends Constraints,
|
|
325
|
-
W3CCaps extends W3CCapabilities<C>
|
|
326
|
-
>(
|
|
326
|
+
export function processCapabilities<C extends Constraints, W3CCaps extends W3CCapabilities<C>>(
|
|
327
327
|
w3cCaps: W3CCaps,
|
|
328
328
|
constraints: C | undefined = {} as C,
|
|
329
|
-
shouldValidateCaps: boolean | undefined = true
|
|
329
|
+
shouldValidateCaps: boolean | undefined = true,
|
|
330
330
|
): Capabilities<C> {
|
|
331
331
|
const {matchedCaps, validationErrors} = parseCaps(w3cCaps, constraints, shouldValidateCaps);
|
|
332
332
|
|
|
@@ -336,8 +336,8 @@ export function processCapabilities<
|
|
|
336
336
|
// If there was more than one 'firstMatch' cap, indicate that we couldn't find a matching capabilities set and show all the errors
|
|
337
337
|
throw new errors.InvalidArgumentError(
|
|
338
338
|
`Could not find matching capabilities from ${JSON.stringify(
|
|
339
|
-
w3cCaps
|
|
340
|
-
)}:\n ${validationErrors.join('\n')}
|
|
339
|
+
w3cCaps,
|
|
340
|
+
)}:\n ${validationErrors.join('\n')}`,
|
|
341
341
|
);
|
|
342
342
|
} else {
|
|
343
343
|
// Otherwise, just show the singular error message
|
|
@@ -352,7 +352,9 @@ export function processCapabilities<
|
|
|
352
352
|
* Return a copy of a "bare" (single-level, non-W3C) capabilities object which has taken everything
|
|
353
353
|
* within the 'appium:options' capability and promoted it to the top level.
|
|
354
354
|
*/
|
|
355
|
-
export function promoteAppiumOptionsForObject<C extends Constraints>(
|
|
355
|
+
export function promoteAppiumOptionsForObject<C extends Constraints>(
|
|
356
|
+
obj: NSCapabilities<C>,
|
|
357
|
+
): NSCapabilities<C> {
|
|
356
358
|
const appiumOptions = obj[PREFIXED_APPIUM_OPTS_CAP];
|
|
357
359
|
if (!appiumOptions) {
|
|
358
360
|
return obj;
|
|
@@ -360,7 +362,7 @@ export function promoteAppiumOptionsForObject<C extends Constraints>(obj: NSCapa
|
|
|
360
362
|
|
|
361
363
|
if (!util.isPlainObject(appiumOptions)) {
|
|
362
364
|
throw new errors.SessionNotCreatedError(
|
|
363
|
-
`The ${PREFIXED_APPIUM_OPTS_CAP} capability must be an object
|
|
365
|
+
`The ${PREFIXED_APPIUM_OPTS_CAP} capability must be an object`,
|
|
364
366
|
);
|
|
365
367
|
}
|
|
366
368
|
if (util.isEmpty(appiumOptions)) {
|
|
@@ -368,7 +370,7 @@ export function promoteAppiumOptionsForObject<C extends Constraints>(obj: NSCapa
|
|
|
368
370
|
}
|
|
369
371
|
|
|
370
372
|
log.debug(
|
|
371
|
-
`Found ${PREFIXED_APPIUM_OPTS_CAP} capability present; will promote items inside to caps
|
|
373
|
+
`Found ${PREFIXED_APPIUM_OPTS_CAP} capability present; will promote items inside to caps`,
|
|
372
374
|
);
|
|
373
375
|
|
|
374
376
|
/**
|
|
@@ -378,12 +380,12 @@ export function promoteAppiumOptionsForObject<C extends Constraints>(obj: NSCapa
|
|
|
378
380
|
const verifyIfAcceptable = (capName: string) => {
|
|
379
381
|
if (typeof capName !== 'string') {
|
|
380
382
|
throw new errors.SessionNotCreatedError(
|
|
381
|
-
`Capability names in ${PREFIXED_APPIUM_OPTS_CAP} must be strings. '${capName}' is unexpected
|
|
383
|
+
`Capability names in ${PREFIXED_APPIUM_OPTS_CAP} must be strings. '${capName}' is unexpected`,
|
|
382
384
|
);
|
|
383
385
|
}
|
|
384
386
|
if (isStandardCap(capName)) {
|
|
385
387
|
throw new errors.SessionNotCreatedError(
|
|
386
|
-
`${PREFIXED_APPIUM_OPTS_CAP} must only contain vendor-specific capabilities. '${capName}' is unexpected
|
|
388
|
+
`${PREFIXED_APPIUM_OPTS_CAP} must only contain vendor-specific capabilities. '${capName}' is unexpected`,
|
|
387
389
|
);
|
|
388
390
|
}
|
|
389
391
|
return capName;
|
|
@@ -391,7 +393,9 @@ export function promoteAppiumOptionsForObject<C extends Constraints>(obj: NSCapa
|
|
|
391
393
|
const preprocessedOptions: Record<string, unknown> = {};
|
|
392
394
|
for (const [key, value] of Object.entries(appiumOptions as Record<string, unknown>)) {
|
|
393
395
|
const verifiedKey = verifyIfAcceptable(key);
|
|
394
|
-
const finalKey = shouldAddVendorPrefix(verifiedKey)
|
|
396
|
+
const finalKey = shouldAddVendorPrefix(verifiedKey)
|
|
397
|
+
? `${APPIUM_VENDOR_PREFIX}${verifiedKey}`
|
|
398
|
+
: verifiedKey;
|
|
395
399
|
preprocessedOptions[finalKey] = value;
|
|
396
400
|
}
|
|
397
401
|
// warn if we are going to overwrite any keys on the base caps object
|
|
@@ -399,7 +403,7 @@ export function promoteAppiumOptionsForObject<C extends Constraints>(obj: NSCapa
|
|
|
399
403
|
if (overwrittenKeys.length > 0) {
|
|
400
404
|
log.warn(
|
|
401
405
|
`Found capabilities inside ${PREFIXED_APPIUM_OPTS_CAP} that will overwrite ` +
|
|
402
|
-
`capabilities at the top level: ${JSON.stringify(overwrittenKeys)}
|
|
406
|
+
`capabilities at the top level: ${JSON.stringify(overwrittenKeys)}`,
|
|
403
407
|
);
|
|
404
408
|
}
|
|
405
409
|
const restObj = omit(obj, PREFIXED_APPIUM_OPTS_CAP) as NSCapabilities<C>;
|
|
@@ -413,7 +417,9 @@ export function promoteAppiumOptionsForObject<C extends Constraints>(obj: NSCapa
|
|
|
413
417
|
* Return a copy of a capabilities object which has taken everything within the 'options'
|
|
414
418
|
* capability and promoted it to the top level.
|
|
415
419
|
*/
|
|
416
|
-
export function promoteAppiumOptions<C extends Constraints>(
|
|
420
|
+
export function promoteAppiumOptions<C extends Constraints>(
|
|
421
|
+
originalCaps: W3CCapabilities<C>,
|
|
422
|
+
): W3CCapabilities<C> {
|
|
417
423
|
const result = {} as W3CCapabilities<C>;
|
|
418
424
|
const {alwaysMatch, firstMatch} = originalCaps;
|
|
419
425
|
if (util.isPlainObject(alwaysMatch)) {
|
|
@@ -16,7 +16,11 @@ const EventCommands: IEventCommands = {
|
|
|
16
16
|
* separation
|
|
17
17
|
* @param event - the event name
|
|
18
18
|
*/
|
|
19
|
-
async logCustomEvent<C extends Constraints>(
|
|
19
|
+
async logCustomEvent<C extends Constraints>(
|
|
20
|
+
this: BaseDriver<C>,
|
|
21
|
+
vendor: string,
|
|
22
|
+
event: string,
|
|
23
|
+
): Promise<void> {
|
|
20
24
|
this.logEvent(`${vendor}:${event}`);
|
|
21
25
|
},
|
|
22
26
|
|
|
@@ -26,9 +30,10 @@ const EventCommands: IEventCommands = {
|
|
|
26
30
|
* It returns all events if the type is not provided or empty string/array.
|
|
27
31
|
* @returns the event history log object
|
|
28
32
|
*/
|
|
29
|
-
async getLogEvents<C extends Constraints>(
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
async getLogEvents<C extends Constraints>(
|
|
34
|
+
this: BaseDriver<C>,
|
|
35
|
+
type: string | string[],
|
|
36
|
+
): Promise<Partial<EventHistory>> {
|
|
32
37
|
if (util.isEmpty(type)) {
|
|
33
38
|
return this.eventHistory;
|
|
34
39
|
}
|
|
@@ -42,7 +47,7 @@ const EventCommands: IEventCommands = {
|
|
|
42
47
|
}
|
|
43
48
|
return acc;
|
|
44
49
|
},
|
|
45
|
-
{}
|
|
50
|
+
{},
|
|
46
51
|
) as Record<string, number>;
|
|
47
52
|
},
|
|
48
53
|
};
|
|
@@ -17,11 +17,11 @@ declare module '../driver' {
|
|
|
17
17
|
interface BaseDriver<C extends Constraints> extends IExecuteCommands {}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
const ExecuteCommands
|
|
20
|
+
const ExecuteCommands = {
|
|
21
21
|
async executeMethod<C extends Constraints>(
|
|
22
22
|
this: BaseDriver<C>,
|
|
23
23
|
script: string,
|
|
24
|
-
protoArgs: readonly [StringRecord<unknown>] | readonly unknown[]
|
|
24
|
+
protoArgs: readonly [StringRecord<unknown>] | readonly unknown[],
|
|
25
25
|
) {
|
|
26
26
|
const Driver = this.constructor as DriverClass<Driver<C>>;
|
|
27
27
|
const commandMetadata = {...Driver.executeMethodMap?.[script]};
|
|
@@ -30,18 +30,21 @@ const ExecuteCommands: IExecuteCommands = {
|
|
|
30
30
|
if (util.isEmpty(availableScripts)) {
|
|
31
31
|
throw new errors.UnsupportedOperationError(
|
|
32
32
|
`Unsupported execute method '${script}'. ` +
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
`Make sure the installed ${Driver.name} is up-to-date. ` +
|
|
34
|
+
`The current driver version does not define any execute methods.`,
|
|
35
35
|
);
|
|
36
36
|
}
|
|
37
|
-
const {sorted: sortedMatches, suggestion} = rankLevenshteinCandidates(
|
|
37
|
+
const {sorted: sortedMatches, suggestion} = rankLevenshteinCandidates(
|
|
38
|
+
script,
|
|
39
|
+
availableScripts,
|
|
40
|
+
);
|
|
38
41
|
throw new errors.UnsupportedOperationError(
|
|
39
42
|
(suggestion
|
|
40
43
|
? `Unsupported execute method '${script}', did you mean '${suggestion}'? `
|
|
41
44
|
: `Unsupported execute method '${script}'. `) +
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
`Make sure the installed ${Driver.name} is up-to-date. ` +
|
|
46
|
+
`Execute methods available in the current driver version are: ` +
|
|
47
|
+
sortedMatches.join(', '),
|
|
45
48
|
);
|
|
46
49
|
}
|
|
47
50
|
const args = validateExecuteMethodParams(protoArgs as any[], commandMetadata.params);
|
|
@@ -49,6 +52,6 @@ const ExecuteCommands: IExecuteCommands = {
|
|
|
49
52
|
const command = this[commandName] as DriverCommand;
|
|
50
53
|
return await command.call(this, ...args);
|
|
51
54
|
},
|
|
52
|
-
};
|
|
55
|
+
} as IExecuteCommands;
|
|
53
56
|
|
|
54
57
|
mixin(ExecuteCommands);
|
|
@@ -5,7 +5,6 @@ import type {BaseDriver} from '../driver';
|
|
|
5
5
|
import {mixin} from './mixin';
|
|
6
6
|
|
|
7
7
|
declare module '../driver' {
|
|
8
|
-
|
|
9
8
|
interface BaseDriver<C extends Constraints> extends IFindCommands {}
|
|
10
9
|
}
|
|
11
10
|
|
|
@@ -14,21 +13,21 @@ async function findElOrEls<C extends Constraints>(
|
|
|
14
13
|
strategy: string,
|
|
15
14
|
selector: string,
|
|
16
15
|
mult: true,
|
|
17
|
-
context?: any
|
|
16
|
+
context?: any,
|
|
18
17
|
): Promise<Element[]>;
|
|
19
18
|
async function findElOrEls<C extends Constraints>(
|
|
20
19
|
this: BaseDriver<C>,
|
|
21
20
|
strategy: string,
|
|
22
21
|
selector: string,
|
|
23
22
|
mult: false,
|
|
24
|
-
context?: any
|
|
23
|
+
context?: any,
|
|
25
24
|
): Promise<Element>;
|
|
26
25
|
async function findElOrEls<C extends Constraints>(
|
|
27
26
|
this: BaseDriver<C>,
|
|
28
27
|
strategy: string,
|
|
29
28
|
selector: string,
|
|
30
29
|
mult: boolean,
|
|
31
|
-
context?: any
|
|
30
|
+
context?: any,
|
|
32
31
|
): Promise<Element[] | Element> {
|
|
33
32
|
throw new errors.NotImplementedError('Not implemented yet for find.');
|
|
34
33
|
}
|
|
@@ -38,21 +37,21 @@ async function findElOrElsWithProcessing<C extends Constraints>(
|
|
|
38
37
|
strategy: string,
|
|
39
38
|
selector: string,
|
|
40
39
|
mult: true,
|
|
41
|
-
context?: any
|
|
40
|
+
context?: any,
|
|
42
41
|
): Promise<Element[]>;
|
|
43
42
|
async function findElOrElsWithProcessing<C extends Constraints>(
|
|
44
43
|
this: BaseDriver<C>,
|
|
45
44
|
strategy: string,
|
|
46
45
|
selector: string,
|
|
47
46
|
mult: false,
|
|
48
|
-
context?: any
|
|
47
|
+
context?: any,
|
|
49
48
|
): Promise<Element>;
|
|
50
49
|
async function findElOrElsWithProcessing<C extends Constraints>(
|
|
51
50
|
this: BaseDriver<C>,
|
|
52
51
|
strategy: string,
|
|
53
52
|
selector: string,
|
|
54
53
|
mult: boolean,
|
|
55
|
-
context?: any
|
|
54
|
+
context?: any,
|
|
56
55
|
): Promise<Element[] | Element> {
|
|
57
56
|
this.validateLocatorStrategy(strategy);
|
|
58
57
|
try {
|
|
@@ -61,7 +60,8 @@ async function findElOrElsWithProcessing<C extends Constraints>(
|
|
|
61
60
|
} catch (err) {
|
|
62
61
|
if (this.opts.printPageSourceOnFindFailure) {
|
|
63
62
|
const src = await this.getPageSource();
|
|
64
|
-
|
|
63
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
64
|
+
this.log.debug(`Error finding element${mult ? 's' : ''}: ${message}`);
|
|
65
65
|
this.log.debug(`Page source requested through 'printPageSourceOnFindFailure':`);
|
|
66
66
|
this.log.debug(src);
|
|
67
67
|
}
|
|
@@ -71,11 +71,19 @@ async function findElOrElsWithProcessing<C extends Constraints>(
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
const FindCommands: IFindCommands = {
|
|
74
|
-
async findElement<C extends Constraints>(
|
|
74
|
+
async findElement<C extends Constraints>(
|
|
75
|
+
this: BaseDriver<C>,
|
|
76
|
+
strategy: string,
|
|
77
|
+
selector: string,
|
|
78
|
+
) {
|
|
75
79
|
return await this.findElOrElsWithProcessing(strategy, selector, false);
|
|
76
80
|
},
|
|
77
81
|
|
|
78
|
-
async findElements<C extends Constraints>(
|
|
82
|
+
async findElements<C extends Constraints>(
|
|
83
|
+
this: BaseDriver<C>,
|
|
84
|
+
strategy: string,
|
|
85
|
+
selector: string,
|
|
86
|
+
) {
|
|
79
87
|
return await this.findElOrElsWithProcessing(strategy, selector, true);
|
|
80
88
|
},
|
|
81
89
|
|
|
@@ -83,7 +91,7 @@ const FindCommands: IFindCommands = {
|
|
|
83
91
|
this: BaseDriver<C>,
|
|
84
92
|
strategy: string,
|
|
85
93
|
selector: string,
|
|
86
|
-
elementId: string
|
|
94
|
+
elementId: string,
|
|
87
95
|
) {
|
|
88
96
|
return await this.findElOrElsWithProcessing(strategy, selector, false, elementId);
|
|
89
97
|
},
|
|
@@ -92,7 +100,7 @@ const FindCommands: IFindCommands = {
|
|
|
92
100
|
this: BaseDriver<C>,
|
|
93
101
|
strategy: string,
|
|
94
102
|
selector: string,
|
|
95
|
-
elementId: string
|
|
103
|
+
elementId: string,
|
|
96
104
|
) {
|
|
97
105
|
return await this.findElOrElsWithProcessing(strategy, selector, true, elementId);
|
|
98
106
|
},
|
|
@@ -20,11 +20,11 @@ const LogCommands: ILogCommands = {
|
|
|
20
20
|
|
|
21
21
|
if (!(logType in this.supportedLogTypes)) {
|
|
22
22
|
const logsTypesWithDescriptions = Object.fromEntries(
|
|
23
|
-
Object.entries(this.supportedLogTypes).map(([key, value]) => [key, value.description])
|
|
23
|
+
Object.entries(this.supportedLogTypes).map(([key, value]) => [key, value.description]),
|
|
24
24
|
);
|
|
25
25
|
throw new Error(
|
|
26
26
|
`Unsupported log type '${String(logType)}'. ` +
|
|
27
|
-
`Supported types: ${JSON.stringify(logsTypesWithDescriptions)}
|
|
27
|
+
`Supported types: ${JSON.stringify(logsTypesWithDescriptions)}`,
|
|
28
28
|
);
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -13,19 +13,26 @@ declare module '../driver' {
|
|
|
13
13
|
const MIN_TIMEOUT = 0;
|
|
14
14
|
|
|
15
15
|
const TimeoutCommands: ITimeoutCommands = {
|
|
16
|
-
async timeouts<C extends Constraints>(
|
|
16
|
+
async timeouts<C extends Constraints>(
|
|
17
|
+
this: BaseDriver<C>,
|
|
18
|
+
type?: string,
|
|
19
|
+
ms?: number | string,
|
|
20
|
+
script?: number,
|
|
21
|
+
pageLoad?: number,
|
|
22
|
+
implicit?: number,
|
|
23
|
+
) {
|
|
17
24
|
if (type && typeof type === 'string' && util.hasValue(ms)) {
|
|
18
25
|
// legacy stuff with some Appium-specific additions
|
|
19
26
|
this.log.debug(`Timeout arguments: ${JSON.stringify({type, ms})}}`);
|
|
20
27
|
switch (type) {
|
|
21
28
|
case 'command':
|
|
22
|
-
return void (await this.newCommandTimeout(ms));
|
|
29
|
+
return void (await this.newCommandTimeout(this.parseTimeoutArgument(ms)));
|
|
23
30
|
case 'implicit':
|
|
24
|
-
return void (await this.implicitWaitW3C(ms));
|
|
31
|
+
return void (await this.implicitWaitW3C(this.parseTimeoutArgument(ms)));
|
|
25
32
|
case 'page load':
|
|
26
|
-
return void (await this.pageLoadTimeoutW3C(ms));
|
|
33
|
+
return void (await this.pageLoadTimeoutW3C(this.parseTimeoutArgument(ms)));
|
|
27
34
|
case 'script':
|
|
28
|
-
return void (await this.scriptTimeoutW3C(ms));
|
|
35
|
+
return void (await this.scriptTimeoutW3C(this.parseTimeoutArgument(ms)));
|
|
29
36
|
default:
|
|
30
37
|
throw new Error(`'${type}' type is not supported for the timeout API`);
|
|
31
38
|
}
|
|
@@ -33,7 +40,9 @@ const TimeoutCommands: ITimeoutCommands = {
|
|
|
33
40
|
|
|
34
41
|
this.log.debug(`W3C timeout argument: ${JSON.stringify({script, pageLoad, implicit})}}`);
|
|
35
42
|
if ([script, pageLoad, implicit].every((value) => value == null)) {
|
|
36
|
-
throw new errors.InvalidArgumentError(
|
|
43
|
+
throw new errors.InvalidArgumentError(
|
|
44
|
+
'W3C protocol expects any of script, pageLoad or implicit to be set',
|
|
45
|
+
);
|
|
37
46
|
}
|
|
38
47
|
if (util.hasValue(script)) {
|
|
39
48
|
await this.scriptTimeoutW3C(script);
|
|
@@ -46,7 +55,7 @@ const TimeoutCommands: ITimeoutCommands = {
|
|
|
46
55
|
}
|
|
47
56
|
},
|
|
48
57
|
|
|
49
|
-
async getTimeouts() {
|
|
58
|
+
async getTimeouts<C extends Constraints>(this: BaseDriver<C>) {
|
|
50
59
|
return {
|
|
51
60
|
command: this.newCommandTimeoutMs,
|
|
52
61
|
implicit: this.implicitWaitMs,
|
|
@@ -103,7 +112,7 @@ const TimeoutCommands: ITimeoutCommands = {
|
|
|
103
112
|
|
|
104
113
|
async implicitWaitForCondition<C extends Constraints>(
|
|
105
114
|
this: BaseDriver<C>,
|
|
106
|
-
condFn: (...args: any[]) => Promise<any
|
|
115
|
+
condFn: (...args: any[]) => Promise<any>,
|
|
107
116
|
) {
|
|
108
117
|
this.log.debug(`Waiting up to ${this.implicitWaitMs} ms for condition`);
|
|
109
118
|
const wrappedCondFn = async (...args: any[]) => {
|