appium-xcuitest-driver 10.2.2 → 10.4.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/CHANGELOG.md +12 -0
- package/build/lib/commands/active-app-info.d.ts +9 -0
- package/build/lib/commands/active-app-info.d.ts.map +1 -0
- package/build/lib/commands/active-app-info.js +14 -0
- package/build/lib/commands/active-app-info.js.map +1 -0
- package/build/lib/commands/alert.d.ts +42 -45
- package/build/lib/commands/alert.d.ts.map +1 -1
- package/build/lib/commands/alert.js +66 -62
- package/build/lib/commands/alert.js.map +1 -1
- package/build/lib/commands/app-management.d.ts +150 -153
- package/build/lib/commands/app-management.d.ts.map +1 -1
- package/build/lib/commands/app-management.js +300 -286
- package/build/lib/commands/app-management.js.map +1 -1
- package/build/lib/commands/app-strings.d.ts +14 -17
- package/build/lib/commands/app-strings.d.ts.map +1 -1
- package/build/lib/commands/app-strings.js +23 -24
- package/build/lib/commands/app-strings.js.map +1 -1
- package/build/lib/commands/appearance.d.ts +19 -22
- package/build/lib/commands/appearance.d.ts.map +1 -1
- package/build/lib/commands/appearance.js +56 -56
- package/build/lib/commands/appearance.js.map +1 -1
- package/build/lib/commands/audit.d.ts +22 -17
- package/build/lib/commands/audit.d.ts.map +1 -1
- package/build/lib/commands/audit.js +17 -18
- package/build/lib/commands/audit.js.map +1 -1
- package/build/lib/commands/battery.d.ts +11 -14
- package/build/lib/commands/battery.d.ts.map +1 -1
- package/build/lib/commands/battery.js +36 -37
- package/build/lib/commands/battery.js.map +1 -1
- package/build/lib/commands/biometric.d.ts +30 -33
- package/build/lib/commands/biometric.d.ts.map +1 -1
- package/build/lib/commands/biometric.js +42 -41
- package/build/lib/commands/biometric.js.map +1 -1
- package/build/lib/commands/certificate.d.ts +48 -45
- package/build/lib/commands/certificate.d.ts.map +1 -1
- package/build/lib/commands/certificate.js +218 -205
- package/build/lib/commands/certificate.js.map +1 -1
- package/build/lib/commands/clipboard.d.ts +19 -22
- package/build/lib/commands/clipboard.d.ts.map +1 -1
- package/build/lib/commands/clipboard.js +30 -30
- package/build/lib/commands/clipboard.js.map +1 -1
- package/build/lib/commands/condition.d.ts +49 -26
- package/build/lib/commands/condition.d.ts.map +1 -1
- package/build/lib/commands/condition.js +87 -86
- package/build/lib/commands/condition.js.map +1 -1
- package/build/lib/commands/content-size.d.ts +26 -29
- package/build/lib/commands/content-size.d.ts.map +1 -1
- package/build/lib/commands/content-size.js +36 -36
- package/build/lib/commands/content-size.js.map +1 -1
- package/build/lib/commands/context.d.ts +161 -108
- package/build/lib/commands/context.d.ts.map +1 -1
- package/build/lib/commands/context.js +530 -517
- package/build/lib/commands/context.js.map +1 -1
- package/build/lib/commands/deviceInfo.d.ts +9 -12
- package/build/lib/commands/deviceInfo.d.ts.map +1 -1
- package/build/lib/commands/deviceInfo.js +17 -18
- package/build/lib/commands/deviceInfo.js.map +1 -1
- package/build/lib/commands/element.d.ts +102 -105
- package/build/lib/commands/element.d.ts.map +1 -1
- package/build/lib/commands/element.js +337 -323
- package/build/lib/commands/element.js.map +1 -1
- package/build/lib/commands/execute.d.ts +24 -19
- package/build/lib/commands/execute.d.ts.map +1 -1
- package/build/lib/commands/execute.js +63 -62
- package/build/lib/commands/execute.js.map +1 -1
- package/build/lib/commands/file-movement.d.ts +77 -80
- package/build/lib/commands/file-movement.d.ts.map +1 -1
- package/build/lib/commands/file-movement.js +130 -124
- package/build/lib/commands/file-movement.js.map +1 -1
- package/build/lib/commands/find.d.ts +18 -21
- package/build/lib/commands/find.d.ts.map +1 -1
- package/build/lib/commands/find.js +158 -156
- package/build/lib/commands/find.js.map +1 -1
- package/build/lib/commands/general.d.ts +124 -116
- package/build/lib/commands/general.d.ts.map +1 -1
- package/build/lib/commands/general.js +248 -232
- package/build/lib/commands/general.js.map +1 -1
- package/build/lib/commands/geolocation.d.ts +43 -46
- package/build/lib/commands/geolocation.d.ts.map +1 -1
- package/build/lib/commands/geolocation.js +10 -11
- package/build/lib/commands/geolocation.js.map +1 -1
- package/build/lib/commands/gesture.d.ts +273 -276
- package/build/lib/commands/gesture.d.ts.map +1 -1
- package/build/lib/commands/gesture.js +506 -492
- package/build/lib/commands/gesture.js.map +1 -1
- package/build/lib/commands/increase-contrast.d.ts +20 -23
- package/build/lib/commands/increase-contrast.d.ts.map +1 -1
- package/build/lib/commands/increase-contrast.js +30 -30
- package/build/lib/commands/increase-contrast.js.map +1 -1
- package/build/lib/commands/iohid.d.ts +1370 -1373
- package/build/lib/commands/iohid.d.ts.map +1 -1
- package/build/lib/commands/iohid.js +30 -31
- package/build/lib/commands/iohid.js.map +1 -1
- package/build/lib/commands/keyboard.d.ts +29 -32
- package/build/lib/commands/keyboard.d.ts.map +1 -1
- package/build/lib/commands/keyboard.js +53 -51
- package/build/lib/commands/keyboard.js.map +1 -1
- package/build/lib/commands/keychains.d.ts +9 -12
- package/build/lib/commands/keychains.d.ts.map +1 -1
- package/build/lib/commands/keychains.js +13 -14
- package/build/lib/commands/keychains.js.map +1 -1
- package/build/lib/commands/localization.d.ts +16 -19
- package/build/lib/commands/localization.d.ts.map +1 -1
- package/build/lib/commands/localization.js +25 -26
- package/build/lib/commands/localization.js.map +1 -1
- package/build/lib/commands/location.d.ts +36 -39
- package/build/lib/commands/location.d.ts.map +1 -1
- package/build/lib/commands/location.js +99 -98
- package/build/lib/commands/location.js.map +1 -1
- package/build/lib/commands/lock.d.ts +21 -24
- package/build/lib/commands/lock.d.ts.map +1 -1
- package/build/lib/commands/lock.js +39 -38
- package/build/lib/commands/lock.js.map +1 -1
- package/build/lib/commands/log.d.ts +43 -37
- package/build/lib/commands/log.d.ts.map +1 -1
- package/build/lib/commands/log.js +174 -171
- package/build/lib/commands/log.js.map +1 -1
- package/build/lib/commands/memory.d.ts +9 -12
- package/build/lib/commands/memory.d.ts.map +1 -1
- package/build/lib/commands/memory.js +37 -39
- package/build/lib/commands/memory.js.map +1 -1
- package/build/lib/commands/navigation.d.ts +30 -33
- package/build/lib/commands/navigation.d.ts.map +1 -1
- package/build/lib/commands/navigation.js +92 -92
- package/build/lib/commands/navigation.js.map +1 -1
- package/build/lib/commands/notifications.d.ts +26 -29
- package/build/lib/commands/notifications.d.ts.map +1 -1
- package/build/lib/commands/notifications.js +53 -53
- package/build/lib/commands/notifications.js.map +1 -1
- package/build/lib/commands/pasteboard.d.ts +21 -24
- package/build/lib/commands/pasteboard.d.ts.map +1 -1
- package/build/lib/commands/pasteboard.js +37 -37
- package/build/lib/commands/pasteboard.js.map +1 -1
- package/build/lib/commands/pcap.d.ts +39 -26
- package/build/lib/commands/pcap.d.ts.map +1 -1
- package/build/lib/commands/pcap.js +81 -81
- package/build/lib/commands/pcap.js.map +1 -1
- package/build/lib/commands/performance.d.ts +63 -44
- package/build/lib/commands/performance.d.ts.map +1 -1
- package/build/lib/commands/performance.js +105 -105
- package/build/lib/commands/performance.js.map +1 -1
- package/build/lib/commands/permissions.d.ts +33 -36
- package/build/lib/commands/permissions.d.ts.map +1 -1
- package/build/lib/commands/permissions.js +66 -65
- package/build/lib/commands/permissions.js.map +1 -1
- package/build/lib/commands/proxy-helper.d.ts +12 -15
- package/build/lib/commands/proxy-helper.d.ts.map +1 -1
- package/build/lib/commands/proxy-helper.js +53 -54
- package/build/lib/commands/proxy-helper.js.map +1 -1
- package/build/lib/commands/record-audio.d.ts +49 -29
- package/build/lib/commands/record-audio.d.ts.map +1 -1
- package/build/lib/commands/record-audio.js +100 -104
- package/build/lib/commands/record-audio.js.map +1 -1
- package/build/lib/commands/recordscreen.d.ts +54 -18
- package/build/lib/commands/recordscreen.d.ts.map +1 -1
- package/build/lib/commands/recordscreen.js +127 -129
- package/build/lib/commands/recordscreen.js.map +1 -1
- package/build/lib/commands/screenshots.d.ts +14 -17
- package/build/lib/commands/screenshots.d.ts.map +1 -1
- package/build/lib/commands/screenshots.js +108 -107
- package/build/lib/commands/screenshots.js.map +1 -1
- package/build/lib/commands/simctl.d.ts +11 -14
- package/build/lib/commands/simctl.d.ts.map +1 -1
- package/build/lib/commands/simctl.js +23 -26
- package/build/lib/commands/simctl.js.map +1 -1
- package/build/lib/commands/source.d.ts +14 -17
- package/build/lib/commands/source.d.ts.map +1 -1
- package/build/lib/commands/source.js +40 -43
- package/build/lib/commands/source.js.map +1 -1
- package/build/lib/commands/timeouts.d.ts +44 -33
- package/build/lib/commands/timeouts.d.ts.map +1 -1
- package/build/lib/commands/timeouts.js +65 -63
- package/build/lib/commands/timeouts.js.map +1 -1
- package/build/lib/commands/web.d.ts +247 -197
- package/build/lib/commands/web.d.ts.map +1 -1
- package/build/lib/commands/web.js +815 -786
- package/build/lib/commands/web.js.map +1 -1
- package/build/lib/commands/xctest-record-screen.d.ts +63 -66
- package/build/lib/commands/xctest-record-screen.d.ts.map +1 -1
- package/build/lib/commands/xctest-record-screen.js +103 -102
- package/build/lib/commands/xctest-record-screen.js.map +1 -1
- package/build/lib/commands/xctest.d.ts +55 -51
- package/build/lib/commands/xctest.d.ts.map +1 -1
- package/build/lib/commands/xctest.js +116 -117
- package/build/lib/commands/xctest.js.map +1 -1
- package/build/lib/driver.d.ts +278 -1597
- package/build/lib/driver.d.ts.map +1 -1
- package/build/lib/driver.js +320 -236
- package/build/lib/driver.js.map +1 -1
- package/build/lib/execute-method-map.d.ts.map +1 -1
- package/build/lib/execute-method-map.js +9 -0
- package/build/lib/execute-method-map.js.map +1 -1
- package/build/lib/real-device.d.ts +1 -1
- package/build/lib/real-device.d.ts.map +1 -1
- package/build/lib/real-device.js +2 -2
- package/build/lib/real-device.js.map +1 -1
- package/lib/commands/active-app-info.js +12 -0
- package/lib/commands/alert.js +68 -65
- package/lib/commands/app-management.js +308 -301
- package/lib/commands/app-strings.js +24 -26
- package/lib/commands/appearance.js +54 -56
- package/lib/commands/audit.js +18 -20
- package/lib/commands/battery.js +35 -37
- package/lib/commands/biometric.js +44 -46
- package/lib/commands/certificate.js +226 -215
- package/lib/commands/clipboard.js +30 -32
- package/lib/commands/condition.js +98 -100
- package/lib/commands/content-size.js +36 -38
- package/lib/commands/context.js +495 -490
- package/lib/commands/deviceInfo.js +19 -20
- package/lib/commands/element.js +367 -357
- package/lib/commands/execute.js +72 -72
- package/lib/commands/file-movement.js +132 -134
- package/lib/commands/find.js +160 -159
- package/lib/commands/general.js +238 -231
- package/lib/commands/geolocation.js +6 -14
- package/lib/commands/gesture.js +525 -515
- package/lib/commands/increase-contrast.js +30 -32
- package/lib/commands/iohid.js +32 -34
- package/lib/commands/keyboard.js +49 -51
- package/lib/commands/keychains.js +12 -14
- package/lib/commands/localization.js +24 -26
- package/lib/commands/location.js +102 -104
- package/lib/commands/lock.js +38 -38
- package/lib/commands/log.js +197 -198
- package/lib/commands/memory.js +40 -43
- package/lib/commands/navigation.js +96 -100
- package/lib/commands/notifications.js +57 -59
- package/lib/commands/pasteboard.js +37 -39
- package/lib/commands/pcap.js +84 -86
- package/lib/commands/performance.js +132 -133
- package/lib/commands/permissions.js +67 -69
- package/lib/commands/proxy-helper.js +60 -61
- package/lib/commands/record-audio.js +115 -120
- package/lib/commands/recordscreen.js +145 -149
- package/lib/commands/screenshots.js +116 -116
- package/lib/commands/simctl.js +25 -29
- package/lib/commands/source.js +42 -46
- package/lib/commands/timeouts.js +59 -63
- package/lib/commands/web.js +878 -858
- package/lib/commands/xctest-record-screen.js +103 -105
- package/lib/commands/xctest.js +134 -139
- package/lib/driver.js +288 -236
- package/lib/execute-method-map.ts +9 -0
- package/lib/real-device.js +2 -2
- package/npm-shrinkwrap.json +440 -76
- package/package.json +2 -1
- package/build/lib/commands/activeAppInfo.d.ts +0 -12
- package/build/lib/commands/activeAppInfo.d.ts.map +0 -1
- package/build/lib/commands/activeAppInfo.js +0 -15
- package/build/lib/commands/activeAppInfo.js.map +0 -1
- package/build/lib/commands/index.d.ts +0 -96
- package/build/lib/commands/index.d.ts.map +0 -1
- package/build/lib/commands/index.js +0 -100
- package/build/lib/commands/index.js.map +0 -1
- package/build/lib/real-device-clients/devicectl.d.ts +0 -204
- package/build/lib/real-device-clients/devicectl.d.ts.map +0 -1
- package/build/lib/real-device-clients/devicectl.js +0 -264
- package/build/lib/real-device-clients/devicectl.js.map +0 -1
- package/lib/commands/activeAppInfo.js +0 -14
- package/lib/commands/index.js +0 -95
- package/lib/real-device-clients/devicectl.js +0 -291
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Devicectl = void 0;
|
|
7
|
-
const teen_process_1 = require("teen_process");
|
|
8
|
-
const support_1 = require("appium/support");
|
|
9
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
10
|
-
const XCRUN = 'xcrun';
|
|
11
|
-
/**
|
|
12
|
-
* @typedef {Object} ProcessInfo
|
|
13
|
-
* @property {number} processIdentifier
|
|
14
|
-
* @property {string} executable
|
|
15
|
-
*/
|
|
16
|
-
/*
|
|
17
|
-
Example:
|
|
18
|
-
{
|
|
19
|
-
"executable" : "file:///sbin/launchd",
|
|
20
|
-
"processIdentifier" : 1
|
|
21
|
-
},
|
|
22
|
-
*/
|
|
23
|
-
/**
|
|
24
|
-
* @typedef {Object} AppInfo
|
|
25
|
-
* @property {boolean} appClip
|
|
26
|
-
* @property {boolean} builtByDeveloper
|
|
27
|
-
* @property {string} bundleIdentifier
|
|
28
|
-
* @property {string} bundleVersion
|
|
29
|
-
* @property {boolean} defaultApp
|
|
30
|
-
* @property {boolean} hidden
|
|
31
|
-
* @property {boolean} internalApp
|
|
32
|
-
* @property {string} name
|
|
33
|
-
* @property {boolean} removable
|
|
34
|
-
* @property {string} url
|
|
35
|
-
* @property {string} version
|
|
36
|
-
*/
|
|
37
|
-
/*
|
|
38
|
-
Example:
|
|
39
|
-
{
|
|
40
|
-
"appClip" : false,
|
|
41
|
-
"builtByDeveloper" : false,
|
|
42
|
-
"bundleIdentifier" : "com.apple.mobilesafari",
|
|
43
|
-
"bundleVersion" : "8617.1.17.10.9",
|
|
44
|
-
"defaultApp" : true,
|
|
45
|
-
"hidden" : false,
|
|
46
|
-
"internalApp" : false,
|
|
47
|
-
"name" : "Safari",
|
|
48
|
-
"removable" : false,
|
|
49
|
-
"url" : "file:///Applications/MobileSafari.app/",
|
|
50
|
-
"version" : "17.2"
|
|
51
|
-
}
|
|
52
|
-
*/
|
|
53
|
-
/**
|
|
54
|
-
* @typedef {Object} ExecuteOptions
|
|
55
|
-
* @property {boolean} [logStdout=false]
|
|
56
|
-
* @property {boolean} [asJson=true]
|
|
57
|
-
* @property {boolean} [asynchronous=false]
|
|
58
|
-
* @property {string[]|string} [subcommandOptions]
|
|
59
|
-
* @property {number} [timeout]
|
|
60
|
-
*/
|
|
61
|
-
/**
|
|
62
|
-
* @typedef {{asynchronous: true}} TAsyncOpts
|
|
63
|
-
*/
|
|
64
|
-
/**
|
|
65
|
-
* @typedef {Object} ListFilesOptions
|
|
66
|
-
* @property {string} [username] The username of the user we should target. Only relevant for certain domains.
|
|
67
|
-
* @property {string} [subdirectory] A subdirectory within the domain. If not specified, defaults to the root.
|
|
68
|
-
*/
|
|
69
|
-
/**
|
|
70
|
-
* @typedef {Object} PullFileOptions
|
|
71
|
-
* @property {string} [username] The username of the user we should target. Only relevant for certain domains.
|
|
72
|
-
* @property {string} domainType The file service domain. Valid values are: temporary, rootStaging, appDataContainer, appGroupDataContainer,
|
|
73
|
-
* systemCrashLogs. You must specify a valid domain and identifier pair. Each domain is accompanied by an identifier
|
|
74
|
-
* that provides additional context. For example, if the domain is an app data container, the identifier is the bundle
|
|
75
|
-
* ID of the app. For temporary directories and root staging areas, the identifier is a unique client-provided string
|
|
76
|
-
* which is used to get your own space, separate from those of other clients.
|
|
77
|
-
* @property {string} domainIdentifier A unique string used to provide additional context to the domain.
|
|
78
|
-
* @property {number} [timeout=120000] The timeout for pulling a file in milliseconds.
|
|
79
|
-
*/
|
|
80
|
-
/**
|
|
81
|
-
* An option for launchApp method by devicectl.
|
|
82
|
-
* @typedef {Object} LaunchAppOptions
|
|
83
|
-
* @property {import('@appium/types').StringRecord<string|number>} [env] Bundle id to Environment variables for the launching app process.
|
|
84
|
-
* @property {boolean} [terminateExisting=false] Whether terminating the already running app.
|
|
85
|
-
*/
|
|
86
|
-
class Devicectl {
|
|
87
|
-
/**
|
|
88
|
-
* @since Xcode 15, iOS 17
|
|
89
|
-
* @param {string} udid
|
|
90
|
-
* @param {import('@appium/types').AppiumLogger} log
|
|
91
|
-
*/
|
|
92
|
-
constructor(udid, log) {
|
|
93
|
-
this.udid = udid;
|
|
94
|
-
this.log = log;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* @template {ExecuteOptions} TExecOpts
|
|
98
|
-
* @param {string[]} subcommand
|
|
99
|
-
* @param {TExecOpts} [opts]
|
|
100
|
-
* @return {Promise<TExecOpts extends TAsyncOpts ? import('teen_process').SubProcess : import('teen_process').TeenProcessExecResult>}
|
|
101
|
-
*/
|
|
102
|
-
async execute(subcommand, opts) {
|
|
103
|
-
const { logStdout = false, asynchronous = false, asJson = true, subcommandOptions, timeout, } = opts ?? {};
|
|
104
|
-
const finalArgs = [
|
|
105
|
-
'devicectl', ...subcommand,
|
|
106
|
-
'--device', this.udid,
|
|
107
|
-
];
|
|
108
|
-
if (subcommandOptions && !lodash_1.default.isEmpty(subcommandOptions)) {
|
|
109
|
-
finalArgs.push(...(Array.isArray(subcommandOptions) ? subcommandOptions : [subcommandOptions]));
|
|
110
|
-
}
|
|
111
|
-
if (asJson) {
|
|
112
|
-
finalArgs.push('--quiet', '--json-output', '-');
|
|
113
|
-
}
|
|
114
|
-
const cmdStr = support_1.util.quote([XCRUN, ...finalArgs]);
|
|
115
|
-
this.log.debug(`Executing ${cmdStr}`);
|
|
116
|
-
try {
|
|
117
|
-
if (asynchronous) {
|
|
118
|
-
const result = new teen_process_1.SubProcess(XCRUN, finalArgs);
|
|
119
|
-
await result.start(0);
|
|
120
|
-
// @ts-ignore TS does not understand it
|
|
121
|
-
return result;
|
|
122
|
-
}
|
|
123
|
-
const result = await (0, teen_process_1.exec)(XCRUN, finalArgs, ...(lodash_1.default.isNumber(timeout) ? [{ timeout }] : []));
|
|
124
|
-
if (logStdout) {
|
|
125
|
-
this.log.debug(`Command output: ${result.stdout}`);
|
|
126
|
-
}
|
|
127
|
-
// @ts-ignore TS does not understand it
|
|
128
|
-
return result;
|
|
129
|
-
}
|
|
130
|
-
catch (e) {
|
|
131
|
-
throw new Error(`'${cmdStr}' failed. Original error: ${e.stderr || e.stdout || e.message}`);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Simulates memory warning for the process with the given PID
|
|
136
|
-
*
|
|
137
|
-
* @param {number|string} pid The process identifier to simulate the Low Memory warning for
|
|
138
|
-
* @return {Promise<void>}
|
|
139
|
-
*/
|
|
140
|
-
async sendMemoryWarning(pid) {
|
|
141
|
-
await this.execute(['device', 'process', 'sendMemoryWarning'], {
|
|
142
|
-
subcommandOptions: ['--pid', `${pid}`]
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Lists running processes on the device
|
|
147
|
-
*
|
|
148
|
-
* @returns {Promise<ProcessInfo[]>}
|
|
149
|
-
*/
|
|
150
|
-
async listProcesses() {
|
|
151
|
-
const { stdout } = await this.execute(['device', 'info', 'processes']);
|
|
152
|
-
return JSON.parse(stdout).result.runningProcesses;
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Lists files at a specified path on the device
|
|
156
|
-
*
|
|
157
|
-
* @param {string} domainType The file service domain. Valid values are: temporary, rootStaging, appDataContainer, appGroupDataContainer,
|
|
158
|
-
* systemCrashLogs. You must specify a valid domain and identifier pair. Each domain is accompanied by an identifier
|
|
159
|
-
* that provides additional context. For example, if the domain is an app data container, the identifier is the bundle
|
|
160
|
-
* ID of the app. For temporary directories and root staging areas, the identifier is a unique client-provided string
|
|
161
|
-
* which is used to get your own space, separate from those of other clients.
|
|
162
|
-
* @param {string} domainIdentifier A unique string used to provide additional context to the domain.
|
|
163
|
-
* @param {ListFilesOptions} [opts={}]
|
|
164
|
-
* @returns {Promise<string[]>} List of file names (could be empty)
|
|
165
|
-
*/
|
|
166
|
-
async listFiles(domainType, domainIdentifier, opts = {}) {
|
|
167
|
-
const subcommandOptions = [
|
|
168
|
-
'--domain-type', domainType,
|
|
169
|
-
'--domain-identifier', domainIdentifier,
|
|
170
|
-
];
|
|
171
|
-
if (opts.username) {
|
|
172
|
-
subcommandOptions.push('--username', opts.username);
|
|
173
|
-
}
|
|
174
|
-
if (opts.subdirectory) {
|
|
175
|
-
subcommandOptions.push('--subdirectory', opts.subdirectory);
|
|
176
|
-
}
|
|
177
|
-
const { stdout } = await this.execute(['device', 'info', 'files'], {
|
|
178
|
-
subcommandOptions,
|
|
179
|
-
});
|
|
180
|
-
return JSON.parse(stdout).result.files.map(({ name }) => name);
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Pulls a file from the specified path on the device to a local file system
|
|
184
|
-
*
|
|
185
|
-
* @param {string} from The item which should be copied.
|
|
186
|
-
* @param {string} to The location to which the item should be copied.
|
|
187
|
-
* @param {PullFileOptions} opts
|
|
188
|
-
* @returns {Promise<string>} The destination path (same as `to`)
|
|
189
|
-
*/
|
|
190
|
-
async pullFile(from, to, opts) {
|
|
191
|
-
const subcommandOptions = [
|
|
192
|
-
'--domain-type', opts.domainType,
|
|
193
|
-
'--domain-identifier', opts.domainIdentifier,
|
|
194
|
-
'--source', from,
|
|
195
|
-
'--destination', to,
|
|
196
|
-
];
|
|
197
|
-
if (opts.username) {
|
|
198
|
-
subcommandOptions.push('--user', opts.username);
|
|
199
|
-
}
|
|
200
|
-
await this.execute(['device', 'copy', 'from'], {
|
|
201
|
-
subcommandOptions,
|
|
202
|
-
timeout: opts.timeout ?? 120000,
|
|
203
|
-
asJson: false,
|
|
204
|
-
});
|
|
205
|
-
return to;
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Send POSIX signal to the running process
|
|
209
|
-
*
|
|
210
|
-
* @param {number|string} pid The process identifier to send a signal to
|
|
211
|
-
* @param {number|string} signal The signal to send to a process. See 'man signal' for a list of signals
|
|
212
|
-
* @returns {Promise<void>}
|
|
213
|
-
*/
|
|
214
|
-
async sendSignalToProcess(pid, signal) {
|
|
215
|
-
await this.execute(['device', 'process', 'signal'], {
|
|
216
|
-
subcommandOptions: ['--signal', `${signal}`, '--pid', `${pid}`]
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* Retrieves the list of installed apps from the device
|
|
221
|
-
*
|
|
222
|
-
* @param {string?} [bundleId=null] Provide the target bundle identifier
|
|
223
|
-
* to speed up the lookup.
|
|
224
|
-
* @returns {Promise<AppInfo[]>} Empty array is returned if no matching apps are found
|
|
225
|
-
*/
|
|
226
|
-
async listApps(bundleId = null) {
|
|
227
|
-
const subcommandOptions = ['--include-all-apps'];
|
|
228
|
-
if (bundleId) {
|
|
229
|
-
subcommandOptions.push('--bundle-id', bundleId);
|
|
230
|
-
}
|
|
231
|
-
const { stdout } = await this.execute(['device', 'info', 'apps'], {
|
|
232
|
-
subcommandOptions,
|
|
233
|
-
});
|
|
234
|
-
return JSON.parse(stdout).result.apps;
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* Launch the given bundle id application with the given environment variable.
|
|
238
|
-
* This method is over devicectl command, this it may take additional seconds to launch the app.
|
|
239
|
-
* Please use via WDA or via appium-ios-device as primary method to launch app if possible.
|
|
240
|
-
*
|
|
241
|
-
* @param {string} bundleId Bundle id to launch.
|
|
242
|
-
* @param {LaunchAppOptions} opts launching app with devicectl command options.
|
|
243
|
-
* @returns {Promise<void>}
|
|
244
|
-
* @throws {Error} If the launching app command fails. For example, the given bundle id did not exist.
|
|
245
|
-
*/
|
|
246
|
-
async launchApp(bundleId, opts) {
|
|
247
|
-
const { env, terminateExisting = false } = opts;
|
|
248
|
-
const subcommandOptions = [];
|
|
249
|
-
if (terminateExisting) {
|
|
250
|
-
subcommandOptions.push('--terminate-existing');
|
|
251
|
-
}
|
|
252
|
-
;
|
|
253
|
-
if (!lodash_1.default.isEmpty(env)) {
|
|
254
|
-
subcommandOptions.push('--environment-variables', JSON.stringify(lodash_1.default.mapValues(env, (v) => lodash_1.default.toString(v))));
|
|
255
|
-
}
|
|
256
|
-
;
|
|
257
|
-
// The bundle id should be the last to apply arguments properly.
|
|
258
|
-
// devicectl command might not raise exception while the order is wrong.
|
|
259
|
-
subcommandOptions.push(bundleId);
|
|
260
|
-
await this.execute(['device', 'process', 'launch'], { subcommandOptions, asJson: false });
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
exports.Devicectl = Devicectl;
|
|
264
|
-
//# sourceMappingURL=devicectl.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"devicectl.js","sourceRoot":"","sources":["../../../lib/real-device-clients/devicectl.js"],"names":[],"mappings":";;;;;;AAAA,+CAA8C;AAC9C,4CAAoC;AACpC,oDAAuB;AAEvB,MAAM,KAAK,GAAG,OAAO,CAAC;AAEtB;;;;GAIG;AAEH;;;;;;EAME;AAEF;;;;;;;;;;;;;GAaG;AAEH;;;;;;;;;;;;;;;EAeE;AAEF;;;;;;;GAOG;AAEH;;GAEG;AAEH;;;;GAIG;AAEH;;;;;;;;;;GAUG;AAGH;;;;;GAKG;AAEH,MAAa,SAAS;IACpB;;;;OAIG;IACH,YAAY,IAAI,EAAE,GAAG;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI;QAC5B,MAAM,EACJ,SAAS,GAAG,KAAK,EACjB,YAAY,GAAG,KAAK,EACpB,MAAM,GAAG,IAAI,EACb,iBAAiB,EACjB,OAAO,GACR,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0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
/**
|
|
3
|
-
* Returns information about the active application.
|
|
4
|
-
*
|
|
5
|
-
* @returns {Promise<import('./types').ActiveAppInfo>} Active app information
|
|
6
|
-
* @throws {Error} if an error raised by command
|
|
7
|
-
* @this {import('../driver').XCUITestDriver}
|
|
8
|
-
*/
|
|
9
|
-
async mobileGetActiveAppInfo() {
|
|
10
|
-
return /** @type {import('./types').ActiveAppInfo} */ (
|
|
11
|
-
await this.proxyCommand('/wda/activeAppInfo', 'GET')
|
|
12
|
-
);
|
|
13
|
-
},
|
|
14
|
-
};
|
package/lib/commands/index.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import activeAppInfoExtensions from './activeAppInfo';
|
|
2
|
-
import alertExtensions from './alert';
|
|
3
|
-
import appManagementExtensions from './app-management';
|
|
4
|
-
import appearanceExtensions from './appearance';
|
|
5
|
-
import appStringsExtensions from './app-strings';
|
|
6
|
-
import auditExtensions from './audit';
|
|
7
|
-
import batteryExtensions from './battery';
|
|
8
|
-
import biometricExtensions from './biometric';
|
|
9
|
-
import certificateExtensions from './certificate';
|
|
10
|
-
import clipboardExtensions from './clipboard';
|
|
11
|
-
import conditionExtensions from './condition';
|
|
12
|
-
import contentSizeExtensions from './content-size';
|
|
13
|
-
import contextExtensions from './context';
|
|
14
|
-
import deviceInfoExtensions from './deviceInfo';
|
|
15
|
-
import elementExtensions from './element';
|
|
16
|
-
import executeExtensions from './execute';
|
|
17
|
-
import fileMovementExtensions from './file-movement';
|
|
18
|
-
import findExtensions from './find';
|
|
19
|
-
import generalExtensions from './general';
|
|
20
|
-
import geolocationExtensions from './geolocation';
|
|
21
|
-
import gestureExtensions from './gesture';
|
|
22
|
-
import increaseContrastExtensions from './increase-contrast';
|
|
23
|
-
import iohidExtensions from './iohid';
|
|
24
|
-
import keychainsExtensions from './keychains';
|
|
25
|
-
import keyboardExtensions from './keyboard';
|
|
26
|
-
import localizationExtensions from './localization';
|
|
27
|
-
import locationExtensions from './location';
|
|
28
|
-
import lockExtensions from './lock';
|
|
29
|
-
import logExtensions from './log';
|
|
30
|
-
import memoryExtensions from './memory';
|
|
31
|
-
import navigationExtensions from './navigation';
|
|
32
|
-
import notificationsExtensions from './notifications';
|
|
33
|
-
import pasteboardExtensions from './pasteboard';
|
|
34
|
-
import pcapExtensions from './pcap';
|
|
35
|
-
import performanceExtensions from './performance';
|
|
36
|
-
import permissionsExtensions from './permissions';
|
|
37
|
-
import proxyHelperExtensions from './proxy-helper';
|
|
38
|
-
import recordAudioExtensions from './record-audio';
|
|
39
|
-
import recordScreenExtensions from './recordscreen';
|
|
40
|
-
import screenshotExtensions from './screenshots';
|
|
41
|
-
import sourceExtensions from './source';
|
|
42
|
-
import simctl from './simctl';
|
|
43
|
-
import timeoutExtensions from './timeouts';
|
|
44
|
-
import webExtensions from './web';
|
|
45
|
-
import xctestExtensions from './xctest';
|
|
46
|
-
import xctestRecordScreenExtensions from './xctest-record-screen';
|
|
47
|
-
|
|
48
|
-
export default {
|
|
49
|
-
activeAppInfoExtensions,
|
|
50
|
-
alertExtensions,
|
|
51
|
-
appearanceExtensions,
|
|
52
|
-
appManagementExtensions,
|
|
53
|
-
appStringsExtensions,
|
|
54
|
-
auditExtensions,
|
|
55
|
-
batteryExtensions,
|
|
56
|
-
biometricExtensions,
|
|
57
|
-
certificateExtensions,
|
|
58
|
-
clipboardExtensions,
|
|
59
|
-
conditionExtensions,
|
|
60
|
-
contentSizeExtensions,
|
|
61
|
-
contextExtensions,
|
|
62
|
-
deviceInfoExtensions,
|
|
63
|
-
elementExtensions,
|
|
64
|
-
executeExtensions,
|
|
65
|
-
fileMovementExtensions,
|
|
66
|
-
findExtensions,
|
|
67
|
-
generalExtensions,
|
|
68
|
-
geolocationExtensions,
|
|
69
|
-
gestureExtensions,
|
|
70
|
-
increaseContrastExtensions,
|
|
71
|
-
iohidExtensions,
|
|
72
|
-
keychainsExtensions,
|
|
73
|
-
keyboardExtensions,
|
|
74
|
-
localizationExtensions,
|
|
75
|
-
locationExtensions,
|
|
76
|
-
lockExtensions,
|
|
77
|
-
logExtensions,
|
|
78
|
-
memoryExtensions,
|
|
79
|
-
navigationExtensions,
|
|
80
|
-
notificationsExtensions,
|
|
81
|
-
pasteboardExtensions,
|
|
82
|
-
pcapExtensions,
|
|
83
|
-
performanceExtensions,
|
|
84
|
-
permissionsExtensions,
|
|
85
|
-
proxyHelperExtensions,
|
|
86
|
-
recordAudioExtensions,
|
|
87
|
-
recordScreenExtensions,
|
|
88
|
-
simctl,
|
|
89
|
-
screenshotExtensions,
|
|
90
|
-
sourceExtensions,
|
|
91
|
-
timeoutExtensions,
|
|
92
|
-
webExtensions,
|
|
93
|
-
xctestExtensions,
|
|
94
|
-
xctestRecordScreenExtensions,
|
|
95
|
-
};
|
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
import {exec, SubProcess} from 'teen_process';
|
|
2
|
-
import {util} from 'appium/support';
|
|
3
|
-
import _ from 'lodash';
|
|
4
|
-
|
|
5
|
-
const XCRUN = 'xcrun';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @typedef {Object} ProcessInfo
|
|
9
|
-
* @property {number} processIdentifier
|
|
10
|
-
* @property {string} executable
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/*
|
|
14
|
-
Example:
|
|
15
|
-
{
|
|
16
|
-
"executable" : "file:///sbin/launchd",
|
|
17
|
-
"processIdentifier" : 1
|
|
18
|
-
},
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @typedef {Object} AppInfo
|
|
23
|
-
* @property {boolean} appClip
|
|
24
|
-
* @property {boolean} builtByDeveloper
|
|
25
|
-
* @property {string} bundleIdentifier
|
|
26
|
-
* @property {string} bundleVersion
|
|
27
|
-
* @property {boolean} defaultApp
|
|
28
|
-
* @property {boolean} hidden
|
|
29
|
-
* @property {boolean} internalApp
|
|
30
|
-
* @property {string} name
|
|
31
|
-
* @property {boolean} removable
|
|
32
|
-
* @property {string} url
|
|
33
|
-
* @property {string} version
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
/*
|
|
37
|
-
Example:
|
|
38
|
-
{
|
|
39
|
-
"appClip" : false,
|
|
40
|
-
"builtByDeveloper" : false,
|
|
41
|
-
"bundleIdentifier" : "com.apple.mobilesafari",
|
|
42
|
-
"bundleVersion" : "8617.1.17.10.9",
|
|
43
|
-
"defaultApp" : true,
|
|
44
|
-
"hidden" : false,
|
|
45
|
-
"internalApp" : false,
|
|
46
|
-
"name" : "Safari",
|
|
47
|
-
"removable" : false,
|
|
48
|
-
"url" : "file:///Applications/MobileSafari.app/",
|
|
49
|
-
"version" : "17.2"
|
|
50
|
-
}
|
|
51
|
-
*/
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* @typedef {Object} ExecuteOptions
|
|
55
|
-
* @property {boolean} [logStdout=false]
|
|
56
|
-
* @property {boolean} [asJson=true]
|
|
57
|
-
* @property {boolean} [asynchronous=false]
|
|
58
|
-
* @property {string[]|string} [subcommandOptions]
|
|
59
|
-
* @property {number} [timeout]
|
|
60
|
-
*/
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* @typedef {{asynchronous: true}} TAsyncOpts
|
|
64
|
-
*/
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* @typedef {Object} ListFilesOptions
|
|
68
|
-
* @property {string} [username] The username of the user we should target. Only relevant for certain domains.
|
|
69
|
-
* @property {string} [subdirectory] A subdirectory within the domain. If not specified, defaults to the root.
|
|
70
|
-
*/
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* @typedef {Object} PullFileOptions
|
|
74
|
-
* @property {string} [username] The username of the user we should target. Only relevant for certain domains.
|
|
75
|
-
* @property {string} domainType The file service domain. Valid values are: temporary, rootStaging, appDataContainer, appGroupDataContainer,
|
|
76
|
-
* systemCrashLogs. You must specify a valid domain and identifier pair. Each domain is accompanied by an identifier
|
|
77
|
-
* that provides additional context. For example, if the domain is an app data container, the identifier is the bundle
|
|
78
|
-
* ID of the app. For temporary directories and root staging areas, the identifier is a unique client-provided string
|
|
79
|
-
* which is used to get your own space, separate from those of other clients.
|
|
80
|
-
* @property {string} domainIdentifier A unique string used to provide additional context to the domain.
|
|
81
|
-
* @property {number} [timeout=120000] The timeout for pulling a file in milliseconds.
|
|
82
|
-
*/
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* An option for launchApp method by devicectl.
|
|
87
|
-
* @typedef {Object} LaunchAppOptions
|
|
88
|
-
* @property {import('@appium/types').StringRecord<string|number>} [env] Bundle id to Environment variables for the launching app process.
|
|
89
|
-
* @property {boolean} [terminateExisting=false] Whether terminating the already running app.
|
|
90
|
-
*/
|
|
91
|
-
|
|
92
|
-
export class Devicectl {
|
|
93
|
-
/**
|
|
94
|
-
* @since Xcode 15, iOS 17
|
|
95
|
-
* @param {string} udid
|
|
96
|
-
* @param {import('@appium/types').AppiumLogger} log
|
|
97
|
-
*/
|
|
98
|
-
constructor(udid, log) {
|
|
99
|
-
this.udid = udid;
|
|
100
|
-
this.log = log;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* @template {ExecuteOptions} TExecOpts
|
|
105
|
-
* @param {string[]} subcommand
|
|
106
|
-
* @param {TExecOpts} [opts]
|
|
107
|
-
* @return {Promise<TExecOpts extends TAsyncOpts ? import('teen_process').SubProcess : import('teen_process').TeenProcessExecResult>}
|
|
108
|
-
*/
|
|
109
|
-
async execute(subcommand, opts) {
|
|
110
|
-
const {
|
|
111
|
-
logStdout = false,
|
|
112
|
-
asynchronous = false,
|
|
113
|
-
asJson = true,
|
|
114
|
-
subcommandOptions,
|
|
115
|
-
timeout,
|
|
116
|
-
} = opts ?? {};
|
|
117
|
-
|
|
118
|
-
const finalArgs = [
|
|
119
|
-
'devicectl', ...subcommand,
|
|
120
|
-
'--device', this.udid,
|
|
121
|
-
];
|
|
122
|
-
if (subcommandOptions && !_.isEmpty(subcommandOptions)) {
|
|
123
|
-
finalArgs.push(
|
|
124
|
-
...(Array.isArray(subcommandOptions) ? subcommandOptions : [subcommandOptions])
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
if (asJson) {
|
|
128
|
-
finalArgs.push('--quiet', '--json-output', '-');
|
|
129
|
-
}
|
|
130
|
-
const cmdStr = util.quote([XCRUN, ...finalArgs]);
|
|
131
|
-
this.log.debug(`Executing ${cmdStr}`);
|
|
132
|
-
try {
|
|
133
|
-
if (asynchronous) {
|
|
134
|
-
const result = new SubProcess(XCRUN, finalArgs);
|
|
135
|
-
await result.start(0);
|
|
136
|
-
// @ts-ignore TS does not understand it
|
|
137
|
-
return result;
|
|
138
|
-
}
|
|
139
|
-
const result = await exec(
|
|
140
|
-
XCRUN,
|
|
141
|
-
finalArgs,
|
|
142
|
-
...(_.isNumber(timeout) ? [{timeout}] : []),
|
|
143
|
-
);
|
|
144
|
-
if (logStdout) {
|
|
145
|
-
this.log.debug(`Command output: ${result.stdout}`);
|
|
146
|
-
}
|
|
147
|
-
// @ts-ignore TS does not understand it
|
|
148
|
-
return result;
|
|
149
|
-
} catch (e) {
|
|
150
|
-
throw new Error(`'${cmdStr}' failed. Original error: ${e.stderr || e.stdout || e.message}`);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Simulates memory warning for the process with the given PID
|
|
156
|
-
*
|
|
157
|
-
* @param {number|string} pid The process identifier to simulate the Low Memory warning for
|
|
158
|
-
* @return {Promise<void>}
|
|
159
|
-
*/
|
|
160
|
-
async sendMemoryWarning(pid) {
|
|
161
|
-
await this.execute(['device', 'process', 'sendMemoryWarning'], {
|
|
162
|
-
subcommandOptions: ['--pid', `${pid}`]
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Lists running processes on the device
|
|
168
|
-
*
|
|
169
|
-
* @returns {Promise<ProcessInfo[]>}
|
|
170
|
-
*/
|
|
171
|
-
async listProcesses() {
|
|
172
|
-
const {stdout} = await this.execute(['device', 'info', 'processes']);
|
|
173
|
-
return JSON.parse(stdout).result.runningProcesses;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* Lists files at a specified path on the device
|
|
178
|
-
*
|
|
179
|
-
* @param {string} domainType The file service domain. Valid values are: temporary, rootStaging, appDataContainer, appGroupDataContainer,
|
|
180
|
-
* systemCrashLogs. You must specify a valid domain and identifier pair. Each domain is accompanied by an identifier
|
|
181
|
-
* that provides additional context. For example, if the domain is an app data container, the identifier is the bundle
|
|
182
|
-
* ID of the app. For temporary directories and root staging areas, the identifier is a unique client-provided string
|
|
183
|
-
* which is used to get your own space, separate from those of other clients.
|
|
184
|
-
* @param {string} domainIdentifier A unique string used to provide additional context to the domain.
|
|
185
|
-
* @param {ListFilesOptions} [opts={}]
|
|
186
|
-
* @returns {Promise<string[]>} List of file names (could be empty)
|
|
187
|
-
*/
|
|
188
|
-
async listFiles(domainType, domainIdentifier, opts = {}) {
|
|
189
|
-
const subcommandOptions = [
|
|
190
|
-
'--domain-type', domainType,
|
|
191
|
-
'--domain-identifier', domainIdentifier,
|
|
192
|
-
];
|
|
193
|
-
if (opts.username) {
|
|
194
|
-
subcommandOptions.push('--username', opts.username);
|
|
195
|
-
}
|
|
196
|
-
if (opts.subdirectory) {
|
|
197
|
-
subcommandOptions.push('--subdirectory', opts.subdirectory);
|
|
198
|
-
}
|
|
199
|
-
const {stdout} = await this.execute(['device', 'info', 'files'], {
|
|
200
|
-
subcommandOptions,
|
|
201
|
-
});
|
|
202
|
-
return JSON.parse(stdout).result.files.map(({name}) => name);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Pulls a file from the specified path on the device to a local file system
|
|
207
|
-
*
|
|
208
|
-
* @param {string} from The item which should be copied.
|
|
209
|
-
* @param {string} to The location to which the item should be copied.
|
|
210
|
-
* @param {PullFileOptions} opts
|
|
211
|
-
* @returns {Promise<string>} The destination path (same as `to`)
|
|
212
|
-
*/
|
|
213
|
-
async pullFile(from, to, opts) {
|
|
214
|
-
const subcommandOptions = [
|
|
215
|
-
'--domain-type', opts.domainType,
|
|
216
|
-
'--domain-identifier', opts.domainIdentifier,
|
|
217
|
-
'--source', from,
|
|
218
|
-
'--destination', to,
|
|
219
|
-
];
|
|
220
|
-
if (opts.username) {
|
|
221
|
-
subcommandOptions.push('--user', opts.username);
|
|
222
|
-
}
|
|
223
|
-
await this.execute(['device', 'copy', 'from'], {
|
|
224
|
-
subcommandOptions,
|
|
225
|
-
timeout: opts.timeout ?? 120000,
|
|
226
|
-
asJson: false,
|
|
227
|
-
});
|
|
228
|
-
return to;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Send POSIX signal to the running process
|
|
233
|
-
*
|
|
234
|
-
* @param {number|string} pid The process identifier to send a signal to
|
|
235
|
-
* @param {number|string} signal The signal to send to a process. See 'man signal' for a list of signals
|
|
236
|
-
* @returns {Promise<void>}
|
|
237
|
-
*/
|
|
238
|
-
async sendSignalToProcess(pid, signal) {
|
|
239
|
-
await this.execute(['device', 'process', 'signal'], {
|
|
240
|
-
subcommandOptions: ['--signal', `${signal}`, '--pid', `${pid}`]
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Retrieves the list of installed apps from the device
|
|
246
|
-
*
|
|
247
|
-
* @param {string?} [bundleId=null] Provide the target bundle identifier
|
|
248
|
-
* to speed up the lookup.
|
|
249
|
-
* @returns {Promise<AppInfo[]>} Empty array is returned if no matching apps are found
|
|
250
|
-
*/
|
|
251
|
-
async listApps(bundleId = null) {
|
|
252
|
-
const subcommandOptions = ['--include-all-apps'];
|
|
253
|
-
if (bundleId) {
|
|
254
|
-
subcommandOptions.push('--bundle-id', bundleId);
|
|
255
|
-
}
|
|
256
|
-
const {stdout} = await this.execute(['device', 'info', 'apps'], {
|
|
257
|
-
subcommandOptions,
|
|
258
|
-
});
|
|
259
|
-
return JSON.parse(stdout).result.apps;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* Launch the given bundle id application with the given environment variable.
|
|
264
|
-
* This method is over devicectl command, this it may take additional seconds to launch the app.
|
|
265
|
-
* Please use via WDA or via appium-ios-device as primary method to launch app if possible.
|
|
266
|
-
*
|
|
267
|
-
* @param {string} bundleId Bundle id to launch.
|
|
268
|
-
* @param {LaunchAppOptions} opts launching app with devicectl command options.
|
|
269
|
-
* @returns {Promise<void>}
|
|
270
|
-
* @throws {Error} If the launching app command fails. For example, the given bundle id did not exist.
|
|
271
|
-
*/
|
|
272
|
-
async launchApp(bundleId, opts) {
|
|
273
|
-
const {
|
|
274
|
-
env,
|
|
275
|
-
terminateExisting = false
|
|
276
|
-
} = opts;
|
|
277
|
-
|
|
278
|
-
const subcommandOptions = [];
|
|
279
|
-
if (terminateExisting) {
|
|
280
|
-
subcommandOptions.push('--terminate-existing');
|
|
281
|
-
};
|
|
282
|
-
if (!_.isEmpty(env)) {
|
|
283
|
-
subcommandOptions.push('--environment-variables', JSON.stringify(_.mapValues(env, (v) => _.toString(v))));
|
|
284
|
-
};
|
|
285
|
-
// The bundle id should be the last to apply arguments properly.
|
|
286
|
-
// devicectl command might not raise exception while the order is wrong.
|
|
287
|
-
subcommandOptions.push(bundleId);
|
|
288
|
-
|
|
289
|
-
await this.execute(['device', 'process', 'launch'], { subcommandOptions, asJson: false});
|
|
290
|
-
}
|
|
291
|
-
}
|