appium-xcuitest-driver 5.15.0 → 5.16.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.
@@ -1 +1 @@
1
- {"version":3,"file":"ios-deploy.d.ts","sourceRoot":"","sources":["../../lib/ios-deploy.js"],"names":[],"mappings":";AAsBA;IACE,uBAEC;IADC,UAAgB;IAGlB,qCAOC;IAED,wCAEC;IAED;;;;;;OAMG;IACH,aALW,MAAM,2CAEN,YAAY,GAAC,QAAQ,GAAC,UAAU,GAAC,IAAI,iBAoE/C;IAED,wFA8BC;IAED;;;;;OAKG;IACH,gBAJW,MAAM,WACN,MAAM,YACN,YAAY,GAAC,QAAQ,GAAC,UAAU,GAAC,IAAI,iBAI/C;IAED;;;;;;;OAOG;IACH,yBAJW,MAAM,GACL,QAAQ,OAAO,CAAC,CAK3B;IAED;;;;;;;;;;;OAWG;IACH,uBARW,MAAM,qBACN,MAAM,GAAC,MAAM,EAAE,GAAC,SAAS,GAIvB,QAAQ,MAAO,SAAS,CAAC,CAgBrC;IAED,oEAiFC;IAED;;;;;OAKG;IACH,kDALW,MAAM,GAEJ,QAAQ,MAAM,EAAE,CAAC,CAoB7B;IAED,mCAEC;CACF"}
1
+ {"version":3,"file":"ios-deploy.d.ts","sourceRoot":"","sources":["../../lib/ios-deploy.js"],"names":[],"mappings":";AAsBA;IACE,uBAEC;IADC,UAAgB;IAGlB,qCAOC;IAED,wCAEC;IAED;;;;;;OAMG;IACH,aALW,MAAM,2CAEN,YAAY,GAAC,QAAQ,GAAC,UAAU,GAAC,IAAI,iBAoE/C;IAED,wFA8BC;IAED;;;;;OAKG;IACH,gBAJW,MAAM,WACN,MAAM,YACN,YAAY,GAAC,QAAQ,GAAC,UAAU,GAAC,IAAI,iBAI/C;IAED;;;;;;;OAOG;IACH,yBAJW,MAAM,GACL,QAAQ,OAAO,CAAC,CAK3B;IAED;;;;;;;;;;;OAWG;IACH,uBARW,MAAM,qBACN,MAAM,GAAC,MAAM,EAAE,GAAC,SAAS,GAIvB,QAAQ,MAAO,SAAS,CAAC,CAgBrC;IAED,oEAwDC;IAED;;;;;OAKG;IACH,kDALW,MAAM,GAEJ,QAAQ,MAAM,EAAE,CAAC,CAoB7B;IAED,mCAEC;CACF"}
@@ -12,7 +12,7 @@ const lodash_1 = __importDefault(require("lodash"));
12
12
  const teen_process_1 = require("teen_process");
13
13
  const app_utils_1 = require("./app-utils");
14
14
  const ios_fs_helpers_1 = require("./ios-fs-helpers");
15
- const xcrun_1 = require("./xcrun");
15
+ const devicectl_1 = require("./devicectl");
16
16
  const APPLICATION_INSTALLED_NOTIFICATION = 'com.apple.mobile.application_installed';
17
17
  const INSTALLATION_STAGING_DIR = 'PublicStaging';
18
18
  const APPLICATION_NOTIFICATION_TIMEOUT_MS = 30 * 1000;
