@limrun/appium-xcuitest-driver 10.11.0-lim.4 → 10.14.6-lim.1
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 +94 -0
- package/build/lib/commands/active-app-info.d.ts +4 -3
- package/build/lib/commands/active-app-info.d.ts.map +1 -1
- package/build/lib/commands/active-app-info.js +2 -3
- package/build/lib/commands/active-app-info.js.map +1 -1
- package/build/lib/commands/alert.d.ts +26 -31
- package/build/lib/commands/alert.d.ts.map +1 -1
- package/build/lib/commands/alert.js +20 -29
- package/build/lib/commands/alert.js.map +1 -1
- package/build/lib/commands/app-management.d.ts +99 -76
- package/build/lib/commands/app-management.d.ts.map +1 -1
- package/build/lib/commands/app-management.js +83 -73
- package/build/lib/commands/app-management.js.map +1 -1
- package/build/lib/commands/app-strings.d.ts +6 -7
- package/build/lib/commands/app-strings.d.ts.map +1 -1
- package/build/lib/commands/app-strings.js +3 -8
- package/build/lib/commands/app-strings.js.map +1 -1
- package/build/lib/commands/appearance.d.ts +7 -9
- package/build/lib/commands/appearance.d.ts.map +1 -1
- package/build/lib/commands/appearance.js +13 -19
- package/build/lib/commands/appearance.js.map +1 -1
- package/build/lib/commands/audit.d.ts +5 -33
- package/build/lib/commands/audit.d.ts.map +1 -1
- package/build/lib/commands/audit.js +3 -16
- package/build/lib/commands/audit.js.map +1 -1
- package/build/lib/commands/battery.d.ts +4 -4
- package/build/lib/commands/battery.d.ts.map +1 -1
- package/build/lib/commands/battery.js +3 -7
- package/build/lib/commands/battery.js.map +1 -1
- package/build/lib/commands/biometric.d.ts +12 -14
- package/build/lib/commands/biometric.d.ts.map +1 -1
- package/build/lib/commands/biometric.js +10 -19
- package/build/lib/commands/biometric.js.map +1 -1
- package/build/lib/commands/certificate.d.ts +14 -19
- package/build/lib/commands/certificate.d.ts.map +1 -1
- package/build/lib/commands/certificate.js +24 -31
- package/build/lib/commands/certificate.js.map +1 -1
- package/build/lib/commands/clipboard.d.ts +9 -11
- package/build/lib/commands/clipboard.d.ts.map +1 -1
- package/build/lib/commands/clipboard.js +8 -13
- package/build/lib/commands/clipboard.js.map +1 -1
- package/build/lib/commands/condition.d.ts +9 -72
- package/build/lib/commands/condition.d.ts.map +1 -1
- package/build/lib/commands/condition.js +5 -66
- package/build/lib/commands/condition.js.map +1 -1
- package/build/lib/commands/content-size.d.ts +16 -19
- package/build/lib/commands/content-size.d.ts.map +1 -1
- package/build/lib/commands/content-size.js +14 -22
- package/build/lib/commands/content-size.js.map +1 -1
- package/build/lib/commands/context.d.ts +130 -161
- package/build/lib/commands/context.d.ts.map +1 -1
- package/build/lib/commands/context.js +123 -108
- package/build/lib/commands/context.js.map +1 -1
- package/build/lib/commands/device-info.d.ts +13 -0
- package/build/lib/commands/device-info.d.ts.map +1 -0
- package/build/lib/commands/device-info.js +20 -0
- package/build/lib/commands/device-info.js.map +1 -0
- package/build/lib/commands/element.d.ts +83 -67
- package/build/lib/commands/element.d.ts.map +1 -1
- package/build/lib/commands/element.js +111 -134
- package/build/lib/commands/element.js.map +1 -1
- package/build/lib/commands/execute.d.ts +10 -22
- package/build/lib/commands/execute.d.ts.map +1 -1
- package/build/lib/commands/execute.js +13 -29
- package/build/lib/commands/execute.js.map +1 -1
- package/build/lib/commands/file-movement.d.ts +31 -42
- package/build/lib/commands/file-movement.d.ts.map +1 -1
- package/build/lib/commands/file-movement.js +146 -205
- package/build/lib/commands/file-movement.js.map +1 -1
- package/build/lib/commands/find.d.ts +20 -12
- package/build/lib/commands/find.d.ts.map +1 -1
- package/build/lib/commands/find.js +27 -65
- package/build/lib/commands/find.js.map +1 -1
- package/build/lib/commands/general.d.ts +84 -80
- package/build/lib/commands/general.d.ts.map +1 -1
- package/build/lib/commands/general.js +67 -54
- package/build/lib/commands/general.js.map +1 -1
- package/build/lib/commands/geolocation.d.ts +16 -36
- package/build/lib/commands/geolocation.d.ts.map +1 -1
- package/build/lib/commands/geolocation.js +8 -25
- package/build/lib/commands/geolocation.js.map +1 -1
- package/build/lib/commands/gesture.d.ts +103 -119
- package/build/lib/commands/gesture.d.ts.map +1 -1
- package/build/lib/commands/gesture.js +98 -138
- package/build/lib/commands/gesture.js.map +1 -1
- package/build/lib/commands/increase-contrast.d.ts +10 -13
- package/build/lib/commands/increase-contrast.d.ts.map +1 -1
- package/build/lib/commands/increase-contrast.js +8 -16
- package/build/lib/commands/increase-contrast.js.map +1 -1
- package/build/lib/commands/iohid.d.ts +6 -1359
- package/build/lib/commands/iohid.d.ts.map +1 -1
- package/build/lib/commands/iohid.js +5 -10
- package/build/lib/commands/iohid.js.map +1 -1
- package/build/lib/commands/keyboard.d.ts +16 -13
- package/build/lib/commands/keyboard.d.ts.map +1 -1
- package/build/lib/commands/keyboard.js +14 -18
- package/build/lib/commands/keyboard.js.map +1 -1
- package/build/lib/commands/keychains.d.ts +2 -2
- package/build/lib/commands/keychains.d.ts.map +1 -1
- package/build/lib/commands/keychains.js +1 -4
- package/build/lib/commands/keychains.js.map +1 -1
- package/build/lib/commands/localization.d.ts +7 -6
- package/build/lib/commands/localization.d.ts.map +1 -1
- package/build/lib/commands/localization.js +7 -8
- package/build/lib/commands/localization.js.map +1 -1
- package/build/lib/commands/location.d.ts +8 -11
- package/build/lib/commands/location.d.ts.map +1 -1
- package/build/lib/commands/location.js +7 -15
- package/build/lib/commands/location.js.map +1 -1
- package/build/lib/commands/lock.d.ts +6 -10
- package/build/lib/commands/lock.d.ts.map +1 -1
- package/build/lib/commands/lock.js +3 -10
- package/build/lib/commands/lock.js.map +1 -1
- package/build/lib/commands/log.d.ts +42 -44
- package/build/lib/commands/log.d.ts.map +1 -1
- package/build/lib/commands/log.js +32 -53
- package/build/lib/commands/log.js.map +1 -1
- package/build/lib/commands/memory.d.ts +4 -5
- package/build/lib/commands/memory.d.ts.map +1 -1
- package/build/lib/commands/memory.js +3 -8
- package/build/lib/commands/memory.js.map +1 -1
- package/build/lib/commands/navigation.d.ts +14 -26
- package/build/lib/commands/navigation.d.ts.map +1 -1
- package/build/lib/commands/navigation.js +22 -32
- package/build/lib/commands/navigation.js.map +1 -1
- package/build/lib/commands/notifications.d.ts +10 -10
- package/build/lib/commands/notifications.d.ts.map +1 -1
- package/build/lib/commands/notifications.js +8 -12
- package/build/lib/commands/notifications.js.map +1 -1
- package/build/lib/commands/pasteboard.d.ts +9 -10
- package/build/lib/commands/pasteboard.d.ts.map +1 -1
- package/build/lib/commands/pasteboard.js +8 -13
- package/build/lib/commands/pasteboard.js.map +1 -1
- package/build/lib/commands/pcap.d.ts +18 -38
- package/build/lib/commands/pcap.d.ts.map +1 -1
- package/build/lib/commands/pcap.js +9 -14
- package/build/lib/commands/pcap.js.map +1 -1
- package/build/lib/commands/performance.d.ts +36 -55
- package/build/lib/commands/performance.d.ts.map +1 -1
- package/build/lib/commands/performance.js +93 -86
- package/build/lib/commands/performance.js.map +1 -1
- package/build/lib/commands/permissions.d.ts +15 -17
- package/build/lib/commands/permissions.d.ts.map +1 -1
- package/build/lib/commands/permissions.js +12 -18
- package/build/lib/commands/permissions.js.map +1 -1
- package/build/lib/commands/proxy-helper.d.ts +11 -11
- package/build/lib/commands/proxy-helper.d.ts.map +1 -1
- package/build/lib/commands/proxy-helper.js +15 -24
- package/build/lib/commands/proxy-helper.js.map +1 -1
- package/build/lib/commands/record-audio.d.ts +25 -52
- package/build/lib/commands/record-audio.d.ts.map +1 -1
- package/build/lib/commands/record-audio.js +17 -19
- package/build/lib/commands/record-audio.js.map +1 -1
- package/build/lib/commands/recordscreen.d.ts +31 -62
- package/build/lib/commands/recordscreen.d.ts.map +1 -1
- package/build/lib/commands/recordscreen.js +29 -28
- package/build/lib/commands/recordscreen.js.map +1 -1
- package/build/lib/commands/screenshots.d.ts +15 -9
- package/build/lib/commands/screenshots.d.ts.map +1 -1
- package/build/lib/commands/screenshots.js +16 -16
- package/build/lib/commands/screenshots.js.map +1 -1
- package/build/lib/commands/simctl.d.ts +16 -22
- package/build/lib/commands/simctl.d.ts.map +1 -1
- package/build/lib/commands/simctl.js +13 -17
- package/build/lib/commands/simctl.js.map +1 -1
- package/build/lib/commands/source.d.ts +10 -8
- package/build/lib/commands/source.d.ts.map +1 -1
- package/build/lib/commands/source.js +11 -14
- package/build/lib/commands/source.js.map +1 -1
- package/build/lib/commands/timeouts.d.ts +25 -32
- package/build/lib/commands/timeouts.d.ts.map +1 -1
- package/build/lib/commands/timeouts.js +19 -15
- package/build/lib/commands/timeouts.js.map +1 -1
- package/build/lib/commands/types.d.ts +80 -0
- package/build/lib/commands/types.d.ts.map +1 -1
- package/build/lib/commands/web.d.ts +199 -202
- package/build/lib/commands/web.d.ts.map +1 -1
- package/build/lib/commands/web.js +216 -175
- package/build/lib/commands/web.js.map +1 -1
- package/build/lib/commands/xctest-record-screen.d.ts +17 -47
- package/build/lib/commands/xctest-record-screen.d.ts.map +1 -1
- package/build/lib/commands/xctest-record-screen.js +28 -59
- package/build/lib/commands/xctest-record-screen.js.map +1 -1
- package/build/lib/commands/xctest.d.ts +37 -37
- package/build/lib/commands/xctest.d.ts.map +1 -1
- package/build/lib/commands/xctest.js +38 -50
- package/build/lib/commands/xctest.js.map +1 -1
- package/build/lib/desired-caps.js +1 -1
- package/build/lib/device/log/ios-simulator-log.d.ts.map +1 -1
- package/build/lib/device/log/ios-simulator-log.js +2 -0
- package/build/lib/device/log/ios-simulator-log.js.map +1 -1
- package/build/lib/device/simulator-management.d.ts.map +1 -1
- package/build/lib/device/simulator-management.js +0 -2
- package/build/lib/device/simulator-management.js.map +1 -1
- package/build/lib/doctor/optional-checks.d.ts +0 -9
- package/build/lib/doctor/optional-checks.d.ts.map +1 -1
- package/build/lib/doctor/optional-checks.js +1 -30
- package/build/lib/doctor/optional-checks.js.map +1 -1
- package/build/lib/driver.d.ts +6 -5
- package/build/lib/driver.d.ts.map +1 -1
- package/build/lib/driver.js +16 -14
- 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 +0 -9
- package/build/lib/execute-method-map.js.map +1 -1
- package/lib/commands/active-app-info.ts +15 -0
- package/lib/commands/alert.ts +98 -0
- package/lib/commands/app-management.ts +414 -0
- package/lib/commands/{app-strings.js → app-strings.ts} +10 -9
- package/lib/commands/appearance.ts +70 -0
- package/lib/commands/audit.ts +25 -0
- package/lib/commands/{battery.js → battery.ts} +10 -12
- package/lib/commands/biometric.ts +52 -0
- package/lib/commands/{certificate.js → certificate.ts} +55 -50
- package/lib/commands/clipboard.ts +37 -0
- package/lib/commands/{condition.js → condition.ts} +21 -77
- package/lib/commands/content-size.ts +67 -0
- package/lib/commands/{context.js → context.ts} +174 -146
- package/lib/commands/device-info.ts +24 -0
- package/lib/commands/element.ts +419 -0
- package/lib/commands/{execute.js → execute.ts} +42 -38
- package/lib/commands/{file-movement.js → file-movement.ts} +212 -235
- package/lib/commands/find.ts +277 -0
- package/lib/commands/{general.js → general.ts} +102 -77
- package/lib/commands/geolocation.ts +55 -0
- package/lib/commands/{gesture.js → gesture.ts} +225 -183
- package/lib/commands/increase-contrast.ts +49 -0
- package/lib/commands/{iohid.js → iohid.ts} +15 -13
- package/lib/commands/keyboard.ts +70 -0
- package/lib/commands/keychains.ts +16 -0
- package/lib/commands/{localization.js → localization.ts} +22 -12
- package/lib/commands/{location.js → location.ts} +19 -22
- package/lib/commands/lock.ts +43 -0
- package/lib/commands/{log.js → log.ts} +68 -68
- package/lib/commands/{memory.js → memory.ts} +9 -9
- package/lib/commands/{navigation.js → navigation.ts} +42 -39
- package/lib/commands/{notifications.js → notifications.ts} +22 -14
- package/lib/commands/pasteboard.ts +44 -0
- package/lib/commands/{pcap.js → pcap.ts} +28 -28
- package/lib/commands/{performance.js → performance.ts} +133 -114
- package/lib/commands/permissions.ts +90 -0
- package/lib/commands/{proxy-helper.js → proxy-helper.ts} +26 -26
- package/lib/commands/{record-audio.js → record-audio.ts} +35 -33
- package/lib/commands/{recordscreen.js → recordscreen.ts} +78 -50
- package/lib/commands/{screenshots.js → screenshots.ts} +27 -21
- package/lib/commands/simctl.ts +82 -0
- package/lib/commands/{source.js → source.ts} +23 -20
- package/lib/commands/timeouts.ts +95 -0
- package/lib/commands/types.ts +86 -0
- package/lib/commands/{web.js → web.ts} +314 -264
- package/lib/commands/{xctest-record-screen.js → xctest-record-screen.ts} +54 -71
- package/lib/commands/{xctest.js → xctest.ts} +78 -71
- package/lib/desired-caps.ts +1 -1
- package/lib/device/log/ios-simulator-log.ts +2 -0
- package/lib/device/simulator-management.ts +0 -2
- package/lib/doctor/optional-checks.ts +0 -33
- package/lib/driver.ts +19 -17
- package/lib/execute-method-map.ts +0 -9
- package/package.json +6 -6
- package/lib/commands/active-app-info.js +0 -12
- package/lib/commands/alert.js +0 -88
- package/lib/commands/app-management.js +0 -346
- package/lib/commands/appearance.js +0 -71
- package/lib/commands/audit.js +0 -31
- package/lib/commands/biometric.js +0 -52
- package/lib/commands/clipboard.js +0 -35
- package/lib/commands/content-size.js +0 -68
- package/lib/commands/deviceInfo.js +0 -27
- package/lib/commands/element.js +0 -423
- package/lib/commands/find.js +0 -205
- package/lib/commands/geolocation.js +0 -56
- package/lib/commands/increase-contrast.js +0 -50
- package/lib/commands/keyboard.js +0 -62
- package/lib/commands/keychains.js +0 -17
- package/lib/commands/lock.js +0 -46
- package/lib/commands/pasteboard.js +0 -43
- package/lib/commands/permissions.js +0 -85
- package/lib/commands/simctl.js +0 -71
- package/lib/commands/timeouts.js +0 -68
|
@@ -2,6 +2,11 @@ import _ from 'lodash';
|
|
|
2
2
|
import {fs, util} from 'appium/support';
|
|
3
3
|
import {encodeBase64OrUpload} from '../utils';
|
|
4
4
|
import path from 'node:path';
|
|
5
|
+
import type {XCUITestDriver} from '../driver';
|
|
6
|
+
import type {Simulator} from 'appium-ios-simulator';
|
|
7
|
+
import type {RealDevice} from '../device/real-device-management';
|
|
8
|
+
import type {HTTPHeaders} from '@appium/types';
|
|
9
|
+
import type {XcTestScreenRecordingInfo, XcTestScreenRecording} from './types';
|
|
5
10
|
|
|
6
11
|
const MOV_EXT = '.mov';
|
|
7
12
|
const FEATURE_NAME = 'xctest_screen_record';
|
|
@@ -10,30 +15,9 @@ const DOMAIN_TYPE = 'appDataContainer';
|
|
|
10
15
|
const USERNAME = 'mobile';
|
|
11
16
|
const SUBDIRECTORY = 'Attachments';
|
|
12
17
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
* @property {number} fps FPS value
|
|
17
|
-
* @property {number} codec Video codec, where 0 is h264
|
|
18
|
-
* @property {number} startedAt The timestamp when the screen recording has started in float Unix seconds
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @typedef {Object} XcTestScreenRecordingType
|
|
23
|
-
* @property {string} payload Base64-encoded content of the recorded media
|
|
24
|
-
* file if `remotePath` parameter is empty or null or an empty string otherwise.
|
|
25
|
-
* The media is expected to a be a valid QuickTime movie (.mov).
|
|
26
|
-
* @typedef {XcTestScreenRecordingInfo & XcTestScreenRecordingType} XcTestScreenRecording
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @this {XCUITestDriver}
|
|
31
|
-
* @param {string} uuid Unique identifier of the video being recorded
|
|
32
|
-
* @returns {Promise<string>} The full path to the screen recording movie
|
|
33
|
-
*/
|
|
34
|
-
async function retrieveRecodingFromSimulator(uuid) {
|
|
35
|
-
const device = /** @type {import('appium-ios-simulator').Simulator} */ (this.device);
|
|
36
|
-
const dataRoot = /** @type {string} */ (device.getDir());
|
|
18
|
+
async function retrieveRecodingFromSimulator(this: XCUITestDriver, uuid: string): Promise<string> {
|
|
19
|
+
const device = this.device as Simulator;
|
|
20
|
+
const dataRoot = device.getDir();
|
|
37
21
|
// On Simulators the path looks like
|
|
38
22
|
// $HOME/Library/Developer/CoreSimulator/Devices/F8E1968A-8443-4A9A-AB86-27C54C36A2F6/data/Containers/Data/InternalDaemon/4E3FE8DF-AD0A-41DA-B6EC-C35E5798C219/Attachments/A044DAF7-4A58-4CD5-95C3-29B4FE80C377
|
|
39
23
|
const internalDaemonRoot = path.resolve(dataRoot, 'Containers', 'Data', 'InternalDaemon');
|
|
@@ -52,13 +36,8 @@ async function retrieveRecodingFromSimulator(uuid) {
|
|
|
52
36
|
return videoPath;
|
|
53
37
|
}
|
|
54
38
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
* @param {string} uuid Unique identifier of the video being recorded
|
|
58
|
-
* @returns {Promise<string>} The full path to the screen recording movie
|
|
59
|
-
*/
|
|
60
|
-
async function retrieveRecodingFromRealDevice(uuid) {
|
|
61
|
-
const device = /** @type {import('../device/real-device-management').RealDevice} */ (this.device);
|
|
39
|
+
async function retrieveRecodingFromRealDevice(this: XCUITestDriver, uuid: string): Promise<string> {
|
|
40
|
+
const device = this.device as RealDevice;
|
|
62
41
|
|
|
63
42
|
const fileNames = await device.devicectl.listFiles(DOMAIN_TYPE, DOMAIN_IDENTIFIER, {
|
|
64
43
|
username: USERNAME,
|
|
@@ -69,7 +48,10 @@ async function retrieveRecodingFromRealDevice(uuid) {
|
|
|
69
48
|
`Unable to locate XCTest screen recording identified by '${uuid}' for the device ${this.opts.udid}`
|
|
70
49
|
);
|
|
71
50
|
}
|
|
72
|
-
|
|
51
|
+
if (!this.opts.tmpDir) {
|
|
52
|
+
throw new Error('tmpDir is not set in driver options');
|
|
53
|
+
}
|
|
54
|
+
const videoPath = path.join(this.opts.tmpDir, `${uuid}${MOV_EXT}`);
|
|
73
55
|
await device.devicectl.pullFile(`${SUBDIRECTORY}/${uuid}`, videoPath, {
|
|
74
56
|
username: USERNAME,
|
|
75
57
|
domainIdentifier: DOMAIN_IDENTIFIER,
|
|
@@ -80,15 +62,10 @@ async function retrieveRecodingFromRealDevice(uuid) {
|
|
|
80
62
|
return videoPath;
|
|
81
63
|
}
|
|
82
64
|
|
|
83
|
-
|
|
84
|
-
* @this {XCUITestDriver}
|
|
85
|
-
* @param {string} uuid Unique identifier of the video being recorded
|
|
86
|
-
* @returns {Promise<string>} The full path to the screen recording movie
|
|
87
|
-
*/
|
|
88
|
-
async function retrieveXcTestScreenRecording(uuid) {
|
|
65
|
+
async function retrieveXcTestScreenRecording(this: XCUITestDriver, uuid: string): Promise<string> {
|
|
89
66
|
return this.isRealDevice()
|
|
90
|
-
? await retrieveRecodingFromRealDevice.
|
|
91
|
-
: await retrieveRecodingFromSimulator.
|
|
67
|
+
? await retrieveRecodingFromRealDevice.call(this, uuid)
|
|
68
|
+
: await retrieveRecodingFromSimulator.call(this, uuid);
|
|
92
69
|
}
|
|
93
70
|
|
|
94
71
|
/**
|
|
@@ -102,14 +79,16 @@ async function retrieveXcTestScreenRecording(uuid) {
|
|
|
102
79
|
* If the recording is already running this API is a noop.
|
|
103
80
|
*
|
|
104
81
|
* @since Xcode 15/iOS 17
|
|
105
|
-
* @param
|
|
106
|
-
* @param
|
|
107
|
-
* @returns
|
|
108
|
-
* about a newly created or a running the screen recording.
|
|
82
|
+
* @param fps - FPS value
|
|
83
|
+
* @param codec - Video codec, where 0 is h264, 1 is HEVC
|
|
84
|
+
* @returns The information about a newly created or a running the screen recording.
|
|
109
85
|
* @throws {Error} If screen recording has failed to start.
|
|
110
|
-
* @this {XCUITestDriver}
|
|
111
86
|
*/
|
|
112
|
-
export async function mobileStartXctestScreenRecording(
|
|
87
|
+
export async function mobileStartXctestScreenRecording(
|
|
88
|
+
this: XCUITestDriver,
|
|
89
|
+
fps?: number,
|
|
90
|
+
codec?: number,
|
|
91
|
+
): Promise<XcTestScreenRecordingInfo> {
|
|
113
92
|
if (this.isRealDevice()) {
|
|
114
93
|
// This feature might be used to abuse real devices as there is no
|
|
115
94
|
// reliable way (yet) to cleanup video recordings stored there
|
|
@@ -117,16 +96,14 @@ export async function mobileStartXctestScreenRecording(fps, codec) {
|
|
|
117
96
|
this.assertFeatureEnabled(FEATURE_NAME);
|
|
118
97
|
}
|
|
119
98
|
|
|
120
|
-
const opts = {};
|
|
99
|
+
const opts: {codec?: number; fps?: number} = {};
|
|
121
100
|
if (_.isInteger(codec)) {
|
|
122
101
|
opts.codec = codec;
|
|
123
102
|
}
|
|
124
103
|
if (_.isInteger(fps)) {
|
|
125
104
|
opts.fps = fps;
|
|
126
105
|
}
|
|
127
|
-
const response =
|
|
128
|
-
await this.proxyCommand('/wda/video/start', 'POST', opts)
|
|
129
|
-
);
|
|
106
|
+
const response = await this.proxyCommand('/wda/video/start', 'POST', opts) as XcTestScreenRecordingInfo;
|
|
130
107
|
this.log.info(`Started a new screen recording: ${JSON.stringify(response)}`);
|
|
131
108
|
return response;
|
|
132
109
|
}
|
|
@@ -134,13 +111,11 @@ export async function mobileStartXctestScreenRecording(fps, codec) {
|
|
|
134
111
|
/**
|
|
135
112
|
* Retrieves information about the current running screen recording.
|
|
136
113
|
* If no screen recording is running then `null` is returned.
|
|
137
|
-
*
|
|
138
|
-
* @returns {Promise<XcTestScreenRecordingInfo?>}
|
|
139
114
|
*/
|
|
140
|
-
export async function mobileGetXctestScreenRecordingInfo(
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
);
|
|
115
|
+
export async function mobileGetXctestScreenRecordingInfo(
|
|
116
|
+
this: XCUITestDriver,
|
|
117
|
+
): Promise<XcTestScreenRecordingInfo | null> {
|
|
118
|
+
return (await this.proxyCommand('/wda/video', 'GET')) as XcTestScreenRecordingInfo | null;
|
|
144
119
|
}
|
|
145
120
|
|
|
146
121
|
/**
|
|
@@ -157,29 +132,37 @@ export async function mobileGetXctestScreenRecordingInfo() {
|
|
|
157
132
|
* on the device directly or by doing factory reset.
|
|
158
133
|
*
|
|
159
134
|
* @since Xcode 15/iOS 17
|
|
160
|
-
* @param
|
|
135
|
+
* @param remotePath - The path to the remote location, where the resulting video should be
|
|
161
136
|
* uploaded.
|
|
162
137
|
* The following protocols are supported: `http`, `https`, `ftp`. Null or empty
|
|
163
138
|
* string value (the default setting) means the content of resulting file
|
|
164
139
|
* should be encoded as Base64 and passed as the endpoint response value. An
|
|
165
140
|
* exception will be thrown if the generated media file is too big to fit into
|
|
166
141
|
* the available process memory.
|
|
167
|
-
* @param
|
|
142
|
+
* @param user - The name of the user for the remote authentication.
|
|
168
143
|
* Only works if `remotePath` is provided.
|
|
169
|
-
* @param
|
|
144
|
+
* @param pass - The password for the remote authentication.
|
|
170
145
|
* Only works if `remotePath` is provided.
|
|
171
|
-
* @param
|
|
172
|
-
* @param
|
|
146
|
+
* @param headers - Additional headers mapping for multipart http(s) uploads
|
|
147
|
+
* @param fileFieldName - The name of the form field where the file content BLOB should be stored for
|
|
173
148
|
* http(s) uploads
|
|
174
|
-
* @param
|
|
175
|
-
* @param
|
|
149
|
+
* @param formFields - Additional form fields for multipart http(s) uploads
|
|
150
|
+
* @param method - The http multipart upload method name.
|
|
176
151
|
* Only works if `remotePath` is provided.
|
|
177
|
-
* @returns
|
|
152
|
+
* @returns The resulting movie with base64-encoded content or empty string if uploaded remotely.
|
|
178
153
|
* @throws {Error} If there was an error while retrieving the video
|
|
179
154
|
* file or the file content cannot be uploaded to the remote location.
|
|
180
|
-
* @this {XCUITestDriver}
|
|
181
155
|
*/
|
|
182
|
-
export async function mobileStopXctestScreenRecording(
|
|
156
|
+
export async function mobileStopXctestScreenRecording(
|
|
157
|
+
this: XCUITestDriver,
|
|
158
|
+
remotePath?: string,
|
|
159
|
+
user?: string,
|
|
160
|
+
pass?: string,
|
|
161
|
+
headers?: HTTPHeaders,
|
|
162
|
+
fileFieldName?: string,
|
|
163
|
+
formFields?: Record<string, any> | [string, any][],
|
|
164
|
+
method: 'PUT' | 'POST' | 'PATCH' = 'PUT',
|
|
165
|
+
): Promise<XcTestScreenRecording> {
|
|
183
166
|
const screenRecordingInfo = await this.mobileGetXctestScreenRecordingInfo();
|
|
184
167
|
if (!screenRecordingInfo) {
|
|
185
168
|
throw new Error('There is no active screen recording. Did you start one beforehand?');
|
|
@@ -187,8 +170,11 @@ export async function mobileStopXctestScreenRecording(remotePath, user, pass, he
|
|
|
187
170
|
|
|
188
171
|
this.log.debug(`Stopping the active screen recording: ${JSON.stringify(screenRecordingInfo)}`);
|
|
189
172
|
await this.proxyCommand('/wda/video/stop', 'POST', {});
|
|
190
|
-
const videoPath = await retrieveXcTestScreenRecording.
|
|
191
|
-
const result =
|
|
173
|
+
const videoPath = await retrieveXcTestScreenRecording.call(this, screenRecordingInfo.uuid);
|
|
174
|
+
const result: XcTestScreenRecording = {
|
|
175
|
+
...screenRecordingInfo,
|
|
176
|
+
payload: '', // Will be set below
|
|
177
|
+
};
|
|
192
178
|
try {
|
|
193
179
|
result.payload = await encodeBase64OrUpload(videoPath, remotePath, {
|
|
194
180
|
user, pass, headers, fileFieldName, formFields, method
|
|
@@ -199,6 +185,3 @@ export async function mobileStopXctestScreenRecording(remotePath, user, pass, he
|
|
|
199
185
|
return result;
|
|
200
186
|
}
|
|
201
187
|
|
|
202
|
-
/**
|
|
203
|
-
* @typedef {import('../driver').XCUITestDriver} XCUITestDriver
|
|
204
|
-
*/
|
|
@@ -2,34 +2,42 @@ import B from 'bluebird';
|
|
|
2
2
|
import {logger} from 'appium/support';
|
|
3
3
|
import _ from 'lodash';
|
|
4
4
|
import {errors} from 'appium/driver';
|
|
5
|
+
import type {XCUITestDriver} from '../driver';
|
|
6
|
+
import type {XCTestResult, RunXCTestResult} from './types';
|
|
7
|
+
import type {StringRecord} from '@appium/types';
|
|
8
|
+
import type IDB from 'appium-idb';
|
|
5
9
|
|
|
6
10
|
const XCTEST_TIMEOUT = 360000; // 60 minute timeout
|
|
7
11
|
|
|
8
12
|
const xctestLog = logger.getLogger('XCTest');
|
|
9
13
|
|
|
10
14
|
/**
|
|
11
|
-
* Asserts that IDB is present and that launchWithIDB was used
|
|
15
|
+
* Asserts that IDB is present and that launchWithIDB was used.
|
|
12
16
|
*
|
|
13
|
-
* @param
|
|
17
|
+
* @param opts - Opts object from the driver instance
|
|
18
|
+
* @returns The IDB instance
|
|
19
|
+
* @throws {Error} If IDB is not available or launchWithIDB is not enabled
|
|
14
20
|
*/
|
|
15
|
-
export function assertIDB(opts) {
|
|
16
|
-
|
|
21
|
+
export function assertIDB(this: XCUITestDriver, opts: XCUITestDriver['opts']): IDB {
|
|
22
|
+
const device = this.device as any;
|
|
23
|
+
if (!device?.idb || !opts.launchWithIDB) {
|
|
17
24
|
throw new Error(
|
|
18
25
|
`To use XCTest runner, IDB (https://github.com/facebook/idb) must be installed ` +
|
|
19
26
|
`and sessions must be run with the "launchWithIDB" capability`,
|
|
20
27
|
);
|
|
21
28
|
}
|
|
22
|
-
return
|
|
29
|
+
return device.idb;
|
|
23
30
|
}
|
|
24
31
|
|
|
25
32
|
/**
|
|
26
|
-
* Parse the stdout of XC test log
|
|
27
|
-
*
|
|
28
|
-
* @
|
|
33
|
+
* Parse the stdout of XC test log.
|
|
34
|
+
*
|
|
35
|
+
* @param stdout - A line of standard out from `idb xctest run ...`
|
|
36
|
+
* @returns The final output of the XCTest run
|
|
29
37
|
*/
|
|
30
|
-
export function parseXCTestStdout(stdout) {
|
|
38
|
+
export function parseXCTestStdout(stdout: string): XCTestResult[] | string[] {
|
|
31
39
|
// Parses a 'key' into JSON format
|
|
32
|
-
function parseKey(name) {
|
|
40
|
+
function parseKey(name: string): string {
|
|
33
41
|
const words = name.split(' ');
|
|
34
42
|
let out = '';
|
|
35
43
|
for (const word of words) {
|
|
@@ -39,7 +47,7 @@ export function parseXCTestStdout(stdout) {
|
|
|
39
47
|
}
|
|
40
48
|
|
|
41
49
|
// Parses a 'value' into JSON format
|
|
42
|
-
function parseValue(value) {
|
|
50
|
+
function parseValue(value: string): any {
|
|
43
51
|
value = value || '';
|
|
44
52
|
switch (value.toLowerCase()) {
|
|
45
53
|
case 'true':
|
|
@@ -51,7 +59,7 @@ export function parseXCTestStdout(stdout) {
|
|
|
51
59
|
default:
|
|
52
60
|
break;
|
|
53
61
|
}
|
|
54
|
-
if (!isNaN(value)) {
|
|
62
|
+
if (!isNaN(Number(value))) {
|
|
55
63
|
if (!_.isString(value)) {
|
|
56
64
|
return 0;
|
|
57
65
|
} else if (value.indexOf('.') > 0) {
|
|
@@ -73,16 +81,14 @@ export function parseXCTestStdout(stdout) {
|
|
|
73
81
|
return [lines[0]];
|
|
74
82
|
}
|
|
75
83
|
|
|
76
|
-
|
|
77
|
-
const results = [];
|
|
84
|
+
const results: XCTestResult[] = [];
|
|
78
85
|
for (const line of lines) {
|
|
79
86
|
// The properties are split up by pipes and each property
|
|
80
87
|
// has the format "Some Key : Some Value"
|
|
81
88
|
const properties = line.split('|');
|
|
82
89
|
|
|
83
90
|
// Parse each property
|
|
84
|
-
|
|
85
|
-
const output = /** @type {any} */ ({});
|
|
91
|
+
const output: any = {};
|
|
86
92
|
let entryIndex = 0;
|
|
87
93
|
for (const prop of properties) {
|
|
88
94
|
if (entryIndex === 0) {
|
|
@@ -94,7 +100,7 @@ export function parseXCTestStdout(stdout) {
|
|
|
94
100
|
// e.g. Location /path/to/XCTesterAppUITests/XCTesterAppUITests.swift:36
|
|
95
101
|
output.location = prop.substring(prop.indexOf('Location') + 8).trim();
|
|
96
102
|
} else {
|
|
97
|
-
|
|
103
|
+
const [key, value] = prop.split(':');
|
|
98
104
|
output[parseKey(key.trim())] = parseValue(value ? value.trim() : '');
|
|
99
105
|
}
|
|
100
106
|
entryIndex++;
|
|
@@ -123,12 +129,13 @@ export function parseXCTestStdout(stdout) {
|
|
|
123
129
|
}
|
|
124
130
|
|
|
125
131
|
/**
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
* @property {number} code Subprocess exit code
|
|
129
|
-
* @property {string} signal The signal (SIG*) that caused the process to fail
|
|
130
|
-
* @property {XCTestResult[]} results The output of the failed test (if there is output)
|
|
132
|
+
* Error thrown when XCTest subprocess returns non-zero exit code.
|
|
131
133
|
*/
|
|
134
|
+
export interface XCUITestError extends Error {
|
|
135
|
+
code: number;
|
|
136
|
+
signal?: string;
|
|
137
|
+
result?: XCTestResult[];
|
|
138
|
+
}
|
|
132
139
|
|
|
133
140
|
/**
|
|
134
141
|
* Run a native XCTest script.
|
|
@@ -137,36 +144,36 @@ export function parseXCTestStdout(stdout) {
|
|
|
137
144
|
*
|
|
138
145
|
* **Facebook's [IDB](https://github.com/facebook/idb) tool is required** to run such tests; see [the idb docs](https://fbidb.io/docs/test-execution/) for reference.
|
|
139
146
|
*
|
|
140
|
-
* @param
|
|
141
|
-
* @param
|
|
142
|
-
* @param
|
|
143
|
-
* @param
|
|
144
|
-
* @param
|
|
145
|
-
* @param
|
|
146
|
-
* @param
|
|
147
|
+
* @param testRunnerBundleId - Test app bundle (e.g.: `io.appium.XCTesterAppUITests.xctrunner`)
|
|
148
|
+
* @param appUnderTestBundleId - App-under-test bundle
|
|
149
|
+
* @param xcTestBundleId - XCTest bundle ID
|
|
150
|
+
* @param args - Launch arguments to start the test with (see [reference documentation](https://developer.apple.com/documentation/xctest/xcuiapplication/1500477-launcharguments))
|
|
151
|
+
* @param testType - XC test type
|
|
152
|
+
* @param env - Environment variables passed to test
|
|
153
|
+
* @param timeout - Timeout (in ms) for session completion
|
|
154
|
+
* @returns The array of test results
|
|
147
155
|
* @throws {XCUITestError} Error thrown if subprocess returns non-zero exit code
|
|
148
|
-
* @returns {Promise<import('./types').RunXCTestResult>} The array of test results
|
|
149
|
-
* @this {XCUITestDriver}
|
|
150
156
|
*/
|
|
151
157
|
export async function mobileRunXCTest(
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
+
this: XCUITestDriver,
|
|
159
|
+
testRunnerBundleId: string,
|
|
160
|
+
appUnderTestBundleId: string,
|
|
161
|
+
xcTestBundleId: string,
|
|
162
|
+
args: string[] = [],
|
|
163
|
+
testType: 'app' | 'ui' | 'logic' = 'ui',
|
|
164
|
+
env?: StringRecord,
|
|
158
165
|
timeout = XCTEST_TIMEOUT,
|
|
159
|
-
) {
|
|
160
|
-
const subproc = await assertIDB(this.opts).runXCUITest(
|
|
166
|
+
): Promise<RunXCTestResult> {
|
|
167
|
+
const subproc = await assertIDB.call(this, this.opts).runXCUITest(
|
|
161
168
|
testRunnerBundleId,
|
|
162
169
|
appUnderTestBundleId,
|
|
163
170
|
xcTestBundleId,
|
|
164
171
|
{env, args, testType},
|
|
165
172
|
);
|
|
166
173
|
return await new B((resolve, reject) => {
|
|
167
|
-
let mostRecentLogObject = null;
|
|
168
|
-
let xctestTimeout;
|
|
169
|
-
let lastErrorMessage = null;
|
|
174
|
+
let mostRecentLogObject: XCTestResult[] | string[] | null = null;
|
|
175
|
+
let xctestTimeout: NodeJS.Timeout | undefined;
|
|
176
|
+
let lastErrorMessage: string | null = null;
|
|
170
177
|
if (timeout > 0) {
|
|
171
178
|
xctestTimeout = setTimeout(
|
|
172
179
|
() =>
|
|
@@ -179,11 +186,11 @@ export async function mobileRunXCTest(
|
|
|
179
186
|
);
|
|
180
187
|
}
|
|
181
188
|
|
|
182
|
-
subproc.on('output', (stdout, stderr) => {
|
|
189
|
+
subproc.on('output', (stdout: string, stderr: string) => {
|
|
183
190
|
if (stdout) {
|
|
184
191
|
try {
|
|
185
192
|
mostRecentLogObject = parseXCTestStdout(stdout);
|
|
186
|
-
} catch (err) {
|
|
193
|
+
} catch (err: any) {
|
|
187
194
|
// Fails if log parsing fails.
|
|
188
195
|
// This is in case IDB changes the way that logs are formatted and
|
|
189
196
|
// it breaks 'parseXCTestStdout'. If that happens we still want the process
|
|
@@ -202,23 +209,25 @@ export async function mobileRunXCTest(
|
|
|
202
209
|
}
|
|
203
210
|
});
|
|
204
211
|
|
|
205
|
-
subproc.on('exit', (code, signal) => {
|
|
206
|
-
|
|
212
|
+
subproc.on('exit', (code: number | null, signal: string | null) => {
|
|
213
|
+
if (xctestTimeout) {
|
|
214
|
+
clearTimeout(xctestTimeout);
|
|
215
|
+
}
|
|
207
216
|
if (code !== 0) {
|
|
208
|
-
const err =
|
|
209
|
-
err.code = code;
|
|
217
|
+
const err = new Error(lastErrorMessage || String(mostRecentLogObject)) as XCUITestError;
|
|
218
|
+
err.code = code ?? -1;
|
|
210
219
|
if (signal != null) {
|
|
211
220
|
err.signal = signal;
|
|
212
221
|
}
|
|
213
222
|
if (mostRecentLogObject) {
|
|
214
|
-
err.result = mostRecentLogObject;
|
|
223
|
+
err.result = mostRecentLogObject as XCTestResult[];
|
|
215
224
|
}
|
|
216
225
|
return reject(err);
|
|
217
226
|
}
|
|
218
227
|
resolve({
|
|
219
|
-
code,
|
|
220
|
-
signal,
|
|
221
|
-
results: mostRecentLogObject,
|
|
228
|
+
code: code ?? 0,
|
|
229
|
+
signal: signal ?? null,
|
|
230
|
+
results: mostRecentLogObject as XCTestResult[],
|
|
222
231
|
passed: true,
|
|
223
232
|
});
|
|
224
233
|
});
|
|
@@ -230,11 +239,12 @@ export async function mobileRunXCTest(
|
|
|
230
239
|
*
|
|
231
240
|
* **Facebook's [IDB](https://github.com/facebook/idb) tool is required** for this command to work.
|
|
232
241
|
*
|
|
233
|
-
* @param
|
|
234
|
-
* @returns {Promise<void>}
|
|
235
|
-
* @this {XCUITestDriver}
|
|
242
|
+
* @param xctestApp - Path of the XCTest app (URL or filename with extension `.app`)
|
|
236
243
|
*/
|
|
237
|
-
export async function mobileInstallXCTestBundle(
|
|
244
|
+
export async function mobileInstallXCTestBundle(
|
|
245
|
+
this: XCUITestDriver,
|
|
246
|
+
xctestApp: string,
|
|
247
|
+
): Promise<void> {
|
|
238
248
|
if (!_.isString(xctestApp)) {
|
|
239
249
|
throw new errors.InvalidArgumentError(
|
|
240
250
|
`'xctestApp' is a required parameter for 'installXCTestBundle' and ` +
|
|
@@ -242,7 +252,7 @@ export async function mobileInstallXCTestBundle(xctestApp) {
|
|
|
242
252
|
);
|
|
243
253
|
}
|
|
244
254
|
xctestLog.info(`Installing bundle '${xctestApp}'`);
|
|
245
|
-
const idb = assertIDB(this.opts);
|
|
255
|
+
const idb = assertIDB.call(this, this.opts);
|
|
246
256
|
const res = await this.helpers.configureApp(xctestApp, '.xctest');
|
|
247
257
|
await idb.installXCTestBundle(res);
|
|
248
258
|
}
|
|
@@ -252,34 +262,31 @@ export async function mobileInstallXCTestBundle(xctestApp) {
|
|
|
252
262
|
*
|
|
253
263
|
* **Facebook's [IDB](https://github.com/facebook/idb) tool is required** for this command to work.
|
|
254
264
|
*
|
|
255
|
-
* @returns
|
|
256
|
-
* @this {XCUITestDriver}
|
|
265
|
+
* @returns List of XCTest bundles (e.g.: `XCTesterAppUITests.XCTesterAppUITests/testLaunchPerformance`)
|
|
257
266
|
*/
|
|
258
|
-
export async function mobileListXCTestBundles() {
|
|
259
|
-
return await assertIDB(this.opts).listXCTestBundles();
|
|
267
|
+
export async function mobileListXCTestBundles(this: XCUITestDriver): Promise<string[]> {
|
|
268
|
+
return await assertIDB.call(this, this.opts).listXCTestBundles();
|
|
260
269
|
}
|
|
261
270
|
|
|
262
271
|
/**
|
|
263
|
-
* List XCTests in a test bundle
|
|
272
|
+
* List XCTests in a test bundle.
|
|
264
273
|
*
|
|
265
274
|
* **Facebook's [IDB](https://github.com/facebook/idb) tool is required** for this command to work.
|
|
266
|
-
* @param {string} bundle - Bundle ID of the XCTest
|
|
267
275
|
*
|
|
268
|
-
* @
|
|
269
|
-
* @
|
|
276
|
+
* @param bundle - Bundle ID of the XCTest
|
|
277
|
+
* @returns The list of xctests in the test bundle (e.g., `['XCTesterAppUITests.XCTesterAppUITests/testExample', 'XCTesterAppUITests.XCTesterAppUITests/testLaunchPerformance']`)
|
|
270
278
|
*/
|
|
271
|
-
export async function mobileListXCTestsInTestBundle(
|
|
279
|
+
export async function mobileListXCTestsInTestBundle(
|
|
280
|
+
this: XCUITestDriver,
|
|
281
|
+
bundle: string,
|
|
282
|
+
): Promise<string[]> {
|
|
272
283
|
if (!_.isString(bundle)) {
|
|
273
284
|
throw new errors.InvalidArgumentError(
|
|
274
285
|
`'bundle' is a required parameter for 'listXCTestsInTestBundle' and ` +
|
|
275
286
|
`must be a string. Found '${bundle}'`,
|
|
276
287
|
);
|
|
277
288
|
}
|
|
278
|
-
const idb = assertIDB(this.opts);
|
|
289
|
+
const idb = assertIDB.call(this, this.opts);
|
|
279
290
|
return await idb.listXCTestsInTestBundle(bundle);
|
|
280
291
|
}
|
|
281
292
|
|
|
282
|
-
/**
|
|
283
|
-
* @typedef {import('../driver').XCUITestDriver} XCUITestDriver
|
|
284
|
-
* @typedef {import('./types').XCTestResult} XCTestResult
|
|
285
|
-
*/
|
package/lib/desired-caps.ts
CHANGED
|
@@ -408,7 +408,7 @@ export const desiredCapConstraints = {
|
|
|
408
408
|
// Useful when WDA is behind a gateway that requires authentication headers
|
|
409
409
|
wdaRequestHeaders: {
|
|
410
410
|
isObject: true,
|
|
411
|
-
}
|
|
411
|
+
},
|
|
412
412
|
} as const satisfies Constraints;
|
|
413
413
|
|
|
414
414
|
export type XCUITestDriverConstraints = typeof desiredCapConstraints;
|
|
@@ -172,6 +172,8 @@ export class IOSSimulatorLog extends LineConsumingLog {
|
|
|
172
172
|
this.onOutput(line, ...(streamName === 'stderr' ? ['STDERR'] : []));
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
|
+
// We immediately start anyway so this is commented out.
|
|
176
|
+
//
|
|
175
177
|
// const startDetector = (stdout: string, stderr: string) => {
|
|
176
178
|
// if (EXECVP_ERROR_PATTERN.test(stderr)) {
|
|
177
179
|
// throw new Error('iOS log capture process failed to start');
|
|
@@ -49,7 +49,6 @@ export async function createSim(this: XCUITestDriver): Promise<Simulator> {
|
|
|
49
49
|
devicesSetPath,
|
|
50
50
|
// @ts-ignore This is ok
|
|
51
51
|
logger: this.log,
|
|
52
|
-
limClient: this.limClient,
|
|
53
52
|
});
|
|
54
53
|
}
|
|
55
54
|
|
|
@@ -75,7 +74,6 @@ export async function getExistingSim(this: XCUITestDriver): Promise<Simulator |
|
|
|
75
74
|
devicesSetPath,
|
|
76
75
|
// @ts-ignore This is ok
|
|
77
76
|
logger: this.log,
|
|
78
|
-
limClient: this.limClient,
|
|
79
77
|
});
|
|
80
78
|
|
|
81
79
|
const simctl = new Simctl({devicesSetPath, limClient: this.limClient});
|
|
@@ -4,39 +4,6 @@ import type {IDoctorCheck, AppiumLogger, DoctorCheckResult} from '@appium/types'
|
|
|
4
4
|
import '@colors/colors';
|
|
5
5
|
import {exec} from 'teen_process';
|
|
6
6
|
|
|
7
|
-
export class OptionalIdbCommandCheck implements IDoctorCheck {
|
|
8
|
-
log!: AppiumLogger;
|
|
9
|
-
static readonly IDB_README_URL = 'https://git.io/JnxQc';
|
|
10
|
-
|
|
11
|
-
async diagnose(): Promise<DoctorCheckResult> {
|
|
12
|
-
const fbIdbPath = await resolveExecutablePath('idb');
|
|
13
|
-
const fbCompanionIdbPath = await resolveExecutablePath('idb_companion');
|
|
14
|
-
if (fbIdbPath && fbCompanionIdbPath) {
|
|
15
|
-
return doctor.okOptional('idb and idb_companion are installed');
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (!fbIdbPath && fbCompanionIdbPath) {
|
|
19
|
-
return doctor.nokOptional('idb is not installed');
|
|
20
|
-
} else if (fbIdbPath && !fbCompanionIdbPath) {
|
|
21
|
-
return doctor.nokOptional('idb_companion is not installed');
|
|
22
|
-
}
|
|
23
|
-
return doctor.nokOptional('idb and idb_companion are not installed');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
async fix(): Promise<string> {
|
|
27
|
-
return `Why ${'idb'.bold} is needed and how to install it: ${OptionalIdbCommandCheck.IDB_README_URL}`;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
hasAutofix(): boolean {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
isOptional(): boolean {
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
export const optionalIdbCheck = new OptionalIdbCommandCheck();
|
|
39
|
-
|
|
40
7
|
export class OptionalSimulatorCheck implements IDoctorCheck {
|
|
41
8
|
log!: AppiumLogger;
|
|
42
9
|
static readonly SUPPORTED_SIMULATOR_PLATFORMS: SimulatorPlatform[] = [
|