appium-xcuitest-driver 10.13.2 → 10.13.4

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/build/lib/commands/app-management.d.ts +99 -76
  3. package/build/lib/commands/app-management.d.ts.map +1 -1
  4. package/build/lib/commands/app-management.js +83 -73
  5. package/build/lib/commands/app-management.js.map +1 -1
  6. package/build/lib/commands/general.d.ts +84 -80
  7. package/build/lib/commands/general.d.ts.map +1 -1
  8. package/build/lib/commands/general.js +66 -53
  9. package/build/lib/commands/general.js.map +1 -1
  10. package/build/lib/commands/log.d.ts +42 -44
  11. package/build/lib/commands/log.d.ts.map +1 -1
  12. package/build/lib/commands/log.js +32 -53
  13. package/build/lib/commands/log.js.map +1 -1
  14. package/build/lib/commands/navigation.d.ts +1 -1
  15. package/build/lib/commands/navigation.d.ts.map +1 -1
  16. package/build/lib/commands/performance.d.ts +36 -55
  17. package/build/lib/commands/performance.d.ts.map +1 -1
  18. package/build/lib/commands/performance.js +93 -86
  19. package/build/lib/commands/performance.js.map +1 -1
  20. package/build/lib/commands/recordscreen.d.ts +31 -63
  21. package/build/lib/commands/recordscreen.d.ts.map +1 -1
  22. package/build/lib/commands/recordscreen.js +29 -28
  23. package/build/lib/commands/recordscreen.js.map +1 -1
  24. package/build/lib/commands/xctest.d.ts +37 -37
  25. package/build/lib/commands/xctest.d.ts.map +1 -1
  26. package/build/lib/commands/xctest.js +38 -50
  27. package/build/lib/commands/xctest.js.map +1 -1
  28. package/build/lib/execute-method-map.d.ts.map +1 -1
  29. package/build/lib/execute-method-map.js +0 -2
  30. package/build/lib/execute-method-map.js.map +1 -1
  31. package/lib/commands/app-management.ts +414 -0
  32. package/lib/commands/{general.js → general.ts} +101 -76
  33. package/lib/commands/{log.js → log.ts} +68 -68
  34. package/lib/commands/{performance.js → performance.ts} +133 -114
  35. package/lib/commands/{recordscreen.js → recordscreen.ts} +78 -50
  36. package/lib/commands/{xctest.js → xctest.ts} +78 -71
  37. package/lib/execute-method-map.ts +0 -2
  38. package/npm-shrinkwrap.json +8 -8
  39. package/package.json +1 -1
  40. package/lib/commands/app-management.js +0 -346
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "xcuitest",
9
9
  "xctest"
10
10
  ],
11
- "version": "10.13.2",
11
+ "version": "10.13.4",
12
12
  "author": "Appium Contributors",
13
13
  "license": "Apache-2.0",
