appium-xcuitest-driver 10.14.2 → 10.14.3
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/CHANGELOG.md +6 -0
- package/build/lib/commands/alert.d.ts +26 -31
- package/build/lib/commands/alert.d.ts.map +1 -1
- package/build/lib/commands/alert.js +20 -29
- package/build/lib/commands/alert.js.map +1 -1
- package/build/lib/commands/appearance.d.ts +7 -9
- package/build/lib/commands/appearance.d.ts.map +1 -1
- package/build/lib/commands/appearance.js +13 -19
- package/build/lib/commands/appearance.js.map +1 -1
- package/build/lib/commands/permissions.d.ts +15 -17
- package/build/lib/commands/permissions.d.ts.map +1 -1
- package/build/lib/commands/permissions.js +12 -18
- package/build/lib/commands/permissions.js.map +1 -1
- package/build/lib/commands/proxy-helper.d.ts +11 -11
- package/build/lib/commands/proxy-helper.d.ts.map +1 -1
- package/build/lib/commands/proxy-helper.js +15 -24
- package/build/lib/commands/proxy-helper.js.map +1 -1
- package/build/lib/commands/simctl.d.ts +16 -22
- package/build/lib/commands/simctl.d.ts.map +1 -1
- package/build/lib/commands/simctl.js +8 -17
- package/build/lib/commands/simctl.js.map +1 -1
- package/build/lib/commands/timeouts.d.ts +25 -32
- package/build/lib/commands/timeouts.d.ts.map +1 -1
- package/build/lib/commands/timeouts.js +18 -14
- package/build/lib/commands/timeouts.js.map +1 -1
- package/lib/commands/alert.ts +98 -0
- package/lib/commands/appearance.ts +70 -0
- package/lib/commands/permissions.ts +90 -0
- package/lib/commands/{proxy-helper.js → proxy-helper.ts} +26 -26
- package/lib/commands/{simctl.js → simctl.ts} +27 -21
- package/lib/commands/timeouts.ts +95 -0
- package/npm-shrinkwrap.json +5 -5
- package/package.json +1 -1
- package/lib/commands/alert.js +0 -88
- package/lib/commands/appearance.js +0 -71
- package/lib/commands/permissions.js +0 -85
- package/lib/commands/timeouts.js +0 -68
|
@@ -1,27 +1,21 @@
|
|
|
1
|
+
import type { XCUITestDriver } from '../driver';
|
|
2
|
+
export interface SimctlExecResponse {
|
|
3
|
+
/** The output of standard out. */
|
|
4
|
+
stdout: string;
|
|
5
|
+
/** The output of standard error. */
|
|
6
|
+
stderr: string;
|
|
7
|
+
/** Return code. */
|
|
8
|
+
code: number;
|
|
9
|
+
}
|
|
1
10
|
/**
|
|
2
11
|
* Run the given command with arguments as `xcrun simctl` subcommand.
|
|
3
12
|
* This method works behind the 'simctl' security flag.
|
|
4
|
-
*
|
|
5
|
-
* @param
|
|
6
|
-
* @param
|
|
7
|
-
* @param
|
|
8
|
-
* @returns
|
|
9
|
-
* @throws
|
|
13
|
+
*
|
|
14
|
+
* @param command - Subcommand to run with `xcrun simctl`. Must be one of the supported commands.
|
|
15
|
+
* @param args - Arguments for the subcommand. The arguments should be after <device> in the help.
|
|
16
|
+
* @param timeout - The maximum number of milliseconds
|
|
17
|
+
* @returns The execution result with stdout, stderr, and return code
|
|
18
|
+
* @throws If the simctl subcommand command returns non-zero return code, or the given subcommand was invalid.
|
|
10
19
|
*/
|
|
11
|
-
export function mobileSimctl(this:
|
|
12
|
-
export type SimctlExecResponse = {
|
|
13
|
-
/**
|
|
14
|
-
* The output of standard out.
|
|
15
|
-
*/
|
|
16
|
-
stdout: string;
|
|
17
|
-
/**
|
|
18
|
-
* The output of standard error.
|
|
19
|
-
*/
|
|
20
|
-
stderr: string;
|
|
21
|
-
/**
|
|
22
|
-
* Return code.
|
|
23
|
-
*/
|
|
24
|
-
code: number;
|
|
25
|
-
};
|
|
26
|
-
export type XCUITestDriver = import("../driver").XCUITestDriver;
|
|
20
|
+
export declare function mobileSimctl(this: XCUITestDriver, command: string, args?: string[], timeout?: number): Promise<SimctlExecResponse>;
|
|
27
21
|
//# sourceMappingURL=simctl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simctl.d.ts","sourceRoot":"","sources":["../../../lib/commands/simctl.
|
|
1
|
+
{"version":3,"file":"simctl.d.ts","sourceRoot":"","sources":["../../../lib/commands/simctl.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,WAAW,CAAC;AAgC9C,MAAM,WAAW,kBAAkB;IACjC,kCAAkC;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,oCAAoC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;GASG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE,MAAM,EACf,IAAI,GAAE,MAAM,EAAO,EACnB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,kBAAkB,CAAC,CAuB7B"}
|
|
@@ -33,14 +33,14 @@ const SUBCOMMANDS_HAS_DEVICE = [
|
|
|
33
33
|
/**
|
|
34
34
|
* Run the given command with arguments as `xcrun simctl` subcommand.
|
|
35
35
|
* This method works behind the 'simctl' security flag.
|
|
36
|
-
*
|
|
37
|
-
* @param
|
|
38
|
-
* @param
|
|
39
|
-
* @param
|
|
40
|
-
* @returns
|
|
41
|
-
* @throws
|
|
36
|
+
*
|
|
37
|
+
* @param command - Subcommand to run with `xcrun simctl`. Must be one of the supported commands.
|
|
38
|
+
* @param args - Arguments for the subcommand. The arguments should be after <device> in the help.
|
|
39
|
+
* @param timeout - The maximum number of milliseconds
|
|
40
|
+
* @returns The execution result with stdout, stderr, and return code
|
|
41
|
+
* @throws If the simctl subcommand command returns non-zero return code, or the given subcommand was invalid.
|
|
42
42
|
*/
|
|
43
|
-
async function mobileSimctl(command, args = [], timeout
|
|
43
|
+
async function mobileSimctl(command, args = [], timeout) {
|
|
44
44
|
if (!this.isSimulator()) {
|
|
45
45
|
throw new driver_1.errors.UnsupportedOperationError(`Only simulator is supported.`);
|
|
46
46
|
}
|
|
@@ -51,20 +51,11 @@ async function mobileSimctl(command, args = [], timeout = undefined) {
|
|
|
51
51
|
throw new driver_1.errors.InvalidArgumentError(`The given command '${command}' is not supported. ` +
|
|
52
52
|
`Available subcommands are ${SUBCOMMANDS_HAS_DEVICE.join(',')}`);
|
|
53
53
|
}
|
|
54
|
-
const result = await
|
|
54
|
+
const result = await this.device.simctl.exec(command, { args: [this.opts.udid, ...args], timeout });
|
|
55
55
|
return {
|
|
56
56
|
stdout: result?.stdout ?? '',
|
|
57
57
|
stderr: result?.stderr ?? '',
|
|
58
58
|
code: result?.code ?? 0
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
|
-
/**
|
|
62
|
-
* @typedef {Object} SimctlExecResponse
|
|
63
|
-
* @property {string} stdout The output of standard out.
|
|
64
|
-
* @property {string} stderr The output of standard error.
|
|
65
|
-
* @property {number} code Return code.
|
|
66
|
-
*/
|
|
67
|
-
/**
|
|
68
|
-
* @typedef {import('../driver').XCUITestDriver} XCUITestDriver
|
|
69
|
-
*/
|
|
70
61
|
//# sourceMappingURL=simctl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simctl.js","sourceRoot":"","sources":["../../../lib/commands/simctl.
|
|
1
|
+
{"version":3,"file":"simctl.js","sourceRoot":"","sources":["../../../lib/commands/simctl.ts"],"names":[],"mappings":";;AAoDA,oCA4BC;AAhFD,0CAAuC;AAIvC;;;GAGG;AACH,MAAM,sBAAsB,GAAG;IAC7B,MAAM;IACN,mBAAmB;IACnB,QAAQ;IACR,aAAa;IACb,SAAS;IACT,kBAAkB;IAClB,IAAI;IACJ,UAAU;IACV,QAAQ;IACR,UAAU;IACV,YAAY;IACZ,SAAS;IACT,QAAQ;IACR,SAAS;IACT,SAAS;IACT,MAAM;IACN,UAAU;IACV,OAAO;IACP,YAAY;IACZ,WAAW;IACX,IAAI;IACJ,WAAW;CACH,CAAC;AAWX;;;;;;;;;GASG;AACI,KAAK,UAAU,YAAY,CAEhC,OAAe,EACf,OAAiB,EAAE,EACnB,OAAgB;IAEhB,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;QACxB,MAAM,IAAI,eAAM,CAAC,yBAAyB,CAAC,8BAA8B,CAAC,CAAC;IAC7E,CAAC;IAED,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QACpB,MAAM,IAAI,eAAM,CAAC,oBAAoB,CAAC,sCAAsC,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;IACjG,CAAC;IAED,IAAI,CAAE,sBAA4C,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACrE,MAAM,IAAI,eAAM,CAAC,oBAAoB,CAAC,sBAAsB,OAAO,sBAAsB;YACvF,6BAA6B,sBAAsB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACrE,CAAC;IAED,MAAM,MAAM,GAAG,MAAO,IAAI,CAAC,MAAoB,CAAC,MAAM,CAAC,IAAI,CACzD,OAAgD,EAChD,EAAC,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,EAAE,OAAO,EAAC,CAC3C,CAAC;IACF,OAAO;QACL,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,EAAE;QAC5B,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,EAAE;QAC5B,IAAI,EAAE,MAAM,EAAE,IAAI,IAAI,CAAC;KACxB,CAAC;AACJ,CAAC"}
|
|
@@ -1,53 +1,46 @@
|
|
|
1
|
+
import type { XCUITestDriver } from '../driver';
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
+
* Sets the page load timeout using W3C protocol.
|
|
4
|
+
*
|
|
5
|
+
* @param ms - Timeout in milliseconds
|
|
3
6
|
*/
|
|
4
|
-
export function pageLoadTimeoutW3C(this:
|
|
7
|
+
export declare function pageLoadTimeoutW3C(this: XCUITestDriver, ms: number): Promise<void>;
|
|
5
8
|
/**
|
|
6
|
-
*
|
|
9
|
+
* Sets the page load timeout using MJSONWP protocol.
|
|
10
|
+
*
|
|
11
|
+
* @param ms - Timeout in milliseconds
|
|
7
12
|
*/
|
|
8
|
-
export function pageLoadTimeoutMJSONWP(this:
|
|
13
|
+
export declare function pageLoadTimeoutMJSONWP(this: XCUITestDriver, ms: number): Promise<void>;
|
|
9
14
|
/**
|
|
10
|
-
*
|
|
15
|
+
* Sets the async script timeout using W3C protocol.
|
|
16
|
+
*
|
|
17
|
+
* @param ms - Timeout in milliseconds
|
|
11
18
|
*/
|
|
12
|
-
export function scriptTimeoutW3C(this:
|
|
19
|
+
export declare function scriptTimeoutW3C(this: XCUITestDriver, ms: number): Promise<void>;
|
|
13
20
|
/**
|
|
14
21
|
* Alias for {@linkcode XCUITestDriver.scriptTimeoutW3C}.
|
|
15
22
|
*
|
|
16
|
-
* @param
|
|
17
|
-
* @this {XCUITestDriver}
|
|
23
|
+
* @param ms - The timeout in milliseconds
|
|
18
24
|
* @deprecated Use {@linkcode XCUITestDriver.scriptTimeoutW3C} instead
|
|
19
25
|
*/
|
|
20
|
-
export function scriptTimeoutMJSONWP(this:
|
|
26
|
+
export declare function scriptTimeoutMJSONWP(this: XCUITestDriver, ms: number): Promise<void>;
|
|
21
27
|
/**
|
|
22
28
|
* Alias for {@linkcode XCUITestDriver.scriptTimeoutW3C}.
|
|
23
29
|
*
|
|
24
|
-
* @param
|
|
25
|
-
*
|
|
30
|
+
* @param ms - The timeout in milliseconds
|
|
26
31
|
* @deprecated Use {@linkcode XCUITestDriver.scriptTimeoutW3C} instead
|
|
27
|
-
* @this {XCUITestDriver}
|
|
28
32
|
*/
|
|
29
|
-
export function asyncScriptTimeout(this:
|
|
33
|
+
export declare function asyncScriptTimeout(this: XCUITestDriver, ms: number): Promise<void>;
|
|
30
34
|
/**
|
|
31
|
-
*
|
|
35
|
+
* Sets the page load timeout.
|
|
36
|
+
*
|
|
37
|
+
* @param ms - Timeout in milliseconds
|
|
32
38
|
*/
|
|
33
|
-
export function setPageLoadTimeout(this:
|
|
34
|
-
export class setPageLoadTimeout {
|
|
35
|
-
/**
|
|
36
|
-
* @this {XCUITestDriver}
|
|
37
|
-
*/
|
|
38
|
-
constructor(this: import("../driver").XCUITestDriver, ms: any);
|
|
39
|
-
pageLoadMs: any;
|
|
40
|
-
}
|
|
39
|
+
export declare function setPageLoadTimeout(this: XCUITestDriver, ms: number): void;
|
|
41
40
|
/**
|
|
42
|
-
*
|
|
41
|
+
* Sets the async script timeout.
|
|
42
|
+
*
|
|
43
|
+
* @param ms - Timeout in milliseconds
|
|
43
44
|
*/
|
|
44
|
-
export function setAsyncScriptTimeout(this:
|
|
45
|
-
export class setAsyncScriptTimeout {
|
|
46
|
-
/**
|
|
47
|
-
* @this {XCUITestDriver}
|
|
48
|
-
*/
|
|
49
|
-
constructor(this: import("../driver").XCUITestDriver, ms: any);
|
|
50
|
-
asyncWaitMs: any;
|
|
51
|
-
}
|
|
52
|
-
export type XCUITestDriver = import("../driver").XCUITestDriver;
|
|
45
|
+
export declare function setAsyncScriptTimeout(this: XCUITestDriver, ms: number): void;
|
|
53
46
|
//# sourceMappingURL=timeouts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeouts.d.ts","sourceRoot":"","sources":["../../../lib/commands/timeouts.
|
|
1
|
+
{"version":3,"file":"timeouts.d.ts","sourceRoot":"","sources":["../../../lib/commands/timeouts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,WAAW,CAAC;AAE9C;;;;GAIG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,cAAc,EACpB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,IAAI,CAAC,CAEf;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,cAAc,EACpB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,IAAI,CAAC,CAEf;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,cAAc,EACpB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,IAAI,CAAC,CAGf;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,cAAc,EACpB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,IAAI,CAAC,CAEf;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,cAAc,EACpB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,IAAI,CAAC,CAEf;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,cAAc,EACpB,EAAE,EAAE,MAAM,GACT,IAAI,CAON;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,cAAc,EACpB,EAAE,EAAE,MAAM,GACT,IAAI,CAGN"}
|
|
@@ -8,19 +8,25 @@ exports.asyncScriptTimeout = asyncScriptTimeout;
|
|
|
8
8
|
exports.setPageLoadTimeout = setPageLoadTimeout;
|
|
9
9
|
exports.setAsyncScriptTimeout = setAsyncScriptTimeout;
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Sets the page load timeout using W3C protocol.
|
|
12
|
+
*
|
|
13
|
+
* @param ms - Timeout in milliseconds
|
|
12
14
|
*/
|
|
13
15
|
async function pageLoadTimeoutW3C(ms) {
|
|
14
16
|
await this.setPageLoadTimeout(this.parseTimeoutArgument(ms));
|
|
15
17
|
}
|
|
16
18
|
/**
|
|
17
|
-
*
|
|
19
|
+
* Sets the page load timeout using MJSONWP protocol.
|
|
20
|
+
*
|
|
21
|
+
* @param ms - Timeout in milliseconds
|
|
18
22
|
*/
|
|
19
23
|
async function pageLoadTimeoutMJSONWP(ms) {
|
|
20
24
|
await this.setPageLoadTimeout(this.parseTimeoutArgument(ms));
|
|
21
25
|
}
|
|
22
26
|
/**
|
|
23
|
-
*
|
|
27
|
+
* Sets the async script timeout using W3C protocol.
|
|
28
|
+
*
|
|
29
|
+
* @param ms - Timeout in milliseconds
|
|
24
30
|
*/
|
|
25
31
|
async function scriptTimeoutW3C(ms) {
|
|
26
32
|
// XXX: this is synchronous
|
|
@@ -29,8 +35,7 @@ async function scriptTimeoutW3C(ms) {
|
|
|
29
35
|
/**
|
|
30
36
|
* Alias for {@linkcode XCUITestDriver.scriptTimeoutW3C}.
|
|
31
37
|
*
|
|
32
|
-
* @param
|
|
33
|
-
* @this {XCUITestDriver}
|
|
38
|
+
* @param ms - The timeout in milliseconds
|
|
34
39
|
* @deprecated Use {@linkcode XCUITestDriver.scriptTimeoutW3C} instead
|
|
35
40
|
*/
|
|
36
41
|
async function scriptTimeoutMJSONWP(ms) {
|
|
@@ -39,19 +44,19 @@ async function scriptTimeoutMJSONWP(ms) {
|
|
|
39
44
|
/**
|
|
40
45
|
* Alias for {@linkcode XCUITestDriver.scriptTimeoutW3C}.
|
|
41
46
|
*
|
|
42
|
-
* @param
|
|
43
|
-
*
|
|
47
|
+
* @param ms - The timeout in milliseconds
|
|
44
48
|
* @deprecated Use {@linkcode XCUITestDriver.scriptTimeoutW3C} instead
|
|
45
|
-
* @this {XCUITestDriver}
|
|
46
49
|
*/
|
|
47
50
|
async function asyncScriptTimeout(ms) {
|
|
48
51
|
await this.scriptTimeoutW3C(ms);
|
|
49
52
|
}
|
|
50
53
|
/**
|
|
51
|
-
*
|
|
54
|
+
* Sets the page load timeout.
|
|
55
|
+
*
|
|
56
|
+
* @param ms - Timeout in milliseconds
|
|
52
57
|
*/
|
|
53
58
|
function setPageLoadTimeout(ms) {
|
|
54
|
-
ms = parseInt(ms, 10);
|
|
59
|
+
ms = parseInt(String(ms), 10);
|
|
55
60
|
this.pageLoadMs = ms;
|
|
56
61
|
if (this._remote) {
|
|
57
62
|
this.remote.pageLoadMs = ms;
|
|
@@ -59,13 +64,12 @@ function setPageLoadTimeout(ms) {
|
|
|
59
64
|
this.log.debug(`Set page load timeout to ${ms}ms`);
|
|
60
65
|
}
|
|
61
66
|
/**
|
|
62
|
-
*
|
|
67
|
+
* Sets the async script timeout.
|
|
68
|
+
*
|
|
69
|
+
* @param ms - Timeout in milliseconds
|
|
63
70
|
*/
|
|
64
71
|
function setAsyncScriptTimeout(ms) {
|
|
65
72
|
this.asyncWaitMs = ms;
|
|
66
73
|
this.log.debug(`Set async script timeout to ${ms}ms`);
|
|
67
74
|
}
|
|
68
|
-
/**
|
|
69
|
-
* @typedef {import('../driver').XCUITestDriver} XCUITestDriver
|
|
70
|
-
*/
|
|
71
75
|
//# sourceMappingURL=timeouts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeouts.js","sourceRoot":"","sources":["../../../lib/commands/timeouts.
|
|
1
|
+
{"version":3,"file":"timeouts.js","sourceRoot":"","sources":["../../../lib/commands/timeouts.ts"],"names":[],"mappings":";;AAOA,gDAKC;AAOD,wDAKC;AAOD,4CAMC;AAQD,oDAKC;AAQD,gDAKC;AAOD,gDAUC;AAOD,sDAMC;AA3FD;;;;GAIG;AACI,KAAK,UAAU,kBAAkB,CAEtC,EAAU;IAEV,MAAM,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAAC,CAAC;AAC/D,CAAC;AAED;;;;GAIG;AACI,KAAK,UAAU,sBAAsB,CAE1C,EAAU;IAEV,MAAM,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAAC,CAAC;AAC/D,CAAC;AAED;;;;GAIG;AACI,KAAK,UAAU,gBAAgB,CAEpC,EAAU;IAEV,2BAA2B;IAC3B,MAAM,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAAC,CAAC;AAClE,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,oBAAoB,CAExC,EAAU;IAEV,MAAM,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;AACpC,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,kBAAkB,CAEtC,EAAU;IAEV,MAAM,IAAI,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;AAClC,CAAC;AAED;;;;GAIG;AACH,SAAgB,kBAAkB,CAEhC,EAAU;IAEV,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IAC9B,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;IACrB,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QACjB,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG,EAAE,CAAC;IAC9B,CAAC;IACD,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,4BAA4B,EAAE,IAAI,CAAC,CAAC;AACrD,CAAC;AAED;;;;GAIG;AACH,SAAgB,qBAAqB,CAEnC,EAAU;IAEV,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IACtB,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,+BAA+B,EAAE,IAAI,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type {XCUITestDriver} from '../driver';
|
|
2
|
+
|
|
3
|
+
export type AlertAction = 'accept' | 'dismiss' | 'getButtons';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Gets the text of the currently displayed alert.
|
|
7
|
+
*
|
|
8
|
+
* @returns The alert text, or null if no alert is displayed
|
|
9
|
+
*/
|
|
10
|
+
export async function getAlertText(this: XCUITestDriver): Promise<string | null> {
|
|
11
|
+
return await this.proxyCommand<any, string | null>('/alert/text', 'GET');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Sets the text in an alert input field.
|
|
16
|
+
*
|
|
17
|
+
* @param value - The text to set
|
|
18
|
+
*/
|
|
19
|
+
export async function setAlertText(
|
|
20
|
+
this: XCUITestDriver,
|
|
21
|
+
value: string,
|
|
22
|
+
): Promise<void> {
|
|
23
|
+
await this.proxyCommand('/alert/text', 'POST', {value});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Accepts the currently displayed alert.
|
|
28
|
+
*
|
|
29
|
+
* @param opts - Options including optional button label
|
|
30
|
+
*/
|
|
31
|
+
export async function postAcceptAlert(
|
|
32
|
+
this: XCUITestDriver,
|
|
33
|
+
opts: AlertOptions = {},
|
|
34
|
+
): Promise<void> {
|
|
35
|
+
await this.proxyCommand('/alert/accept', 'POST', toAlertParams(opts));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Dismisses the currently displayed alert.
|
|
40
|
+
*
|
|
41
|
+
* @param opts - Options including optional button label
|
|
42
|
+
*/
|
|
43
|
+
export async function postDismissAlert(
|
|
44
|
+
this: XCUITestDriver,
|
|
45
|
+
opts: AlertOptions = {},
|
|
46
|
+
): Promise<void> {
|
|
47
|
+
await this.proxyCommand('/alert/dismiss', 'POST', toAlertParams(opts));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Gets the list of button labels from the currently displayed alert.
|
|
52
|
+
*
|
|
53
|
+
* @returns The list of button labels
|
|
54
|
+
* @internal
|
|
55
|
+
*/
|
|
56
|
+
export async function getAlertButtons(this: XCUITestDriver): Promise<string[]> {
|
|
57
|
+
return await this.proxyCommand<any, string[]>('/wda/alert/buttons', 'GET');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Tries to apply the given action to the currently visible alert.
|
|
62
|
+
*
|
|
63
|
+
* @param action - The actual action to apply
|
|
64
|
+
* @param buttonLabel - The name of the button used to perform the chosen alert action. Only makes sense if the action is `accept` or `dismiss`
|
|
65
|
+
* @returns If `action` is `getButtons`, a list of alert button labels; otherwise nothing
|
|
66
|
+
* @remarks This should really be separate commands.
|
|
67
|
+
*/
|
|
68
|
+
export async function mobileHandleAlert(
|
|
69
|
+
this: XCUITestDriver,
|
|
70
|
+
action: AlertAction,
|
|
71
|
+
buttonLabel?: string,
|
|
72
|
+
): Promise<string[] | void> {
|
|
73
|
+
switch (action) {
|
|
74
|
+
case 'accept':
|
|
75
|
+
return await this.postAcceptAlert({buttonLabel});
|
|
76
|
+
case 'dismiss':
|
|
77
|
+
return await this.postDismissAlert({buttonLabel});
|
|
78
|
+
case 'getButtons':
|
|
79
|
+
return await this.getAlertButtons();
|
|
80
|
+
default:
|
|
81
|
+
throw new Error(
|
|
82
|
+
`The 'action' value should be either 'accept', 'dismiss' or 'getButtons'. ` +
|
|
83
|
+
`'${action}' is provided instead.`,
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function toAlertParams(opts: AlertOptions = {}): {name?: string} {
|
|
89
|
+
const params: {name?: string} = {};
|
|
90
|
+
if (opts.buttonLabel) {
|
|
91
|
+
params.name = opts.buttonLabel;
|
|
92
|
+
}
|
|
93
|
+
return params;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
interface AlertOptions {
|
|
97
|
+
buttonLabel?: string;
|
|
98
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import {util} from 'appium/support';
|
|
3
|
+
import type {XCUITestDriver} from '../driver';
|
|
4
|
+
import type {Style} from './types';
|
|
5
|
+
import type {Simulator} from 'appium-ios-simulator';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Set the device's UI appearance style
|
|
9
|
+
*
|
|
10
|
+
* @since iOS 12.0
|
|
11
|
+
* @param style - The appearance style to set
|
|
12
|
+
* @throws If the current platform does not support UI appearance changes
|
|
13
|
+
*/
|
|
14
|
+
export async function mobileSetAppearance(
|
|
15
|
+
this: XCUITestDriver,
|
|
16
|
+
style: 'dark' | 'light',
|
|
17
|
+
): Promise<void> {
|
|
18
|
+
if (!['light', 'dark'].includes(_.toLower(style))) {
|
|
19
|
+
throw new Error(`The 'style' value is expected to equal either 'light' or 'dark'`);
|
|
20
|
+
}
|
|
21
|
+
if (util.compareVersions(this.opts.platformVersion as string, '<', '12.0')) {
|
|
22
|
+
throw new Error('Changing appearance is only supported since iOS 12');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (this.isSimulator()) {
|
|
26
|
+
try {
|
|
27
|
+
await (this.device as Simulator).setAppearance(style);
|
|
28
|
+
return;
|
|
29
|
+
} catch (e: any) {
|
|
30
|
+
this.log.debug(e.stack);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
await this.proxyCommand('/wda/device/appearance', 'POST', {name: style}, false);
|
|
35
|
+
return;
|
|
36
|
+
} catch (e: any) {
|
|
37
|
+
this.log.debug(e.stack);
|
|
38
|
+
}
|
|
39
|
+
// Fall back to the ugly Siri workaround if the current SDK is too old
|
|
40
|
+
await this.mobileSiriCommand(`Turn ${_.toLower(style) === 'dark' ? 'on' : 'off'} dark mode`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Get the device's UI appearance style.
|
|
45
|
+
*
|
|
46
|
+
* @since Xcode SDK 11
|
|
47
|
+
* @returns The current appearance style
|
|
48
|
+
*/
|
|
49
|
+
export async function mobileGetAppearance(
|
|
50
|
+
this: XCUITestDriver,
|
|
51
|
+
): Promise<{style: Style}> {
|
|
52
|
+
if (util.compareVersions(this.opts.platformVersion as string, '<', '12.0')) {
|
|
53
|
+
return {style: 'unsupported'};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
let style: Style | undefined;
|
|
57
|
+
if (this.isSimulator()) {
|
|
58
|
+
try {
|
|
59
|
+
style = await (this.device as Simulator).getAppearance() as Style;
|
|
60
|
+
} catch {}
|
|
61
|
+
}
|
|
62
|
+
if (!style) {
|
|
63
|
+
const deviceInfo = await this.proxyCommand<any, {userInterfaceStyle?: string}>('/wda/device/info', 'GET');
|
|
64
|
+
style = (deviceInfo?.userInterfaceStyle ?? 'unknown') as Style;
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
style: style as Style,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import {PermissionService} from './enum';
|
|
3
|
+
import {assertSimulator as _assertSimulator} from '../utils';
|
|
4
|
+
import type {XCUITestDriver} from '../driver';
|
|
5
|
+
import type {PermissionState} from './types';
|
|
6
|
+
import type {Simulator} from 'appium-ios-simulator';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Resets the given permission for the active application under test.
|
|
10
|
+
* Works for both Simulator and real devices using Xcode SDK 11.4+
|
|
11
|
+
*
|
|
12
|
+
* @param service - One of the available service names. This could also be an integer protected resource identifier; see [this list](https://developer.apple.com/documentation/xctest/xcuiprotectedresource?language=objc)
|
|
13
|
+
* @throws If permission reset fails on the device.
|
|
14
|
+
*/
|
|
15
|
+
export async function mobileResetPermission(
|
|
16
|
+
this: XCUITestDriver,
|
|
17
|
+
service: PermissionService | number,
|
|
18
|
+
): Promise<void> {
|
|
19
|
+
if (!service) {
|
|
20
|
+
throw new Error(`The 'service' option is expected to be present`);
|
|
21
|
+
}
|
|
22
|
+
let resource: number;
|
|
23
|
+
if (_.isString(service)) {
|
|
24
|
+
resource = PermissionService[_.toLower(service) as keyof typeof PermissionService];
|
|
25
|
+
if (!resource) {
|
|
26
|
+
throw new Error(
|
|
27
|
+
`The 'service' value must be one of ` + `${JSON.stringify(_.keys(PermissionService))}`,
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
} else if (_.isInteger(service)) {
|
|
31
|
+
resource = service;
|
|
32
|
+
} else {
|
|
33
|
+
throw new Error(
|
|
34
|
+
`The 'service' value must be either a string or an integer. ` +
|
|
35
|
+
`'${service}' is passed instead`,
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
await this.proxyCommand('/wda/resetAppAuth', 'POST', {resource});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Gets application permission state on a simulated device.
|
|
44
|
+
*
|
|
45
|
+
* **This method requires [WIX applesimutils](https://github.com/wix/AppleSimulatorUtils) to be installed on the Appium server host.**
|
|
46
|
+
*
|
|
47
|
+
* @param bundleId - Bundle identifier of the target application
|
|
48
|
+
* @param service - Service name
|
|
49
|
+
* @returns Either 'yes', 'no', 'unset' or 'limited'
|
|
50
|
+
* @throws If permission getting fails or the device is not a Simulator.
|
|
51
|
+
* @group Simulator Only
|
|
52
|
+
*/
|
|
53
|
+
export async function mobileGetPermission(
|
|
54
|
+
this: XCUITestDriver,
|
|
55
|
+
bundleId: string,
|
|
56
|
+
service: PermissionService,
|
|
57
|
+
): Promise<PermissionState> {
|
|
58
|
+
if (!service) {
|
|
59
|
+
throw new Error(`The 'service' option is expected to be present`);
|
|
60
|
+
}
|
|
61
|
+
assertSimulator(this);
|
|
62
|
+
|
|
63
|
+
return await (this.device as Simulator).getPermission(
|
|
64
|
+
bundleId, String(service)
|
|
65
|
+
) as PermissionState;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Set application permission state on Simulator.
|
|
70
|
+
*
|
|
71
|
+
* @param access - One or more access rules to set.
|
|
72
|
+
* @param bundleId - Bundle identifier of the target application
|
|
73
|
+
* @since Xcode SDK 11.4
|
|
74
|
+
* @throws If permission setting fails or the device is not a Simulator.
|
|
75
|
+
* @group Simulator Only
|
|
76
|
+
*/
|
|
77
|
+
export async function mobileSetPermissions(
|
|
78
|
+
this: XCUITestDriver,
|
|
79
|
+
access: Record<string, PermissionState>,
|
|
80
|
+
bundleId: string,
|
|
81
|
+
): Promise<void> {
|
|
82
|
+
if (!_.isPlainObject(access)) {
|
|
83
|
+
throw new Error(`The 'access' option is expected to be a map`);
|
|
84
|
+
}
|
|
85
|
+
assertSimulator(this);
|
|
86
|
+
|
|
87
|
+
await (this.device as Simulator).setPermissions(bundleId, access);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const assertSimulator = (driver: XCUITestDriver) => _assertSimulator.call(driver, 'Permission-related operations');
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import {errors, routeToCommandName} from 'appium/driver';
|
|
2
2
|
import B from 'bluebird';
|
|
3
|
+
import type {XCUITestDriver} from '../driver';
|
|
3
4
|
|
|
4
5
|
const GET = 'GET';
|
|
5
6
|
const POST = 'POST';
|
|
6
7
|
const DELETE = 'DELETE';
|
|
7
|
-
const SUPPORTED_METHODS = Object.freeze(new Set(
|
|
8
|
+
const SUPPORTED_METHODS = Object.freeze(new Set([GET, POST, DELETE] as const));
|
|
8
9
|
|
|
9
|
-
const WDA_ROUTES =
|
|
10
|
+
const WDA_ROUTES = {
|
|
10
11
|
'/wda/screen': {
|
|
11
12
|
GET: 'getScreenInfo',
|
|
12
13
|
},
|
|
@@ -43,22 +44,30 @@ const WDA_ROUTES = /** @type {const} */ ({
|
|
|
43
44
|
'/wda/locked': {
|
|
44
45
|
GET: 'isLocked',
|
|
45
46
|
},
|
|
46
|
-
}
|
|
47
|
+
} as const;
|
|
48
|
+
|
|
49
|
+
export type AllowedHttpMethod = 'GET' | 'POST' | 'DELETE';
|
|
47
50
|
|
|
48
51
|
/**
|
|
49
52
|
* Proxies a command to WebDriverAgent
|
|
50
|
-
*
|
|
51
|
-
* @template
|
|
52
|
-
* @
|
|
53
|
-
* @param
|
|
54
|
-
* @param
|
|
55
|
-
* @param
|
|
56
|
-
* @this
|
|
57
|
-
* @returns
|
|
53
|
+
*
|
|
54
|
+
* @template TReq - Request body type
|
|
55
|
+
* @template TRes - Response type
|
|
56
|
+
* @param url - The endpoint URL
|
|
57
|
+
* @param method - HTTP method to use
|
|
58
|
+
* @param body - Optional request body
|
|
59
|
+
* @param isSessionCommand - Whether this is a session command (default: true)
|
|
60
|
+
* @returns Promise resolving to the response
|
|
58
61
|
*/
|
|
59
|
-
export async function proxyCommand
|
|
62
|
+
export async function proxyCommand<TReq = any, TRes = unknown>(
|
|
63
|
+
this: XCUITestDriver,
|
|
64
|
+
url: string,
|
|
65
|
+
method: AllowedHttpMethod,
|
|
66
|
+
body?: TReq,
|
|
67
|
+
isSessionCommand: boolean = true,
|
|
68
|
+
): Promise<TRes> {
|
|
60
69
|
if (this.shutdownUnexpectedly) {
|
|
61
|
-
return
|
|
70
|
+
return undefined as TRes;
|
|
62
71
|
}
|
|
63
72
|
|
|
64
73
|
if (!url) {
|
|
@@ -83,12 +92,12 @@ export async function proxyCommand(url, method, body, isSessionCommand = true) {
|
|
|
83
92
|
}
|
|
84
93
|
|
|
85
94
|
if (!timeout) {
|
|
86
|
-
return
|
|
95
|
+
return await proxy.command(url, method, body) as TRes;
|
|
87
96
|
}
|
|
88
97
|
|
|
89
98
|
this.log.debug(`Setting custom timeout to ${timeout} ms for '${cmdName}' command`);
|
|
90
99
|
try {
|
|
91
|
-
return
|
|
100
|
+
return await B.resolve(proxy.command(url, method, body)).timeout(timeout) as TRes;
|
|
92
101
|
} catch (e) {
|
|
93
102
|
if (!(e instanceof B.Promise.TimeoutError)) {
|
|
94
103
|
throw e;
|
|
@@ -102,18 +111,9 @@ export async function proxyCommand(url, method, body, isSessionCommand = true) {
|
|
|
102
111
|
}
|
|
103
112
|
}
|
|
104
113
|
|
|
105
|
-
|
|
106
|
-
* @param {string} endpoint
|
|
107
|
-
* @param {AllowedHttpMethod} method
|
|
108
|
-
* @returns {string|undefined}
|
|
109
|
-
*/
|
|
110
|
-
function wdaRouteToCommandName(endpoint, method) {
|
|
114
|
+
function wdaRouteToCommandName(endpoint: string, method: AllowedHttpMethod): string | undefined {
|
|
111
115
|
if (endpoint in WDA_ROUTES) {
|
|
112
|
-
return WDA_ROUTES[endpoint][method];
|
|
116
|
+
return WDA_ROUTES[endpoint as keyof typeof WDA_ROUTES]?.[method];
|
|
113
117
|
}
|
|
114
118
|
}
|
|
115
119
|
|
|
116
|
-
/**
|
|
117
|
-
* @typedef {import('../driver').XCUITestDriver} XCUITestDriver
|
|
118
|
-
* @typedef {'GET'|'POST'|'DELETE'} AllowedHttpMethod
|
|
119
|
-
*/
|