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
package/lib/commands/general.js
CHANGED
|
@@ -6,26 +6,25 @@ import {exec} from 'teen_process';
|
|
|
6
6
|
|
|
7
7
|
const MOMENT_FORMAT_ISO8601 = 'YYYY-MM-DDTHH:mm:ssZ';
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
},
|
|
9
|
+
/**
|
|
10
|
+
* @this {XCUITestDriver}
|
|
11
|
+
*/
|
|
12
|
+
export async function active() {
|
|
13
|
+
if (this.isWebContext()) {
|
|
14
|
+
return this.cacheWebElements(await this.executeAtom('active_element', []));
|
|
15
|
+
}
|
|
16
|
+
return await this.proxyCommand(`/element/active`, 'GET');
|
|
17
|
+
}
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Trigger a touch/fingerprint match or match failure
|
|
21
|
+
*
|
|
22
|
+
* @param {boolean} match - whether the match should be a success or failure
|
|
23
|
+
* @this {XCUITestDriver}
|
|
24
|
+
*/
|
|
25
|
+
export async function touchId(match = true) {
|
|
26
|
+
await this.mobileSendBiometricMatch('touchId', match);
|
|
27
|
+
}
|
|
29
28
|
/**
|
|
30
29
|
* Toggle whether the device is enrolled in the touch ID program
|
|
31
30
|
*
|
|
@@ -33,231 +32,239 @@ const commands = {
|
|
|
33
32
|
*
|
|
34
33
|
* @this {XCUITestDriver}
|
|
35
34
|
*/
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Get the window size
|
|
41
|
-
* @this {XCUITestDriver}
|
|
42
|
-
* @returns {Promise<import('@appium/types').Size>}
|
|
43
|
-
*/
|
|
44
|
-
async getWindowSize() {
|
|
45
|
-
const {width, height} = await this.getWindowRect();
|
|
46
|
-
return {width, height};
|
|
47
|
-
},
|
|
48
|
-
/**
|
|
49
|
-
* Retrieves the actual device time.
|
|
50
|
-
*
|
|
51
|
-
* @param {string} format - The format specifier string. Read the [MomentJS documentation](https://momentjs.com/docs/) to get the full list of supported datetime format specifiers. The default format is `YYYY-MM-DDTHH:mm:ssZ`, which complies to ISO-8601.
|
|
52
|
-
* @returns {Promise<string>} Formatted datetime string or the raw command output (if formatting fails)
|
|
53
|
-
* @this {XCUITestDriver}
|
|
54
|
-
*/
|
|
55
|
-
async getDeviceTime(format = MOMENT_FORMAT_ISO8601) {
|
|
56
|
-
this.log.info('Attempting to capture iOS device date and time');
|
|
57
|
-
if (!this.isRealDevice()) {
|
|
58
|
-
this.log.info('On simulator. Assuming device time is the same as host time');
|
|
59
|
-
const cmd = 'date';
|
|
60
|
-
const args = ['+%Y-%m-%dT%H:%M:%S%z'];
|
|
61
|
-
const inputFormat = 'YYYY-MM-DDTHH:mm:ssZZ';
|
|
62
|
-
const stdout = (await exec(cmd, args)).stdout.trim();
|
|
63
|
-
this.log.debug(`Got the following output out of '${cmd} ${args.join(' ')}': ${stdout}`);
|
|
64
|
-
const parsedTimestamp = moment.utc(stdout, inputFormat);
|
|
65
|
-
if (!parsedTimestamp.isValid()) {
|
|
66
|
-
this.log.warn(
|
|
67
|
-
`Cannot parse the timestamp '${stdout}' returned by '${cmd}' command. Returning it as is`,
|
|
68
|
-
);
|
|
69
|
-
return stdout;
|
|
70
|
-
}
|
|
71
|
-
// @ts-expect-error This internal prop of moment is evidently a private API
|
|
72
|
-
return parsedTimestamp.utcOffset(parsedTimestamp._tzm || 0).format(format);
|
|
73
|
-
}
|
|
35
|
+
export async function toggleEnrollTouchId(isEnabled = true) {
|
|
36
|
+
await this.mobileEnrollBiometric(isEnabled);
|
|
37
|
+
}
|
|
74
38
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Get the window size
|
|
41
|
+
* @this {XCUITestDriver}
|
|
42
|
+
* @returns {Promise<import('@appium/types').Size>}
|
|
43
|
+
*/
|
|
44
|
+
export async function getWindowSize() {
|
|
45
|
+
const {width, height} = await this.getWindowRect();
|
|
46
|
+
return {width, height};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Retrieves the actual device time.
|
|
51
|
+
*
|
|
52
|
+
* @param {string} format - The format specifier string. Read the [MomentJS documentation](https://momentjs.com/docs/) to get the full list of supported datetime format specifiers. The default format is `YYYY-MM-DDTHH:mm:ssZ`, which complies to ISO-8601.
|
|
53
|
+
* @returns {Promise<string>} Formatted datetime string or the raw command output (if formatting fails)
|
|
54
|
+
* @this {XCUITestDriver}
|
|
55
|
+
*/
|
|
56
|
+
export async function getDeviceTime(format = MOMENT_FORMAT_ISO8601) {
|
|
57
|
+
this.log.info('Attempting to capture iOS device date and time');
|
|
58
|
+
if (!this.isRealDevice()) {
|
|
59
|
+
this.log.info('On simulator. Assuming device time is the same as host time');
|
|
60
|
+
const cmd = 'date';
|
|
61
|
+
const args = ['+%Y-%m-%dT%H:%M:%S%z'];
|
|
62
|
+
const inputFormat = 'YYYY-MM-DDTHH:mm:ssZZ';
|
|
63
|
+
const stdout = (await exec(cmd, args)).stdout.trim();
|
|
64
|
+
this.log.debug(`Got the following output out of '${cmd} ${args.join(' ')}': ${stdout}`);
|
|
65
|
+
const parsedTimestamp = moment.utc(stdout, inputFormat);
|
|
66
|
+
if (!parsedTimestamp.isValid()) {
|
|
67
|
+
this.log.warn(
|
|
68
|
+
`Cannot parse the timestamp '${stdout}' returned by '${cmd}' command. Returning it as is`,
|
|
69
|
+
);
|
|
70
|
+
return stdout;
|
|
90
71
|
}
|
|
91
|
-
|
|
92
|
-
return
|
|
93
|
-
}
|
|
72
|
+
// @ts-expect-error This internal prop of moment is evidently a private API
|
|
73
|
+
return parsedTimestamp.utcOffset(parsedTimestamp._tzm || 0).format(format);
|
|
74
|
+
}
|
|
94
75
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
76
|
+
const {timestamp, utcOffset, timeZone} = await utilities.getDeviceTime(this.opts.udid);
|
|
77
|
+
this.log.debug(`timestamp: ${timestamp}, utcOffset: ${utcOffset}, timeZone: ${timeZone}`);
|
|
78
|
+
const utc = moment.unix(timestamp).utc();
|
|
79
|
+
// at some point of time Apple started to return timestamps
|
|
80
|
+
// in utcOffset instead of actual UTC offsets
|
|
81
|
+
if (Math.abs(utcOffset) <= 12 * 60) {
|
|
82
|
+
return utc.utcOffset(utcOffset).format(format);
|
|
83
|
+
}
|
|
84
|
+
// timeZone could either be a time zone name or
|
|
85
|
+
// an UTC offset in seconds
|
|
86
|
+
if (_.includes(timeZone, '/')) {
|
|
87
|
+
return utc.tz(timeZone).format(format);
|
|
88
|
+
}
|
|
89
|
+
if (Math.abs(timeZone) <= 12 * 60 * 60) {
|
|
90
|
+
return utc.utcOffset(timeZone / 60).format(format);
|
|
91
|
+
}
|
|
92
|
+
this.log.warn('Did not know how to apply the UTC offset. Returning the timestamp without it');
|
|
93
|
+
return utc.format(format);
|
|
94
|
+
}
|
|
105
95
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
'width: window.innerWidth,' +
|
|
117
|
-
'height: window.innerHeight' +
|
|
118
|
-
'}';
|
|
119
|
-
return await this.executeAtom('execute_script', [script]);
|
|
120
|
-
}
|
|
96
|
+
/**
|
|
97
|
+
* Retrieves the current device time
|
|
98
|
+
*
|
|
99
|
+
* @param {string} format - See {@linkcode getDeviceTime.format}
|
|
100
|
+
* @returns {Promise<string>} Formatted datetime string or the raw command output if formatting fails
|
|
101
|
+
* @this {XCUITestDriver}
|
|
102
|
+
*/
|
|
103
|
+
export async function mobileGetDeviceTime(format = MOMENT_FORMAT_ISO8601) {
|
|
104
|
+
return await this.getDeviceTime(format);
|
|
105
|
+
}
|
|
121
106
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
`The launchApp API has been deprecated and is not supported anymore. ` +
|
|
138
|
-
`Consider using corresponding 'mobile:' extensions to manage the state of the app under test.`,
|
|
139
|
-
);
|
|
140
|
-
},
|
|
141
|
-
/**
|
|
142
|
-
* @this {XCUITestDriver}
|
|
143
|
-
*/
|
|
144
|
-
async closeApp() {
|
|
145
|
-
throw new Error(
|
|
146
|
-
`The closeApp API has been deprecated and is not supported anymore. ` +
|
|
147
|
-
`Consider using corresponding 'mobile:' extensions to manage the state of the app under test.`,
|
|
148
|
-
);
|
|
149
|
-
},
|
|
150
|
-
/**
|
|
151
|
-
* @this {XCUITestDriver}
|
|
152
|
-
*/
|
|
153
|
-
async setUrl(url) {
|
|
154
|
-
this.log.debug(`Attempting to set url '${url}'`);
|
|
107
|
+
/**
|
|
108
|
+
* For W3C
|
|
109
|
+
* @this {XCUITestDriver}
|
|
110
|
+
* @return {Promise<import('@appium/types').Rect>}
|
|
111
|
+
*/
|
|
112
|
+
export async function getWindowRect() {
|
|
113
|
+
if (this.isWebContext()) {
|
|
114
|
+
const script = 'return {' +
|
|
115
|
+
'x: window.screenX || 0,' +
|
|
116
|
+
'y: window.screenY || 0,' +
|
|
117
|
+
'width: window.innerWidth,' +
|
|
118
|
+
'height: window.innerHeight' +
|
|
119
|
+
'}';
|
|
120
|
+
return await this.executeAtom('execute_script', [script]);
|
|
121
|
+
}
|
|
155
122
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
await (/** @type {import('appium-remote-debugger').RemoteDebugger} */ (this.remote)).navToUrl(url);
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
123
|
+
return /** @type {import('@appium/types').Rect} */ (
|
|
124
|
+
await this.proxyCommand('/window/rect', 'GET')
|
|
125
|
+
);
|
|
126
|
+
}
|
|
163
127
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Retrieves the viewport dimensions.
|
|
172
|
-
*
|
|
173
|
-
* The viewport is the device's screen size with status bar size subtracted if the latter is present/visible.
|
|
174
|
-
* @returns {Promise<import('./types').Viewport>}
|
|
175
|
-
* @this {XCUITestDriver}
|
|
176
|
-
*/
|
|
177
|
-
async getViewportRect() {
|
|
178
|
-
const scale = await this.getDevicePixelRatio();
|
|
179
|
-
// status bar height comes in unscaled, so scale it
|
|
180
|
-
const statusBarHeight = Math.trunc((await this.getStatusBarHeight()) * scale);
|
|
181
|
-
const windowSize = await this.getWindowRect();
|
|
128
|
+
/**
|
|
129
|
+
* @this {XCUITestDriver}
|
|
130
|
+
*/
|
|
131
|
+
export async function removeApp(bundleId) {
|
|
132
|
+
return await this.mobileRemoveApp(bundleId);
|
|
133
|
+
}
|
|
182
134
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
135
|
+
/**
|
|
136
|
+
* @this {XCUITestDriver}
|
|
137
|
+
*/
|
|
138
|
+
export async function launchApp() {
|
|
139
|
+
throw new Error(
|
|
140
|
+
`The launchApp API has been deprecated and is not supported anymore. ` +
|
|
141
|
+
`Consider using corresponding 'mobile:' extensions to manage the state of the app under test.`,
|
|
142
|
+
);
|
|
143
|
+
}
|
|
192
144
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
},
|
|
203
|
-
/**
|
|
204
|
-
* @this {XCUITestDriver}
|
|
205
|
-
*/
|
|
206
|
-
async getStatusBarHeight() {
|
|
207
|
-
const {statusBarSize} = await this.getScreenInfo();
|
|
208
|
-
return statusBarSize.height;
|
|
209
|
-
},
|
|
145
|
+
/**
|
|
146
|
+
* @this {XCUITestDriver}
|
|
147
|
+
*/
|
|
148
|
+
export async function closeApp() {
|
|
149
|
+
throw new Error(
|
|
150
|
+
`The closeApp API has been deprecated and is not supported anymore. ` +
|
|
151
|
+
`Consider using corresponding 'mobile:' extensions to manage the state of the app under test.`,
|
|
152
|
+
);
|
|
153
|
+
}
|
|
210
154
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
},
|
|
155
|
+
/**
|
|
156
|
+
* @this {XCUITestDriver}
|
|
157
|
+
* @param {string} url
|
|
158
|
+
* @returns {Promise<void>}
|
|
159
|
+
*/
|
|
160
|
+
export async function setUrl(url) {
|
|
161
|
+
this.log.debug(`Attempting to set url '${url}'`);
|
|
219
162
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
*
|
|
228
|
-
* Use {@linkcode mobilePerformIoHidEvent} to call a more universal API to perform a button press with duration on any supported device.
|
|
229
|
-
*
|
|
230
|
-
* @param {import('./types').ButtonName} name - The name of the button to be pressed.
|
|
231
|
-
* @param {number} [durationSeconds] - The duration of the button press in seconds (float).
|
|
232
|
-
* @this {XCUITestDriver}
|
|
233
|
-
*/
|
|
234
|
-
async mobilePressButton(name, durationSeconds) {
|
|
235
|
-
if (!name) {
|
|
236
|
-
throw new errors.InvalidArgumentError('Button name is mandatory');
|
|
237
|
-
}
|
|
238
|
-
if (!_.isNil(durationSeconds) && !_.isNumber(durationSeconds)) {
|
|
239
|
-
throw new errors.InvalidArgumentError('durationSeconds should be a number');
|
|
240
|
-
}
|
|
241
|
-
return await this.proxyCommand('/wda/pressButton', 'POST', {name, duration: durationSeconds});
|
|
242
|
-
},
|
|
243
|
-
/**
|
|
244
|
-
* Process a string as speech and send it to Siri.
|
|
245
|
-
*
|
|
246
|
-
* Presents the Siri UI, if it is not currently active, and accepts a string which is then processed as if it were recognized speech. See [the documentation of `activateWithVoiceRecognitionText`](https://developer.apple.com/documentation/xctest/xcuisiriservice/2852140-activatewithvoicerecognitiontext?language=objc) for more details.
|
|
163
|
+
if (this.isWebContext()) {
|
|
164
|
+
this.setCurrentUrl(url);
|
|
165
|
+
// make sure to clear out any leftover web frames
|
|
166
|
+
this.curWebFrames = [];
|
|
167
|
+
await (/** @type {import('appium-remote-debugger').RemoteDebugger} */ (this.remote)).navToUrl(url);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
247
170
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
171
|
+
if (this.isRealDevice()) {
|
|
172
|
+
await this.proxyCommand('/url', 'POST', {url});
|
|
173
|
+
} else {
|
|
174
|
+
await /** @type {import('../driver').Simulator} */ (this.device).simctl.openUrl(url);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Retrieves the viewport dimensions.
|
|
180
|
+
*
|
|
181
|
+
* The viewport is the device's screen size with status bar size subtracted if the latter is present/visible.
|
|
182
|
+
* @returns {Promise<import('./types').Viewport>}
|
|
183
|
+
* @this {XCUITestDriver}
|
|
184
|
+
*/
|
|
185
|
+
export async function getViewportRect() {
|
|
186
|
+
const scale = await this.getDevicePixelRatio();
|
|
187
|
+
// status bar height comes in unscaled, so scale it
|
|
188
|
+
const statusBarHeight = Math.trunc((await this.getStatusBarHeight()) * scale);
|
|
189
|
+
const windowSize = await this.getWindowRect();
|
|
259
190
|
|
|
260
|
-
|
|
191
|
+
// ios returns coordinates/dimensions in logical pixels, not device pixels,
|
|
192
|
+
// so scale up to device pixels. status bar height is already scaled.
|
|
193
|
+
return {
|
|
194
|
+
left: 0,
|
|
195
|
+
top: statusBarHeight,
|
|
196
|
+
width: Math.trunc(windowSize.width * scale),
|
|
197
|
+
height: Math.trunc(windowSize.height * scale) - statusBarHeight,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Get information about the screen.
|
|
203
|
+
*
|
|
204
|
+
* @privateRemarks memoized in constructor
|
|
205
|
+
* @this {XCUITestDriver}
|
|
206
|
+
* @returns {Promise<ScreenInfo>}
|
|
207
|
+
*/
|
|
208
|
+
export async function getScreenInfo() {
|
|
209
|
+
return /** @type {ScreenInfo} */ (await this.proxyCommand('/wda/screen', 'GET'));
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* @this {XCUITestDriver}
|
|
214
|
+
*/
|
|
215
|
+
export async function getStatusBarHeight() {
|
|
216
|
+
const {statusBarSize} = await this.getScreenInfo();
|
|
217
|
+
return statusBarSize.height;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* memoized in constructor
|
|
222
|
+
* @this {XCUITestDriver}
|
|
223
|
+
*/
|
|
224
|
+
export async function getDevicePixelRatio() {
|
|
225
|
+
const {scale} = await this.getScreenInfo();
|
|
226
|
+
return scale;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Emulates press action on the given physical device button.
|
|
231
|
+
*
|
|
232
|
+
* This executes different methods based on the platform:
|
|
233
|
+
*
|
|
234
|
+
* - iOS: [`pressButton:`](https://developer.apple.com/documentation/xctest/xcuidevice/1619052-pressbutton)
|
|
235
|
+
* - tvOS: [`pressButton:`](https://developer.apple.com/documentation/xctest/xcuiremote/1627475-pressbutton) or [`pressButton:forDuration:`](https://developer.apple.com/documentation/xctest/xcuiremote/1627476-pressbutton)
|
|
236
|
+
*
|
|
237
|
+
* Use {@linkcode mobilePerformIoHidEvent} to call a more universal API to perform a button press with duration on any supported device.
|
|
238
|
+
*
|
|
239
|
+
* @param {import('./types').ButtonName} name - The name of the button to be pressed.
|
|
240
|
+
* @param {number} [durationSeconds] - The duration of the button press in seconds (float).
|
|
241
|
+
* @this {XCUITestDriver}
|
|
242
|
+
*/
|
|
243
|
+
export async function mobilePressButton(name, durationSeconds) {
|
|
244
|
+
if (!name) {
|
|
245
|
+
throw new errors.InvalidArgumentError('Button name is mandatory');
|
|
246
|
+
}
|
|
247
|
+
if (!_.isNil(durationSeconds) && !_.isNumber(durationSeconds)) {
|
|
248
|
+
throw new errors.InvalidArgumentError('durationSeconds should be a number');
|
|
249
|
+
}
|
|
250
|
+
return await this.proxyCommand('/wda/pressButton', 'POST', {name, duration: durationSeconds});
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Process a string as speech and send it to Siri.
|
|
255
|
+
*
|
|
256
|
+
* Presents the Siri UI, if it is not currently active, and accepts a string which is then processed as if it were recognized speech. See [the documentation of `activateWithVoiceRecognitionText`](https://developer.apple.com/documentation/xctest/xcuisiriservice/2852140-activatewithvoicerecognitiontext?language=objc) for more details.
|
|
257
|
+
|
|
258
|
+
* @param {string} text - Text to be sent to Siri
|
|
259
|
+
* @returns {Promise<void>}
|
|
260
|
+
* @this {XCUITestDriver}
|
|
261
|
+
*/
|
|
262
|
+
export async function mobileSiriCommand(text) {
|
|
263
|
+
if (!text) {
|
|
264
|
+
throw new errors.InvalidArgumentError('"text" argument is mandatory');
|
|
265
|
+
}
|
|
266
|
+
await this.proxyCommand('/wda/siri/activate', 'POST', {text});
|
|
267
|
+
}
|
|
261
268
|
|
|
262
269
|
/**
|
|
263
270
|
* @typedef {Object} PressButtonOptions
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
const commands = {};
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* @typedef {Object} GeolocationInfo
|
|
5
3
|
* @property {number|null} latitude Measurement of distance north or south of the Equator, or
|
|
@@ -19,9 +17,9 @@ const commands = {};
|
|
|
19
17
|
* @since 4.18
|
|
20
18
|
* @this {XCUITestDriver}
|
|
21
19
|
*/
|
|
22
|
-
|
|
20
|
+
export async function mobileGetSimulatedLocation() {
|
|
23
21
|
return await this.proxyCommand('/wda/simulatedLocation', 'GET');
|
|
24
|
-
}
|
|
22
|
+
}
|
|
25
23
|
|
|
26
24
|
/**
|
|
27
25
|
* Sets simulated geolocation value.
|
|
@@ -34,12 +32,9 @@ commands.mobileGetSimulatedLocation = async function mobileGetSimulatedLocation(
|
|
|
34
32
|
* @since 4.18
|
|
35
33
|
* @this {XCUITestDriver}
|
|
36
34
|
*/
|
|
37
|
-
|
|
38
|
-
latitude,
|
|
39
|
-
longitude,
|
|
40
|
-
) {
|
|
35
|
+
export async function mobileSetSimulatedLocation(latitude, longitude) {
|
|
41
36
|
return await this.proxyCommand('/wda/simulatedLocation', 'POST', {latitude, longitude});
|
|
42
|
-
}
|
|
37
|
+
}
|
|
43
38
|
|
|
44
39
|
/**
|
|
45
40
|
* Resets simulated geolocation value.
|
|
@@ -52,12 +47,9 @@ commands.mobileSetSimulatedLocation = async function mobileSetSimulatedLocation(
|
|
|
52
47
|
* @since 4.18
|
|
53
48
|
* @this {XCUITestDriver}
|
|
54
49
|
*/
|
|
55
|
-
|
|
50
|
+
export async function mobileResetSimulatedLocation() {
|
|
56
51
|
return await this.proxyCommand('/wda/simulatedLocation', 'DELETE');
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export {commands};
|
|
60
|
-
export default commands;
|
|
52
|
+
}
|
|
61
53
|
|
|
62
54
|
/**
|
|
63
55
|
* @typedef {import('../driver').XCUITestDriver} XCUITestDriver
|