14
14
  "repository": {
@@ -1,346 +0,0 @@
1
- import _ from 'lodash';
2
- import {fs, util} from 'appium/support';
3
- import {errors} from 'appium/driver';
4
- import {services} from 'appium-ios-device';
5
- import path from 'node:path';
6
- import B from 'bluebird';
7
- import {
8
- SUPPORTED_EXTENSIONS,
9
- onPostConfigureApp,
10
- onDownloadApp,
11
- } from '../app-utils';
12
-
13
- /**
14
- * Installs the given application to the device under test.
15
- *
16
- * Please ensure the app is built for a correct architecture and is signed with a proper developer signature (for real devices) prior to calling this.
17
- * @param {string} app - See docs for `appium:app` capability
18
- * @param {number} [timeoutMs] - The maximum time to wait until app install is finished (in ms) on real devices.
19
- * If not provided, then the value of `appium:appPushTimeout` capability is used. If the capability is not provided then the default is 240000ms (4 minutes).
20
- * @param {boolean} [checkVersion] - If the application installation follows currently installed application's version status if provided.
21
- * No checking occurs if no this option.
22
- * @privateRemarks Link to capability docs
23
- * @returns {Promise<void>}
24
- * @this {XCUITestDriver}
25
- */
26
- export async function mobileInstallApp(app, timeoutMs, checkVersion) {
27
- const srcAppPath = await this.helpers.configureApp(app, {
28
- onPostProcess: onPostConfigureApp.bind(this),
29
- onDownload: onDownloadApp.bind(this),
30
- supportedExtensions: SUPPORTED_EXTENSIONS,
31
- });
32
- this.log.info(
33
- `Installing '${srcAppPath}' to the ${this.isRealDevice() ? 'real device' : 'Simulator'} ` +
34
- `with UDID '${this.device.udid}'`,
35
- );
36
- if (!(await fs.exists(srcAppPath))) {
37
- throw this.log.errorWithException(
38
- `The application at '${srcAppPath}' does not exist or is not accessible`,
39
- );
40
- }
41
-
42
- const bundleId = await this.appInfosCache.extractBundleId(srcAppPath);
43
- if (checkVersion) {
44
- const {install} = await this.checkAutInstallationState({
45
- enforceAppInstall: false,
46
- fullReset: false,
47
- noReset: false,
48
- bundleId,
49
- app: srcAppPath,
50
- });
51
-
52
- if (!install) {
53
- this.log.info(`Skipping the installation of '${bundleId}'`);
54
- return;
55
- }
56
- }
57
-
58
- await this.device.installApp(
59
- srcAppPath,
60
- bundleId,
61
- {
62
- timeoutMs: timeoutMs ?? this.opts.appPushTimeout
63
- },
64
- );
65
- this.log.info(`Installation of '${srcAppPath}' succeeded`);
66
- }
67
-
68
- /**
69
- * Checks whether the given application is installed on the device under test.
70
- * Offload app is handled as not installed.
71
- *
72
- * @param {string} bundleId - The bundle identifier of the application to be checked
73
- * @returns {Promise<boolean>} `true` if the application is installed; `false` otherwise
74
- * @this {XCUITestDriver}
75
- */
76
- export async function mobileIsAppInstalled(bundleId) {
77
- const installed = await this.device.isAppInstalled(bundleId);
78
- this.log.info(`App '${bundleId}' is${installed ? '' : ' not'} installed`);
79
- return installed;
80
- }
81
-
82
- /**
83
- * Removes/uninstalls the given application from the device under test.
84
- * Offload app data could also be removed.
85
- *
86
- * @param {string} bundleId - The bundle identifier of the application to be removed
87
- * @returns {Promise<boolean>} `true` if the application has been removed successfully; `false` otherwise
88
- * @this {XCUITestDriver}
89
- */
90
- export async function mobileRemoveApp(bundleId) {
91
- this.log.info(
92
- `Uninstalling the application with bundle identifier '${bundleId}' ` +
93
- `from the ${this.isRealDevice() ? 'real device' : 'Simulator'} with UDID '${this.device.udid}'`,
94
- );
95
- try {
96
- await this.device.removeApp(bundleId);
97
- this.log.info(`Removal of '${bundleId}' succeeded`);
98
- return true;
99
- } catch (err) {
100
- this.log.warn(`Cannot remove '${bundleId}'. Original error: ${err.message}`);
101
- return false;
102
- }
103
- }
104
-
105
- /**
106
- * Executes the given app on the device under test.
107
- *
108
- * If the app is already running it will be activated. If the app is not installed or cannot be launched then an exception is thrown.
109
- * @param {string} bundleId - The bundle identifier of the application to be launched
110
- * @param {string|string[]} [args] - One or more command line arguments for the app. If the app is already running then this argument is ignored.
111
- * @param {object} [environment] - Environment variables mapping for the app. If the app is already running then this argument is ignored.
112
- * @returns {Promise<void>}
113
- * @this {XCUITestDriver}
114
- */
115
- export async function mobileLaunchApp(bundleId, args, environment) {
116
- /** @type { {arguments?: any[], environment?: any, bundleId: string} } */
117
- const launchOptions = {bundleId};
118
- if (args) {
119
- launchOptions.arguments = Array.isArray(args) ? args : [args];
120
- }
121
- if (environment) {
122
- launchOptions.environment = environment;
123
- }
124
- await this.proxyCommand('/wda/apps/launch', 'POST', launchOptions);
125
- }
126
-
127
- /**
128
- * Terminates the given app on the device under test.
129
- *
130
- * This command performs termination via [XCTest's `terminate`](https://developer.apple.com/documentation/xctest/xcuiapplication/1500637-terminate) API. If the app is not installed an exception is thrown. If the app is not running then nothing is done.
131
- * @param {string} bundleId - The bundle identifier of the application to be terminated
132
- * @returns {Promise<boolean>} `true` if the app has been terminated successfully; `false` otherwise
133
- * @this {XCUITestDriver}
134
- */
135
- export async function mobileTerminateApp(bundleId) {
136
- return /** @type {boolean} */ (
137
- await this.proxyCommand('/wda/apps/terminate', 'POST', {bundleId})
138
- );
139
- }
140
-
141
- /**
142
- * Activate the given app on the device under test.
143
- *
144
- * This pushes the app to the foreground if it is running in the background. An exception is thrown if the app is not install or isn't running. Nothing is done if the app is already in the foreground.
145
- *
146
- * @param {string} bundleId - The bundle identifier of the application to be activated
147
- * @returns {Promise<void>}
148
- * @this {XCUITestDriver}
149
- */
150
- export async function mobileActivateApp(bundleId) {
151
- await this.proxyCommand('/wda/apps/activate', 'POST', {bundleId});
152
- }
153
-
154
- /**
155
- * Kill the given app on the real device under test by instruments service.
156
- *
157
- * If the app is not running or kill failed, then nothing is done.
158
- *
159
- * @remarks `appium-xcuitest-driver` v4.4 does not require `py-ios-device` to be installed.
160
- * @privateRemarks See implementation at https://github.com/YueChen-C/py-ios-device/blob/51f4683c5c3c385a015858ada07a5f1c62d3cf57/ios_device/cli/base.py#L220
161
- * @see https://github.com/YueChen-C/py-ios-device
162
- * @param {string} bundleId - The bundle identifier of the application to be killed
163
- * @returns {Promise<boolean>} `true` if the app has been killed successfully; `false` otherwise
164
- * @group Real Device Only
165
- * @this {XCUITestDriver}
166
- */
167
- export async function mobileKillApp(bundleId) {
168
- if (!this.isRealDevice()) {
169
- throw new errors.UnsupportedOperationError('A real device is required');
170
- }
171
-
172
- return await /** @type {import('../device/real-device-management').RealDevice} */ (this.device).terminateApp(
173
- bundleId, String(this.opts.platformVersion)
174
- );
175
- }
176
-
177
- /**
178
- * Queries the state of an installed application from the device under test.
179
- *
180
- * If the app with the given `bundleId` is not installed, an exception will be thrown.
181
- *
182
- * @param {string} bundleId - The bundle identifier of the application to be queried
183
- * @returns {Promise<AppState>} The actual application state code
184
- * @see https://developer.apple.com/documentation/xctest/xcuiapplicationstate?language=objc
185
- * @this {XCUITestDriver}
186
- */
187
- export async function mobileQueryAppState(bundleId) {
188
- return /** @type {AppState} */ (await this.proxyCommand('/wda/apps/state', 'POST', {bundleId}));
189
- }
190
-
191
- /**
192
- * @param {string} appPath
193
- * @param {object} opts
194
- * @this {XCUITestDriver}
195
- */
196
- export async function installApp(appPath, {timeoutMs, strategy} = {}) {
197
- // @ts-ignore Probably a TS bug
198
- await this.mobileInstallApp(appPath, timeoutMs, strategy);
199
- }
200
-
201
- /**
202
- * @param {string} bundleId
203
- * @param {object} opts
204
- * @this {XCUITestDriver}
205
- */
206
- export async function activateApp(bundleId, opts = {}) {
207
- const {environment, arguments: args} = opts;
208
- // @ts-ignore Probably a TS bug
209
- return await this.mobileLaunchApp(bundleId, args, environment);
210
- }
211
-
212
- /**
213
- * @param {string} bundleId
214
- * @this {XCUITestDriver}
215
- */
216
- export async function isAppInstalled(bundleId) {
217
- return await this.mobileIsAppInstalled(bundleId);
218
- }
219
-
220
- /**
221
- * @param {string} bundleId
222
- * @this {XCUITestDriver}
223
- * @returns {Promise<boolean>}
224
- */
225
- export async function terminateApp(bundleId) {
226
- return await this.mobileTerminateApp(bundleId);
227
- }
228
-
229
- /**
230
- * @param {string} bundleId
231
- * @this {XCUITestDriver}
232
- */
233
- export async function queryAppState(bundleId) {
234
- return await this.mobileQueryAppState(bundleId);
235
- }
236
-
237
- /**
238
- * List applications installed on the real device under test
239
- *
240
- * Read [Pushing/Pulling files](https://appium.io/docs/en/writing-running-appium/ios/ios-xctest-file-movement/) for more details.
241
- * @param {'User'|'System'} applicationType - The type of applications to list.
242
- * @returns {Promise<Record<string,any>[]>} A list of apps where each item is a mapping of bundle identifiers to maps of platform-specific app properties.
243
- * @remarks Having `UIFileSharingEnabled` set to `true` in the return app properties map means this app supports file upload/download in its `documents` container.
244
- * @group Real Device Only
245
- */
246
- export async function mobileListApps(applicationType = 'User') {
247
- if (!this.isRealDevice()) {
248
- throw new errors.NotImplementedError(`This extension is only supported on real devices`);
249
- }
250
-
251
- const service = await services.startInstallationProxyService(this.device.udid);
252
- try {
253
- return await service.listApplications({applicationType});
254
- } finally {
255
- service.close();
256
- }
257
- }
258
-
259
- /**
260
- * Deletes application data files, so it could start from the clean state next time
261
- * it is launched.
262
- * This API only works on a Simulator.
263
- *
264
- * @param {string} bundleId Application bundle identifier
265
- * @this {XCUITestDriver}
266
- * @returns {Promise<boolean>} true if any files from the app's data container have been deleted
267
- */
268
- export async function mobileClearApp(bundleId) {
269
- if (this.isRealDevice()) {
270
- throw new errors.NotImplementedError(
271
- `This extension is only supported on simulators. ` +
272
- `The only known way to clear app data on real devices ` +
273
- `would be to uninstall the app then perform a fresh install of it.`
274
- );
275
- }
276
-
277
- const simctl = /** @type {import('appium-ios-simulator').Simulator} */ (this.device).simctl;
278
- const dataRoot = await simctl.getAppContainer(bundleId, 'data');
279
- this.log.debug(`Got the data container root of ${bundleId} at '${dataRoot}'`);
280
- if (!await fs.exists(dataRoot)) {
281
- return false;
282
- }
283
-
284
- await this.mobileTerminateApp(bundleId);
285
- const items = await fs.readdir(dataRoot);
286
- if (!items.length) {
287
- return false;
288
- }
289
-
290
- await B.all(items.map((item) => fs.rimraf(path.join(dataRoot, item))));
291
- this.log.info(
292
- `Cleaned up ${util.pluralize('item', items.length, true)} from ${bundleId}'s data container`
293
- );
294
- return true;
295
- }
296
-
297
- /**
298
- * Close app (simulate device home button). It is possible to restore
299
- * the app after the timeout or keep it minimized based on the parameter value.
300
- *
301
- * @param {number|{timeout: number?}} [seconds]
302
- * - any positive number of seconds: come back after X seconds
303
- * - any negative number of seconds or zero: never come back
304
- * - undefined/null: never come back
305
- * - {timeout: 5000}: come back after 5 seconds
306
- * - {timeout: null}, {timeout: -2}: never come back
307
- * @this {XCUITestDriver}
308
- */
309
- export async function background(seconds) {
310
- const homescreen = '/wda/homescreen';
311
- const deactivateApp = '/wda/deactivateApp';
312
-
313
- let endpoint;
314
- let params = {};
315
- const selectEndpoint = (timeoutSeconds) => {
316
- if (!util.hasValue(timeoutSeconds)) {
317
- endpoint = homescreen;
318
- } else if (!isNaN(timeoutSeconds)) {
319
- const duration = parseFloat(timeoutSeconds);
320
- if (duration >= 0) {
321
- params = {duration};
322
- endpoint = deactivateApp;
323
- } else {
324
- endpoint = homescreen;
325
- }
326
- }
327
- };
328
- if (seconds && !_.isNumber(seconds) && _.has(seconds, 'timeout')) {
329
- const timeout = seconds.timeout;
330
- selectEndpoint(isNaN(Number(timeout)) ? timeout : parseFloat(String(timeout)) / 1000.0);
331
- } else {
332
- selectEndpoint(seconds);
333
- }
334
- if (!endpoint) {
335
- throw new errors.InvalidArgumentError(
336
- `Argument value is expected to be a valid number. ` +
337
- `${JSON.stringify(seconds)} has been provided instead`,
338
- );
339
- }
340
- return await this.proxyCommand(endpoint, 'POST', params, endpoint !== homescreen);
341
- }
342
-
343
- /**
344
- * @typedef {import('../driver').XCUITestDriver} XCUITestDriver
345
- * @typedef {import('./enum').AppState} AppState
346
- */