@@ -196,39 +196,15 @@ class IOSDeploy {
196
196
  // so hre uses the 'devicectl' only for iOS 17+.
197
197
  if (support_1.util.compareVersions(platformVersion, '>=', '17.0')) {
198
198
  logger_1.default.debug(`Calling devicectl to kill the process`);
199
- // FIXME: replace `devicectl` command with a wrapper later
200
- // or remove after implementing appium-ios-device for iOS 17+.
201
- const xcrunBinnaryPath = await (0, xcrun_1.requireXcrun)();
202
- const { stdout } = await (0, teen_process_1.exec)(xcrunBinnaryPath, [
203
- 'devicectl',
204
- 'device',
205
- 'info',
206
- 'processes',
207
- `--device`, this.udid
208
- ]);
209
- // Each line has spaces. devicectl has JSON output option, but it writes it to a file only.
210
- // Here parse the standard output directly.
211
- // e.g.:
212
- // 823 /private/var/containers/Bundle/Application/8E748312-8CBE-4C13-8295-C2EF3ED2C0C1/WebDriverAgentRunner-Runner.app/WebDriverAgentRunner-Runner
213
- // 824 /Applications/MobileSafari.app/MobileSafari
214
- // 825 /usr/libexec/debugserver
215
- const executableLine = stdout.split('\n').find((line) => line.trim().endsWith(executableName));
216
- if (!executableLine) {
199
+ const devicectl = new devicectl_1.Devicectl(this.udid, logger_1.default);
200
+ const pids = (await devicectl.listProcesses())
201
+ .filter(({ executable }) => executable.endsWith(`/${executableName}`))
202
+ .map(({ processIdentifier }) => processIdentifier);
203
+ if (lodash_1.default.isEmpty(pids)) {
217
204
  logger_1.default.info(`The process of the bundle id '${bundleId}' was not running`);
218
205
  return false;
219
206
  }
220
- await (0, teen_process_1.exec)(xcrunBinnaryPath, [
221
- 'devicectl',
222
- 'device',
223
- 'process',
224
- 'signal',
225
- '-s', `2`,
226
- // e.g.
227
- // '824 /Applications/MobileSafari.app/MobileSafari '
228
- // ' 999 /Applications/MobileSafari.app/MobileSafari ' (can include spaces in the top)
229
- '-p', `${executableLine.trim().split(/\s+/)[0]}`,
230
- `--device`, this.udid
231
- ]);
207
+ await devicectl.sendSignalToProcess(pids[0], 2);
232
208
  }
233
209
  else {
234
210
  instrumentService = await appium_ios_device_1.services.startInstrumentService(this.udid);
@@ -1 +1 @@
1
- {"version":3,"file":"ios-deploy.js","sourceRoot":"","sources":["../../lib/ios-deploy.js"],"names":[],"mappings":";;;;;AAAA,4CAAgD;AAChD,gDAAwB;AACxB,yDAA0E;AAC1E,wDAAyB;AACzB,sDAA2B;AAC3B,oDAAuB;AACvB,+CAAkC;AAClC,2CAA4C;AAC5C,qDAA4C;AAC5C,mCAAuC;AAEvC,MAAM,kCAAkC,GAAG,wCAAwC,CAAC;AACpF,MAAM,wBAAwB,GAAG,eAAe,CAAC;AACjD,MAAM,mCAAmC,GAAG,EAAE,GAAG,IAAI,CAAC;AACtD,MAAM,qBAAqB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAC5C,MAAM,UAAU,GAAG,YAAY,CAAC;AAChC,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,CAAC;IACzC,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,UAAU;CACX,CAAC,CAAC;AAEH,MAAM,SAAS;IACb,YAAY,IAAI;QACd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,KA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,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,qCAAqC,CAAC,UAAU;QACpD,MAAM,OAAO,GAAG,MAAM,4BAAQ,CAAC,6BAA6B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACxE,IAAI;YACF,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC,gBAAgB,CAAC,EAAC,eAAe,EAAE,MAAM,EAAC,CAAC,CAAC;YAC/E,OAAO,gBAAC,CAAC,MAAM,CACb,YAAY,EACZ,CAAC,GAAG,EAAE,EAAC,YAAY,EAAC,EAAE,GAAG,EAAE,EAAE;gBAC3B,IAAI,YAAY,KAAK,UAAU,EAAE;oBAC/B,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;iBACf;gBACD,OAAO,GAAG,CAAC;YACb,CAAC;YACD,uBAAuB,CAAC,CAAC,EAAE,CAAC,CAC7B,CAAC;SACH;gBAAS;YACR,OAAO,CAAC,KAAK,EAAE,CAAC;SACjB;IACH,CAAC;IAED,KAAK,CAAC,kBAAkB;QACtB,OAAO,MAAM,6BAAS,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;CACF;AAED,kBAAe,SAAS,CAAC"}
@@ -4,37 +4,6 @@ import _ from 'lodash';
4
4
 
5
5
  const SUPPORTED_GESTURE_DIRECTIONS = ['up', 'down', 'left', 'right'];
6
6
 
7
- /**
8
- * @param {any} [opts]
9
- * @returns {string|undefined}
10
- */
11
- function toElementId(opts) {
12
- if (_.isUndefined(opts)) {
13
- return;
14
- }
15
- if (_.isString(opts) || _.isNumber(opts)) {
16
- return String(opts);
17
- }
18
- if ('elementId' in opts || 'element' in opts) {
19
- return util.unwrapElement(opts);
20
- }
21
- }
22
-
23
- /**
24
- *
25
- * @param {XCUITestDriver} driver
26
- * @param {Element|string} [elementId]
27
- * @returns {Promise<string>}
28
- */
29
- async function toElementOrApplicationId(driver, elementId) {
30
- if (!_.isUndefined(elementId)) {
31
- return util.unwrapElement(elementId);
32
- }
33
- return util.unwrapElement(
34
- await driver.findNativeElementOrElements(`class name`, `XCUIElementTypeApplication`, false),
35
- );
36
- }
37
-
38
7
  /**
39
8
  * Converts the given value to a float number.
40
9
  *
@@ -43,7 +12,7 @@ async function toElementOrApplicationId(driver, elementId) {
43
12
  * @param {string} paramName
44
13
  * @returns {number}
45
14
  */
46
- function asFloat(value, paramName) {
15
+ function requireFloat(value, paramName) {
47
16
  const num = parseFloat(String(value));
48
17
  if (Number.isNaN(num)) {
49
18
  throw new errors.InvalidArgumentError(
@@ -53,24 +22,6 @@ function asFloat(value, paramName) {
53
22
  return num;
54
23
  }
55
24
 
56
- /**
57
- * Converts the given value to an integer number.
58
- *
59
- * @throws If `value` is `NaN`
60
- * @param {any} value
61
- * @param {string} paramName
62
- * @returns {number}
63
- */
64
- function asInt(value, paramName) {
65
- const num = parseInt(String(value), 10);
66
- if (Number.isNaN(num)) {
67
- throw new errors.InvalidArgumentError(
68
- `"${paramName}" parameter should be a valid integer. "${value}" is given instead`,
69
- );
70
- }
71
- return num;
72
- }
73
-
74
25
  /**
75
26
  *
76
27
  * @param {any[]} gestures
@@ -327,8 +278,8 @@ const helpers = {
327
278
  if (!_.isNil(distance)) {
328
279
  params.distance = distance;
329
280
  }
330
- elementId = await toElementOrApplicationId(this, elementId);
331
- return await this.proxyCommand(`/wda/element/${elementId}/scroll`, 'POST', params);
281
+ const endpoint = elementId ? `/wda/element/${util.unwrapElement(elementId)}/scroll` : '/wda/scroll';
282
+ return await this.proxyCommand(endpoint, 'POST', params);
332
283
  },
333
284
  /**
334
285
  * @param {import('./types').Direction} direction
@@ -346,8 +297,8 @@ const helpers = {
346
297
  if (!_.isNil(velocity)) {
347
298
  params.velocity = velocity;
348
299
  }
349
- elementId = await toElementOrApplicationId(this, elementId);
350
- return await this.proxyCommand(`/wda/element/${elementId}/swipe`, 'POST', params);
300
+ const endpoint = elementId ? `/wda/element/${util.unwrapElement(elementId)}/swipe` : '/wda/swipe';
301
+ await this.proxyCommand(endpoint, 'POST', params);
351
302
  },
352
303
  /**
353
304
  * Performs a pinch gesture on the given element or on the Application element.
@@ -366,18 +317,18 @@ const helpers = {
366
317
  */
367
318
  async mobilePinch(scale, velocity, elementId) {
368
319
  const params = {
369
- scale: asFloat(scale, 'scale'),
370
- velocity: asFloat(velocity, 'velocity'),
320
+ scale: requireFloat(scale, 'scale'),
321
+ velocity: requireFloat(velocity, 'velocity'),
371
322
  };
372
- elementId = await toElementOrApplicationId(this, elementId);
373
- return await this.proxyCommand(`/wda/element/${elementId}/pinch`, 'POST', params);
323
+ const endpoint = elementId ? `/wda/element/${util.unwrapElement(elementId)}/pinch` : '/wda/pinch';
324
+ await this.proxyCommand(endpoint, 'POST', params);
374
325
  },
375
326
  /**
376
327
  * Performs double tap gesture on the given element or on the screen.
377
328
  *
378
- * @param {Element|string} [elementId] - The internal element identifier (as hexadecimal hash string) to double tap on. This is required if `x` and `y` are not provided.
379
- * @param {number} [x] - The _x_ coordinate (float value) to double tap on. This is required if `elementId` is not provided.
380
- * @param {number} [y] - The _y_ coordinate (float value) to double tap on. This is required if `elementId` is not provided.
329
+ * @param {Element|string} [elementId] - The internal element identifier (as hexadecimal hash string) to double tap on. The Application element will be used if this parameter is not provided.
330
+ * @param {number} [x] - The _x_ coordinate (float value) to double tap on.
331
+ * @param {number} [y] - The _y_ coordinate (float value) to double tap on.
381
332
  * @returns {Promise<void>}
382
333
  * @this {XCUITestDriver}
383
334
  * @example
@@ -387,16 +338,8 @@ const helpers = {
387
338
  * ```
388
339
  */
389
340
  async mobileDoubleTap(elementId, x, y) {
390
- if (elementId) {
391
- // Double tap element
392
- return await this.proxyCommand(`/wda/element/${elementId}/doubleTap`, 'POST');
393
- }
394
- // Double tap coordinates
395
- const params = {
396
- x: asFloat(x, 'x'),
397
- y: asFloat(y, 'y'),
398
- };
399
- return await this.proxyCommand('/wda/doubleTap', 'POST', params);
341
+ const endpoint = elementId ? `/wda/element/${util.unwrapElement(elementId)}/doubleTap` : '/wda/doubleTap';
342
+ await this.proxyCommand(endpoint, 'POST', {x, y});
400
343
  },
401
344
  /**
402
345
  * Performs two finger tap gesture on the given element or on the application element.
@@ -413,16 +356,16 @@ const helpers = {
413
356
  * ```
414
357
  */
415
358
  async mobileTwoFingerTap(elementId) {
416
- elementId = await toElementOrApplicationId(this, elementId);
417
- return await this.proxyCommand(`/wda/element/${elementId}/twoFingerTap`, 'POST');
359
+ const endpoint = elementId ? `/wda/element/${util.unwrapElement(elementId)}/twoFingerTap` : '/wda/twoFingerTap';
360
+ await this.proxyCommand(endpoint, 'POST');
418
361
  },
419
362
  /**
420
363
  * Performs a "long press" gesture on the given element or on the screen.
421
364
  *
422
365
  * @param {number} duration - The duration (in seconds) of the gesture.
423
- * @param {number} [y] - The _y_ coordinate (float value) to double tap on. This is required if `elementId` is not provided.
424
- * @param {number} [x] - The _x_ coordinate (float value) to double tap on. This is required if `elementId` is not provided.
425
- * @param {Element|string} [elementId] - The internal element identifier (as hexadecimal hash string) to double tap on. This is required if `x` and `y` are not provided.
366
+ * @param {number} [y] - The _y_ coordinate (float value) to hold on.
367
+ * @param {number} [x] - The _x_ coordinate (float value) to hold on.
368
+ * @param {Element|string} [elementId] - The internal element identifier (as hexadecimal hash string) to double tap on. The Application element will be used if this parameter is not provided.
426
369
  * @this {XCUITestDriver}
427
370
  * @see https://developer.apple.com/documentation/xctest/xcuielement/1618663-pressforduration?language=objc
428
371
  * @example
@@ -434,33 +377,24 @@ const helpers = {
434
377
  * ```
435
378
  */
436
379
  async mobileTouchAndHold(duration, x, y, elementId) {
437
- const params = {
438
- duration: asFloat(duration, 'duration'),
439
- };
440
- if (elementId) {
441
- // Long tap element
442
- return await this.proxyCommand(`/wda/element/${elementId}/touchAndHold`, 'POST', params);
443
- }
444
- // Long tap coordinates
445
- params.x = asFloat(x, 'x');
446
- params.y = asFloat(y, 'y');
447
- return await this.proxyCommand('/wda/touchAndHold', 'POST', params);
380
+ const endpoint = elementId ? `/wda/element/${util.unwrapElement(elementId)}/touchAndHold` : '/wda/touchAndHold';
381
+ await this.proxyCommand(endpoint, 'POST', {
382
+ duration: requireFloat(duration, 'duration'),
383
+ x, y,
384
+ });
448
385
  },
449
386
  /**
450
387
  * Performs tap gesture by coordinates on the given element or on the screen.
451
388
  *
452
389
  * @param {number} x - The _x_ coordinate (float value) to tap on. If `elementId` is provided, this is computed relative to the element; otherwise it is computed relative to the active Application element.
453
390
  * @param {number} y - The _y_ coordinate (float value) to tap on. If `elementId` is provided, this is computed relative to the element; otherwise it is computed relative to the active Application element.
454
- * @param {string|Element} [elementId] - The internal element identifier (as hexadecimal hash string) to tap on.
391
+ * @param {string|Element} [elementId] - The internal element identifier (as hexadecimal hash string) to tap on. The Application element will be used if this parameter is not provided.
455
392
  * @this {XCUITestDriver}
456
393
  * @returns {Promise<void>}
457
394
  */
458
- async mobileTap(x, y, elementId = '0') {
459
- const params = {
460
- x: asFloat(x, 'x'),
461
- y: asFloat(y, 'y'),
462
- };
463
- return await this.proxyCommand(`/wda/tap/${elementId}`, 'POST', params);
395
+ async mobileTap(x, y, elementId) {
396
+ const endpoint = elementId ? `/wda/element/${util.unwrapElement(elementId)}/tap` : '/wda/tap';
397
+ await this.proxyCommand(endpoint, 'POST', {x, y});
464
398
  },
465
399
  /**
466
400
  * Performs drag and drop gesture by coordinates on the given element or on the screen.
@@ -489,16 +423,15 @@ const helpers = {
489
423
  */
490
424
  async mobileDragFromToForDuration(duration, fromX, fromY, toX, toY, elementId) {
491
425
  const params = {
492
- duration: asFloat(duration, 'duration'),
493
- fromX: asFloat(fromX, 'fromX'),
494
- fromY: asFloat(fromY, 'fromY'),
495
- toX: asFloat(toX, 'toX'),
496
- toY: asFloat(toY, 'toY'),
426
+ duration: requireFloat(duration, 'duration'),
427
+ fromX: requireFloat(fromX, 'fromX'),
428
+ fromY: requireFloat(fromY, 'fromY'),
429
+ toX: requireFloat(toX, 'toX'),
430
+ toY: requireFloat(toY, 'toY'),
497
431
  };
498
- elementId = toElementId(elementId);
499
432
  return elementId
500
433
  ? // Drag element
501
- await this.proxyCommand(`/wda/element/${elementId}/dragfromtoforduration`, 'POST', params)
434
+ await this.proxyCommand(`/wda/element/${util.unwrapElement(elementId)}/dragfromtoforduration`, 'POST', params)
502
435
  : // Drag coordinates
503
436
  await this.proxyCommand('/wda/dragfromtoforduration', 'POST', params);
504
437
  },
@@ -531,9 +464,9 @@ const helpers = {
531
464
  toY,
532
465
  ) {
533
466
  const params = {
534
- pressDuration: asFloat(pressDuration, 'pressDuration'),
535
- holdDuration: asFloat(holdDuration, 'holdDuration'),
536
- velocity: asFloat(velocity, 'velocity'),
467
+ pressDuration: requireFloat(pressDuration, 'pressDuration'),
468
+ holdDuration: requireFloat(holdDuration, 'holdDuration'),
469
+ velocity: requireFloat(velocity, 'velocity'),
537
470
  };
538
471
  fromElementId = fromElementId ? util.unwrapElement(fromElementId) : undefined;
539
472
  if (fromElementId) {
@@ -550,19 +483,20 @@ const helpers = {
550
483
  params,
551
484
  );
552
485
  }
553
- params.fromX = asFloat(fromX, 'fromX');
554
- params.fromY = asFloat(fromY, 'fromY');
555
- params.toX = asFloat(toX, 'toX');
556
- params.toY = asFloat(toY, 'toY');
486
+ params.fromX = requireFloat(fromX, 'fromX');
487
+ params.fromY = requireFloat(fromY, 'fromY');
488
+ params.toX = requireFloat(toX, 'toX');
489
+ params.toY = requireFloat(toY, 'toY');
557
490
  return await this.proxyCommand('/wda/pressAndDragWithVelocity', 'POST', params);
558
491
  },
559
492
  /**
560
493
  * Sends one or more taps with one or more touch points.
561
494
  *
562
495
  * @since 1.17.1
563
- * @param {string|Element} elementId - The internal element identifier (as hexadecimal hash string) to perform one or more taps.
564
- * @param {number} numberOfTaps - Number of taps to perform.
565
- * @param {number} numberOfTouches - Number of touch points to use.
496
+ * @param {number} [numberOfTaps=1] - Number of taps to perform.
497
+ * @param {number} [numberOfTouches=1] - Number of touch points to use.
498
+ * @param {string|Element} [elementId] - The internal element identifier (as hexadecimal hash string) to perform one or more taps.
499
+ * The Application element will be used if this parameter is not provided.
566
500
  * @returns {Promise<void>}
567
501
  * @this {XCUITestDriver}
568
502
  * @see https://developer.apple.com/documentation/xctest/xcuielement/1618671-tapwithnumberoftaps?language=objc
@@ -573,17 +507,14 @@ const helpers = {
573
507
  * @driver.execute_script 'mobile: tapWithNumberOfTaps', {element: e.ref, numberOfTaps: 2, numberOfTouches: 1}
574
508
  * ```
575
509
  */
576
- async mobileTapWithNumberOfTaps(elementId, numberOfTouches, numberOfTaps) {
577
- if (!elementId) {
578
- throw new errors.InvalidArgumentError(
579
- 'Element id is expected to be set for tapWithNumberOfTaps method',
580
- );
581
- }
582
- const params = {
583
- numberOfTaps: asInt(numberOfTaps, 'numberOfTaps'),
584
- numberOfTouches: asInt(numberOfTouches, 'numberOfTouches'),
585
- };
586
- return await this.proxyCommand(`/wda/element/${elementId}/tapWithNumberOfTaps`, 'POST', params);
510
+ async mobileTapWithNumberOfTaps(numberOfTouches = 1, numberOfTaps = 1, elementId = undefined) {
511
+ const endpoint = elementId
512
+ ? `/wda/element/${util.unwrapElement(elementId)}/tapWithNumberOfTaps`
513
+ : '/wda/tapWithNumberOfTaps';
514
+ return await this.proxyCommand(endpoint, 'POST', {
515
+ numberOfTaps,
516
+ numberOfTouches,
517
+ });
587
518
  },
588
519
  /**
589
520
  * Performs a "force press" on the given element or coordinates.
@@ -593,13 +524,13 @@ const helpers = {
593
524
  * @param {number} [y] - The _y_ coordinate of the gesture. If `elementId` is set, this is calculated relative to its position; otherwise it's calculated relative to the active Application.
594
525
  * @param {number} [duration] - The duraiton (in seconds) of the force press. If this is provided, `pressure` must also be provided.
595
526
  * @param {number} [pressure] - A float value defining the pressure of the force press. If this is provided, `duration` must also be provided.
596
- * @param {string|Element} [elementId] - The internal element identifier (as hexadecimal hash string) to perform one or more taps. If this is _not_ provided, both `x` and `y` must be provided. If this is provided _and_ `x` and `y` are not provided, the actual touch point will be calculated internally.
527
+ * @param {string|Element} [elementId] - The internal element identifier (as hexadecimal hash string) to perform one or more taps.
528
+ * The Application element will be used if this parameter is not provided.
597
529
  * @returns {Promise<void>}
598
530
  * @this {XCUITestDriver}
599
531
  */
600
532
  async mobileForcePress(x, y, duration, pressure, elementId) {
601
- elementId = toElementId(elementId);
602
- const endpoint = elementId ? `/wda/element/${elementId}/forceTouch` : `/wda/forceTouch`;
533
+ const endpoint = elementId ? `/wda/element/${util.unwrapElement(elementId)}/forceTouch` : `/wda/forceTouch`;
603
534
  return await this.proxyCommand(endpoint, 'POST', {x, y, duration, pressure});
604
535
  },
605
536
  /**
@@ -625,7 +556,6 @@ const helpers = {
625
556
  * ```
626
557
  */
627
558
  async mobileSelectPickerWheelValue(elementId, order, offset, value, maxAttempts) {
628
- elementId = /** @type {string} */ (toElementId(elementId));
629
559
  if (!elementId) {
630
560
  throw new errors.InvalidArgumentError(
631
561
  'elementId is expected to be set for selectPickerWheelValue method',
@@ -639,7 +569,7 @@ const helpers = {
639
569
  }
640
570
  const params = {order};
641
571
  if (offset) {
642
- params.offset = asFloat(offset, 'offset');
572
+ params.offset = requireFloat(offset, 'offset');
643
573
  }
644
574
  if (!_.isNil(value)) {
645
575
  params.value = value;
@@ -647,15 +577,16 @@ const helpers = {
647
577
  if (!_.isNil(maxAttempts)) {
648
578
  params.maxAttempts = maxAttempts;
649
579
  }
650
- return await this.proxyCommand(`/wda/pickerwheel/${elementId}/select`, 'POST', params);
580
+ return await this.proxyCommand(`/wda/pickerwheel/${util.unwrapElement(elementId)}/select`, 'POST', params);
651
581
  },
652
582
  /**
653
583
  * Performs a rotate gesture on the given element.
654
584
  *
655
585
  * @see https://developer.apple.com/documentation/xctest/xcuielement/1618665-rotate?language=objc
656
- * @param {string|Element} elementId - The internal element identifier (as hexadecimal hash string) to perform the gesture on.
657
586
  * @param {number} rotation - The rotation gesture (in radians)
658
587
  * @param {number} velocity - The velocity (in radians-per-second) of the gesture.
588
+ * @param {string|Element} [elementId] - The internal element identifier (as hexadecimal hash string) to perform the gesture on.
589
+ * The Application element will be used if this parameter is not provided.
659
590
  * @returns {Promise<void>}
660
591
  * @this {XCUITestDriver}
661
592
  * @example
@@ -670,65 +601,13 @@ const helpers = {
670
601
  * ));
671
602
  * ```
672
603
  */
673
- async mobileRotateElement(elementId, rotation, velocity) {
674
- elementId = /** @type {string} */ (toElementId(elementId));
675
- if (!elementId) {
676
- throw new errors.InvalidArgumentError(
677
- 'Element id is expected to be set for rotateElement method',
678
- );
679
- }
604
+ async mobileRotateElement(rotation, velocity, elementId) {
680
605
  const params = {
681
- rotation: asFloat(rotation, 'rotation'),
682
- velocity: asFloat(velocity, 'velocity'),
606
+ rotation: requireFloat(rotation, 'rotation'),
607
+ velocity: requireFloat(velocity, 'velocity'),
683
608
  };
684
- return await this.proxyCommand(`/wda/element/${elementId}/rotate`, 'POST', params);
685
- },
686
- /**
687
- * @this {XCUITestDriver}
688
- */
689
- async getCoordinates(gesture) {
690
- // defaults
691
- let coordinates = {x: 0, y: 0, areOffsets: false};
692
-
693
- let optionX = null;
694
- if (gesture.options.x) {
695
- optionX = asFloat(gesture.options.x, 'x');
696
- }
697
- let optionY = null;
698
- if (gesture.options.y) {
699
- optionY = asFloat(gesture.options.y, 'y');
700
- }
701
-
702
- // figure out the element coordinates.
703
- const elementId = toElementId(gesture.options);
704
- if (elementId) {
705
- let rect = await this.getElementRect(elementId);
706
- let pos = {x: rect.x, y: rect.y};
707
- let size = {w: rect.width, h: rect.height};
708
-
709
- // defaults
710
- let offsetX = 0;
711
- let offsetY = 0;
712
-
713
- // get the real offsets
714
- if (optionX || optionY) {
715
- offsetX = optionX || 0;
716
- offsetY = optionY || 0;
717
- } else {
718
- offsetX = size.w / 2;
719
- offsetY = size.h / 2;
720
- }
721
-
722
- // apply the offsets
723
- coordinates.x = pos.x + offsetX;
724
- coordinates.y = pos.y + offsetY;
725
- } else {
726
- // moveTo coordinates are passed in as offsets
727
- coordinates.areOffsets = gesture.action === 'moveTo';
728
- coordinates.x = optionX || 0;
729
- coordinates.y = optionY || 0;
730
- }
731
- return coordinates;
609
+ const endpoint = elementId ? `/wda/element/${util.unwrapElement(elementId)}/rotate` : '/wda/rotate';
610
+ return await this.proxyCommand(endpoint, 'POST', params);
732
611
  },
733
612
  };
734
613
 
package/lib/devicectl.js CHANGED
@@ -122,7 +122,7 @@ export class Devicectl {
122
122
  /**
123
123
  * Simulates memory warning for the process with the given PID
124
124
  *
125
- * @param {number} pid
125
+ * @param {number|string} pid The process identifier to simulate the Low Memory warning for
126
126
  * @return {Promise<void>}
127
127
  */
128
128
  async sendMemoryWarning(pid) {
@@ -141,6 +141,19 @@ export class Devicectl {
141
141
  return JSON.parse(stdout).result.runningProcesses;
142
142
  }
143
143
 
144
+ /**
145
+ * Send POSIX signal to the running process
146
+ *
147
+ * @param {number|string} pid The process identifier to send a signal to
148
+ * @param {number|string} signal The signal to send to a process. See 'man signal' for a list of signals
149
+ * @returns {Promise<void>}
150
+ */
151
+ async sendSignalToProcess(pid, signal) {
152
+ await this.execute(['device', 'process', 'signal'], {
153
+ subcommandOptions: ['--signal', `${signal}`, '--pid', `${pid}`]
154
+ });
155
+ }
156
+
144
157
  /**
145
158
  * Retrieves the list of installed apps from the device
146
159
  *
package/lib/driver.js CHANGED
@@ -2018,7 +2018,6 @@ class XCUITestDriver extends BaseDriver {
2018
2018
  mobileForcePress = commands.gestureExtensions.mobileForcePress;
2019
2019
  mobileSelectPickerWheelValue = commands.gestureExtensions.mobileSelectPickerWheelValue;
2020
2020
  mobileRotateElement = commands.gestureExtensions.mobileRotateElement;
2021
- getCoordinates = commands.gestureExtensions.getCoordinates;
2022
2021
 
2023
2022
  /*-------+
2024
2023
  | IOHID |
@@ -61,7 +61,7 @@ export const executeMethodMap = {
61
61
  'mobile: tapWithNumberOfTaps': {
62
62
  command: 'mobileTapWithNumberOfTaps',
63
63
  params: {
64
- required: ['elementId', 'numberOfTouches', 'numberOfTaps'],
64
+ optional: ['numberOfTouches', 'numberOfTaps', 'elementId'],
65
65
  },
66
66
  },
67
67
  // https://developer.apple.com/documentation/xctest/xcuielement/1618663-pressforduration?language=objc
@@ -84,7 +84,8 @@ export const executeMethodMap = {
84
84
  'mobile: rotateElement': {
85
85
  command: 'mobileRotateElement',
86
86
  params: {
87
- required: ['elementId', 'rotation', 'velocity'],
87
+ required: ['rotation', 'velocity'],
88
+ optional: ['elementId'],
88
89
  },
89
90
  },
90
91
  // https://developer.apple.com/documentation/xctest/xcuicoordinate/3551692-pressforduration?language=objc
package/lib/ios-deploy.js CHANGED
@@ -7,7 +7,7 @@ import _ from 'lodash';
7
7
  import {exec} from 'teen_process';
8
8
  import {extractBundleId} from './app-utils';
9
9
  import {pushFolder} from './ios-fs-helpers';
10
- import { requireXcrun } from './xcrun';
10
+ import { Devicectl } from './devicectl';
11
11
 
12
12
  const APPLICATION_INSTALLED_NOTIFICATION = 'com.apple.mobile.application_installed';
13
13
  const INSTALLATION_STAGING_DIR = 'PublicStaging';
@@ -211,40 +211,15 @@ class IOSDeploy {
211
211
  if (util.compareVersions(platformVersion, '>=', '17.0')) {
212
212
  log.debug(`Calling devicectl to kill the process`);
213
213
 
214
- // FIXME: replace `devicectl` command with a wrapper later
215
- // or remove after implementing appium-ios-device for iOS 17+.
216
-
217
- const xcrunBinnaryPath = await requireXcrun();
218
- const {stdout} = await exec(xcrunBinnaryPath, [
219
- 'devicectl',
220
- 'device',
221
- 'info',
222
- 'processes',
223
- `--device`, this.udid
224
- ]);
225
- // Each line has spaces. devicectl has JSON output option, but it writes it to a file only.
226
- // Here parse the standard output directly.
227
- // e.g.:
228
- // 823 /private/var/containers/Bundle/Application/8E748312-8CBE-4C13-8295-C2EF3ED2C0C1/WebDriverAgentRunner-Runner.app/WebDriverAgentRunner-Runner
229
- // 824 /Applications/MobileSafari.app/MobileSafari
230
- // 825 /usr/libexec/debugserver
231
- const executableLine = stdout.split('\n').find((line) => line.trim().endsWith(executableName));
232
- if (!executableLine) {
214
+ const devicectl = new Devicectl(this.udid, log);
215
+ const pids = (await devicectl.listProcesses())
216
+ .filter(({executable}) => executable.endsWith(`/${executableName}`))
217
+ .map(({processIdentifier}) => processIdentifier);
218
+ if (_.isEmpty(pids)) {
233
219
  log.info(`The process of the bundle id '${bundleId}' was not running`);
234
220
  return false;
235
221
  }
236
- await exec(xcrunBinnaryPath, [
237
- 'devicectl',
238
- 'device',
239
- 'process',
240
- 'signal',
241
- '-s', `2`,
242
- // e.g.
243
- // '824 /Applications/MobileSafari.app/MobileSafari '
244
- // ' 999 /Applications/MobileSafari.app/MobileSafari ' (can include spaces in the top)
245
- '-p', `${executableLine.trim().split(/\s+/)[0]}`,
246
- `--device`, this.udid
247
- ]);
222
+ await devicectl.sendSignalToProcess(pids[0], 2);
248
223
  } else {
249
224
  instrumentService = await services.startInstrumentService(this.udid);
250
225
  const processes = await instrumentService.callChannel(