-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathapp-management.js
83 lines (79 loc) · 3.14 KB
/
app-management.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/**
* Start an app with given bundle identifier or activates it
* if the app is already running. An exception is thrown if the
* app with the given identifier cannot be found.
*
* @this {Mac2Driver}
* @param {string} [bundleId] Bundle identifier of the app to be launched or activated.
* Either this property or `path` must be provided
* @param {string} [path] Full path to the app bundle. Either this property or
* `bundleId` must be provided
* @param {string[]} [args] The list of command line arguments for the app to be launched with.
* This parameter is ignored if the app is already running.
* @param {import('@appium/types').StringRecord} [environment] Environment variables mapping.
* Custom variables are added to the default process environment.
*/
export async function macosLaunchApp (
bundleId,
path,
args,
environment,
) {
return await this.wda.proxy.command('/wda/apps/launch', 'POST', {
arguments: args,
environment,
bundleId,
path,
});
};
/**
* Activate an app with given bundle identifier. An exception is thrown if the
* app cannot be found or is not running.
*
* @this {Mac2Driver}
* @param {string} [bundleId] Bundle identifier of the app to be activated.
* Either this property or `path` must be provided
* @param {string} [path] Full path to the app bundle. Either this property
* or `bundleId` must be provided
*/
export async function macosActivateApp (bundleId, path) {
return await this.wda.proxy.command('/wda/apps/activate', 'POST', { bundleId, path });
};
/**
* Terminate an app with given bundle identifier. An exception is thrown if the
* app cannot be found.
*
* @this {Mac2Driver}
* @param {string} [bundleId] Bundle identifier of the app to be terminated.
* Either this property or `path` must be provided
* @param {string} [path] Full path to the app bundle. Either this property
* or `bundleId` must be provided
* @returns {Promise<boolean>} `true` if the app was running and has been successfully terminated.
* `false` if the app was not running before.
*/
export async function macosTerminateApp (bundleId, path) {
return /** @type {boolean} */ (
await this.wda.proxy.command('/wda/apps/terminate', 'POST', { bundleId, path })
);
};
/**
* Query an app state with given bundle identifier. An exception is thrown if the
* app cannot be found.
*
* @this {Mac2Driver}
* @param {string} [bundleId] Bundle identifier of the app whose state should be queried.
* Either this property or `path` must be provided
* @param {string} [path] Full path to the app bundle. Either this property
* or `bundleId` must be provided
* @returns {Promise<number>} The application state code. See
* https://developer.apple.com/documentation/xctest/xcuiapplicationstate?language=objc
* for more details
*/
export async function macosQueryAppState (bundleId, path) {
return /** @type {number} */ (
await this.wda.proxy.command('/wda/apps/state', 'POST', { bundleId, path })
);
};
/**
* @typedef {import('../driver').Mac2Driver} Mac2Driver
*/