appium-xcuitest-driver 10.3.0 → 10.4.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 +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 -38
- 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 +275 -197
- package/build/lib/commands/web.d.ts.map +1 -1
- package/build/lib/commands/web.js +866 -785
- 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 +277 -1597
- package/build/lib/driver.d.ts.map +1 -1
- package/build/lib/driver.js +318 -235
- 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/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 -42
- 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 +932 -859
- package/lib/commands/xctest-record-screen.js +103 -105
- package/lib/commands/xctest.js +134 -139
- package/lib/driver.js +286 -235
- package/lib/execute-method-map.ts +9 -0
- package/npm-shrinkwrap.json +8 -8
- package/package.json +1 -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/cookies.d.ts +0 -15
- package/build/lib/cookies.d.ts.map +0 -1
- package/build/lib/cookies.js +0 -84
- package/build/lib/cookies.js.map +0 -1
- package/lib/commands/activeAppInfo.js +0 -14
- package/lib/commands/index.js +0 -95
- package/lib/cookies.js +0 -92
|
@@ -9,41 +9,39 @@ const INCREASE_CONTRAST_CONFIG = [
|
|
|
9
9
|
'disabled',
|
|
10
10
|
];
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const simulator = assertSimulator(this);
|
|
12
|
+
/**
|
|
13
|
+
* Sets the increase contrast configuration for the given simulator.
|
|
14
|
+
*
|
|
15
|
+
* @since Xcode 15 (but lower xcode could have this command)
|
|
16
|
+
* @param {IncreaseContrastAction} increaseContrast valid increase contrast configuration value.
|
|
17
|
+
* Acceptable value is 'enabled' or 'disabled' with Xcode 16.2.
|
|
18
|
+
* @throws {Error} if the current platform does not support content size appearance changes
|
|
19
|
+
* @this {XCUITestDriver}
|
|
20
|
+
*/
|
|
21
|
+
export async function mobileSetIncreaseContrast(increaseContrast) {
|
|
22
|
+
const simulator = assertSimulator(this);
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
if (!INCREASE_CONTRAST_CONFIG.includes(_.lowerCase(increaseContrast))) {
|
|
25
|
+
throw new errors.InvalidArgumentError(
|
|
26
|
+
`The 'increaseContrast' value is expected to be one of ${INCREASE_CONTRAST_CONFIG.join(',')}`
|
|
27
|
+
);
|
|
28
|
+
}
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
await simulator.setIncreaseContrast(increaseContrast);
|
|
31
|
+
}
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
};
|
|
33
|
+
/**
|
|
34
|
+
* Retrieves the current increase contrast configuration value from the given simulator.
|
|
35
|
+
*
|
|
36
|
+
* @since Xcode 15 (but lower xcode could have this command)
|
|
37
|
+
* @returns {Promise<IncreaseContrastResult>} the contrast configuration value.
|
|
38
|
+
* Possible return value is 'enabled', 'disabled',
|
|
39
|
+
* 'unsupported' or 'unknown' with Xcode 16.2.
|
|
40
|
+
* @this {XCUITestDriver}
|
|
41
|
+
*/
|
|
42
|
+
export async function mobileGetIncreaseContrast() {
|
|
43
|
+
return /** @type {IncreaseContrastResult} */ (await assertSimulator(this).getIncreaseContrast());
|
|
44
|
+
}
|
|
47
45
|
|
|
48
46
|
/**
|
|
49
47
|
* @typedef {import('../driver').XCUITestDriver} XCUITestDriver
|
package/lib/commands/iohid.js
CHANGED
|
@@ -1,6 +1,38 @@
|
|
|
1
1
|
import {errors} from 'appium/driver';
|
|
2
2
|
import {HIDUsageEvent, HIDPageEvent} from './hid-event';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Emulates triggering of the given low-level IO HID device event.
|
|
6
|
+
*
|
|
7
|
+
* Popular constants:
|
|
8
|
+
* - `kHIDPage_Consumer` = `0x0C`
|
|
9
|
+
* - `kHIDUsage_Csmr_VolumeIncrement` = `0xE9` (Volume Up)
|
|
10
|
+
* - `kHIDUsage_Csmr_VolumeDecrement` = `0xEA` (Volume Down)
|
|
11
|
+
* - `kHIDUsage_Csmr_Menu` = `0x40` (Home)
|
|
12
|
+
* - `kHIDUsage_Csmr_Power` = `0x30` (Power)
|
|
13
|
+
* - `kHIDUsage_Csmr_Snapshot` = `0x65` (Power + Home)
|
|
14
|
+
*
|
|
15
|
+
* @param {HIDPageEvent} page - The event page identifier
|
|
16
|
+
* @param {HIDUsageEvent} usage - The event usage identifier (usages are defined per-page)
|
|
17
|
+
* @param {number|string} durationSeconds - The event duration in float seconds (XCTest uses `0.005` for a single press event)
|
|
18
|
+
* @this {import('../driver').XCUITestDriver}
|
|
19
|
+
*/
|
|
20
|
+
export async function mobilePerformIoHidEvent(page, usage, durationSeconds) {
|
|
21
|
+
if (!isHIDPageEvent(page)) {
|
|
22
|
+
throw new errors.InvalidArgumentError(
|
|
23
|
+
`'page' argument must be a valid HIDPageEvent identifier`,
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
if (!isHIDUsageEvent(usage)) {
|
|
27
|
+
throw new errors.InvalidArgumentError(`'usage' must be a valid HIDUsageEvent identifier`);
|
|
28
|
+
}
|
|
29
|
+
const duration = parseFloat(String(durationSeconds));
|
|
30
|
+
if (Number.isNaN(duration)) {
|
|
31
|
+
throw new errors.InvalidArgumentError(`'durationSeconds' argument must be a valid number`);
|
|
32
|
+
}
|
|
33
|
+
return await this.proxyCommand('/wda/performIoHidEvent', 'POST', {page, usage, duration});
|
|
34
|
+
}
|
|
35
|
+
|
|
4
36
|
/**
|
|
5
37
|
* Type guard for {@linkcode HIDUsageEvent}
|
|
6
38
|
* @param {any} value
|
|
@@ -30,37 +62,3 @@ function isHIDPageEvent(value) {
|
|
|
30
62
|
}
|
|
31
63
|
return value in HIDPageEvent;
|
|
32
64
|
}
|
|
33
|
-
|
|
34
|
-
export default {
|
|
35
|
-
/**
|
|
36
|
-
* Emulates triggering of the given low-level IO HID device event.
|
|
37
|
-
*
|
|
38
|
-
* Popular constants:
|
|
39
|
-
* - `kHIDPage_Consumer` = `0x0C`
|
|
40
|
-
* - `kHIDUsage_Csmr_VolumeIncrement` = `0xE9` (Volume Up)
|
|
41
|
-
* - `kHIDUsage_Csmr_VolumeDecrement` = `0xEA` (Volume Down)
|
|
42
|
-
* - `kHIDUsage_Csmr_Menu` = `0x40` (Home)
|
|
43
|
-
* - `kHIDUsage_Csmr_Power` = `0x30` (Power)
|
|
44
|
-
* - `kHIDUsage_Csmr_Snapshot` = `0x65` (Power + Home)
|
|
45
|
-
*
|
|
46
|
-
* @param {HIDPageEvent} page - The event page identifier
|
|
47
|
-
* @param {HIDUsageEvent} usage - The event usage identifier (usages are defined per-page)
|
|
48
|
-
* @param {number|string} durationSeconds - The event duration in float seconds (XCTest uses `0.005` for a single press event)
|
|
49
|
-
* @this {import('../driver').XCUITestDriver}
|
|
50
|
-
*/
|
|
51
|
-
async mobilePerformIoHidEvent(page, usage, durationSeconds) {
|
|
52
|
-
if (!isHIDPageEvent(page)) {
|
|
53
|
-
throw new errors.InvalidArgumentError(
|
|
54
|
-
`'page' argument must be a valid HIDPageEvent identifier`,
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
if (!isHIDUsageEvent(usage)) {
|
|
58
|
-
throw new errors.InvalidArgumentError(`'usage' must be a valid HIDUsageEvent identifier`);
|
|
59
|
-
}
|
|
60
|
-
const duration = parseFloat(String(durationSeconds));
|
|
61
|
-
if (Number.isNaN(duration)) {
|
|
62
|
-
throw new errors.InvalidArgumentError(`'durationSeconds' argument must be a valid number`);
|
|
63
|
-
}
|
|
64
|
-
return await this.proxyCommand('/wda/performIoHidEvent', 'POST', {page, usage, duration});
|
|
65
|
-
},
|
|
66
|
-
};
|
package/lib/commands/keyboard.js
CHANGED
|
@@ -1,59 +1,57 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
},
|
|
3
|
+
/**
|
|
4
|
+
* @this {XCUITestDriver}
|
|
5
|
+
* @deprecated
|
|
6
|
+
*/
|
|
7
|
+
export async function hideKeyboard(strategy, ...possibleKeys) {
|
|
8
|
+
// last parameter is the session id
|
|
9
|
+
const keyNames = _.compact(possibleKeys.slice(0, -1)).map((x) => `${x}`);
|
|
10
|
+
await this.mobileHideKeyboard(keyNames);
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
14
|
+
/**
|
|
15
|
+
* @this {XCUITestDriver}
|
|
16
|
+
* @param {string[]} keys
|
|
17
|
+
*/
|
|
18
|
+
export async function mobileHideKeyboard(keys = []) {
|
|
19
|
+
if (!keys.includes('done')) {
|
|
20
|
+
keys.push('done');
|
|
21
|
+
}
|
|
22
|
+
await this.proxyCommand('/wda/keyboard/dismiss', 'POST', {keyNames: keys});
|
|
23
|
+
}
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
25
|
+
/**
|
|
26
|
+
* @this {XCUITestDriver}
|
|
27
|
+
*/
|
|
28
|
+
export async function isKeyboardShown() {
|
|
29
|
+
try {
|
|
30
|
+
await this.findNativeElementOrElements('class name', 'XCUIElementTypeKeyboard', false);
|
|
31
|
+
return true;
|
|
32
|
+
} catch {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
37
36
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
};
|
|
37
|
+
/**
|
|
38
|
+
* Send keys to the given element or to the application under test.
|
|
39
|
+
* This API is not supported on tvOS
|
|
40
|
+
*
|
|
41
|
+
* @since Xcode 15/iOS 17
|
|
42
|
+
* @this {import('../driver').XCUITestDriver}
|
|
43
|
+
* @param {(Key|string)[]} keys Array of keys to type.
|
|
44
|
+
* Each item could either be a string, that represents a key itself (see
|
|
45
|
+
* https://developer.apple.com/documentation/xctest/xcuielement/1500604-typekey?language=objc
|
|
46
|
+
* and https://developer.apple.com/documentation/xctest/xcuikeyboardkey?language=objc)
|
|
47
|
+
* or a dictionary, if the key should also be entered with modifiers.
|
|
48
|
+
* @param {string?} [elementId=null] uuid of the element to send keys to.
|
|
49
|
+
* If the element is not provided then the keys will be sent to the current application.
|
|
50
|
+
*/
|
|
51
|
+
export async function mobileKeys(keys, elementId = null) {
|
|
52
|
+
const url = `/wda/element/${elementId || 0}/keyboardInput`;
|
|
53
|
+
return await this.proxyCommand(url, 'POST', { keys });
|
|
54
|
+
}
|
|
57
55
|
|
|
58
56
|
/**
|
|
59
57
|
* @typedef {import('../driver').XCUITestDriver} XCUITestDriver
|
|
@@ -3,18 +3,16 @@ import {assertSimulator as _assertSimulator} from '../utils';
|
|
|
3
3
|
|
|
4
4
|
const assertSimulator = _.partial(_assertSimulator, 'Keychain modification');
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
assertSimulator(this);
|
|
6
|
+
/**
|
|
7
|
+
* Clears keychains on a simulated device.
|
|
8
|
+
*
|
|
9
|
+
* @throws {Error} If current device is not a Simulator or there was an error
|
|
10
|
+
* while clearing keychains.
|
|
11
|
+
* @this {import('../driver').XCUITestDriver}
|
|
12
|
+
* @group Simulator Only
|
|
13
|
+
*/
|
|
14
|
+
export async function mobileClearKeychains() {
|
|
15
|
+
assertSimulator(this);
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
17
|
+
await /** @type {import('../driver').Simulator} */ (this.device).clearKeychains();
|
|
18
|
+
}
|
|
@@ -3,30 +3,28 @@ import {assertSimulator as _assertSimulator} from '../utils';
|
|
|
3
3
|
|
|
4
4
|
const assertSimulator = _.partial(_assertSimulator, 'Localization configuration');
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
assertSimulator(this);
|
|
6
|
+
/**
|
|
7
|
+
* Change localization settings on the currently booted simulator
|
|
8
|
+
*
|
|
9
|
+
* The changed settings are only applied for _newly started_ applications and activities.
|
|
10
|
+
* Currently running applications will be unchanged. This means, for example, that the keyboard should be hidden and shown again in order to observe the changed layout, and corresponding apps must be restarted in order to observe their interface using the newly set locale/language.
|
|
11
|
+
*
|
|
12
|
+
* The driver performs no strict checking of the arguments (such as locale names). Be aware that an incorrect or invalid string may cause unexpected behavior.
|
|
13
|
+
* @param {import('./types').KeyboardOptions} [keyboard] - Keyboard options
|
|
14
|
+
* @param {import('./types').LanguageOptions} [language] - Language options
|
|
15
|
+
* @param {import('./types').LocaleOptions} [locale] - Locale options
|
|
16
|
+
* @throws {Error} If there was a failure while setting the preferences
|
|
17
|
+
* @returns {Promise<boolean>} `true` if any of settings has been successfully changed
|
|
18
|
+
* @group Simulator Only
|
|
19
|
+
* @this {import('../driver').XCUITestDriver}
|
|
20
|
+
*/
|
|
21
|
+
export async function mobileConfigureLocalization(keyboard, language, locale) {
|
|
22
|
+
assertSimulator(this);
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
};
|
|
24
|
+
const localizationOptions = {locale, keyboard};
|
|
25
|
+
if (language) {
|
|
26
|
+
// Assign skipSyncUiDialogTranslation: true option in order to avoid shutting down the WDA session
|
|
27
|
+
localizationOptions.language = Object.assign(language, {skipSyncUiDialogTranslation: true});
|
|
28
|
+
}
|
|
29
|
+
return await /** @type {import('../driver').Simulator} */ (this.device).configureLocalization(localizationOptions);
|
|
30
|
+
}
|
package/lib/commands/location.js
CHANGED
|
@@ -4,127 +4,125 @@ import {util} from 'appium/support';
|
|
|
4
4
|
import {AuthorizationStatus} from './enum';
|
|
5
5
|
import { isIos17OrNewer } from '../utils';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return {latitude, longitude, altitude: 0};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
this.log.warn(`No location was set by mobile:setSimulatedLocation. Trying to return the location from the device.`);
|
|
7
|
+
/**
|
|
8
|
+
* Returns location of the device under test.
|
|
9
|
+
* The device under test must allow the location services for WDA
|
|
10
|
+
* as 'Always' to get the location data correctly.
|
|
11
|
+
*
|
|
12
|
+
* The 'latitude', 'longitude' and 'altitude' could be zero even
|
|
13
|
+
* if the Location Services are set to 'Always', because the device
|
|
14
|
+
* needs some time to update the location data.
|
|
15
|
+
*
|
|
16
|
+
* For iOS 17, the return value could be the result of
|
|
17
|
+
* "mobile:getSimulatedLocation" if the simulated location has been previously set
|
|
18
|
+
* "mobile:setSimulatedLocation" already.
|
|
19
|
+
*
|
|
20
|
+
* @returns {Promise<import('./types').LocationWithAltitude>}
|
|
21
|
+
* @throws {Error} If the device under test returns an error message.
|
|
22
|
+
* i.e.: tvOS returns unsupported error
|
|
23
|
+
* @this {XCUITestDriver}
|
|
24
|
+
*/
|
|
25
|
+
export async function getGeoLocation() {
|
|
26
|
+
// Currently we proxy the setGeoLocation to mobile:setSimulatedLocation for iOS 17+.
|
|
27
|
+
// It would be helpful to address to use "mobile:getSimulatedLocation" for iOS 17+.
|
|
28
|
+
if (isIos17OrNewer(this.opts)) {
|
|
29
|
+
const {latitude, longitude} = await this.mobileGetSimulatedLocation();
|
|
30
|
+
if (latitude && longitude) {
|
|
31
|
+
this.log.debug('Returning the geolocation that has been previously set by mobile:setSimulatedLocation. ' +
|
|
32
|
+
'mobile:resetSimulatedLocation can reset the location configuration.');
|
|
33
|
+
return {latitude, longitude, altitude: 0};
|
|
38
34
|
}
|
|
39
35
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
// '/wda/device/location' returns current device location information,
|
|
43
|
-
// but '/wda/simulatedLocation' returns `null` values until the WDA process
|
|
44
|
-
// sets a simulated location. After setting the value, both returns the same values.
|
|
45
|
-
const {authorizationStatus, latitude, longitude, altitude} = /** @type {WDALocationInfo} */ (
|
|
46
|
-
await this.proxyCommand('/wda/device/location', 'GET')
|
|
47
|
-
);
|
|
36
|
+
this.log.warn(`No location was set by mobile:setSimulatedLocation. Trying to return the location from the device.`);
|
|
37
|
+
}
|
|
48
38
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
`to simulate locations instead.`,
|
|
58
|
-
);
|
|
59
|
-
}
|
|
39
|
+
// Please do not change the way to get the location here with '/wda/simulatedLocation'
|
|
40
|
+
// endpoint because they could return different value before setting the simulated location.
|
|
41
|
+
// '/wda/device/location' returns current device location information,
|
|
42
|
+
// but '/wda/simulatedLocation' returns `null` values until the WDA process
|
|
43
|
+
// sets a simulated location. After setting the value, both returns the same values.
|
|
44
|
+
const {authorizationStatus, latitude, longitude, altitude} = /** @type {WDALocationInfo} */ (
|
|
45
|
+
await this.proxyCommand('/wda/device/location', 'GET')
|
|
46
|
+
);
|
|
60
47
|
|
|
61
|
-
|
|
62
|
-
|
|
48
|
+
// '3' is 'Always' in the privacy
|
|
49
|
+
// https://developer.apple.com/documentation/corelocation/clauthorizationstatus
|
|
50
|
+
if (authorizationStatus !== AuthorizationStatus.authorizedAlways) {
|
|
51
|
+
throw this.log.errorWithException(
|
|
52
|
+
`Location service must be set to 'Always' in order to ` +
|
|
53
|
+
`retrieve the current geolocation data. Please set it up manually via ` +
|
|
54
|
+
`'Settings > Privacy > Location Services -> WebDriverAgentRunner-Runner'. ` +
|
|
55
|
+
`Or please use 'mobile:getSimulatedLocation'/'mobile:setSimulatedLocation' commands ` +
|
|
56
|
+
`to simulate locations instead.`,
|
|
57
|
+
);
|
|
58
|
+
}
|
|
63
59
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
*
|
|
67
|
-
* iOS 17+ real device environment will be via "mobile:setSimulatedLocation" as
|
|
68
|
-
* setting simulated location for XCTest session.
|
|
69
|
-
*
|
|
70
|
-
* @param {Partial<Location>} location
|
|
71
|
-
* @this {XCUITestDriver}
|
|
72
|
-
*/
|
|
73
|
-
async setGeoLocation(location) {
|
|
74
|
-
let {latitude, longitude} = location;
|
|
60
|
+
return {latitude, longitude, altitude};
|
|
61
|
+
}
|
|
75
62
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Set location of the device under test.
|
|
65
|
+
*
|
|
66
|
+
* iOS 17+ real device environment will be via "mobile:setSimulatedLocation" as
|
|
67
|
+
* setting simulated location for XCTest session.
|
|
68
|
+
*
|
|
69
|
+
* @param {Partial<Location>} location
|
|
70
|
+
* @this {XCUITestDriver}
|
|
71
|
+
*/
|
|
72
|
+
export async function setGeoLocation(location) {
|
|
73
|
+
let {latitude, longitude} = location;
|
|
84
74
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
} else {
|
|
89
|
-
const service = await services.startSimulateLocationService(this.opts.udid);
|
|
90
|
-
try {
|
|
91
|
-
service.setLocation(latitude, longitude);
|
|
92
|
-
} catch (e) {
|
|
93
|
-
throw this.log.errorWithException(
|
|
94
|
-
`Can't set the location on device '${this.opts.udid}'. Original error: ${e.message}`,
|
|
95
|
-
);
|
|
96
|
-
} finally {
|
|
97
|
-
service.close();
|
|
98
|
-
}
|
|
99
|
-
}
|
|
75
|
+
if (!util.hasValue(latitude) || !util.hasValue(longitude)) {
|
|
76
|
+
throw new errors.InvalidArgumentError(`Both latitude and longitude should be set`);
|
|
77
|
+
}
|
|
100
78
|
|
|
79
|
+
if (this.isSimulator()) {
|
|
80
|
+
await /** @type {import('../driver').Simulator} */ (this.device).setGeolocation(`${latitude}`, `${longitude}`);
|
|
101
81
|
return /** @type {Location} */ ({latitude, longitude, altitude: 0});
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Reset the location service on real device.
|
|
106
|
-
* Raises not implemented error for simulator.
|
|
107
|
-
* @throws {Error} If the device is simulator, or 'resetLocation' raises an error.
|
|
108
|
-
* @this {XCUITestDriver}
|
|
109
|
-
*/
|
|
110
|
-
async mobileResetLocationService() {
|
|
111
|
-
if (this.isSimulator()) {
|
|
112
|
-
throw new errors.NotImplementedError();
|
|
113
|
-
}
|
|
82
|
+
}
|
|
114
83
|
|
|
84
|
+
if (isIos17OrNewer(this.opts)) {
|
|
85
|
+
this.log.info(`Proxying to mobile:setSimulatedLocation method for iOS 17+ platform version`);
|
|
86
|
+
await this.mobileSetSimulatedLocation(latitude, longitude);
|
|
87
|
+
} else {
|
|
115
88
|
const service = await services.startSimulateLocationService(this.opts.udid);
|
|
116
89
|
try {
|
|
117
|
-
service.
|
|
118
|
-
} catch (
|
|
90
|
+
service.setLocation(latitude, longitude);
|
|
91
|
+
} catch (e) {
|
|
119
92
|
throw this.log.errorWithException(
|
|
120
|
-
`
|
|
121
|
-
`Original error: ${err.message}`,
|
|
93
|
+
`Can't set the location on device '${this.opts.udid}'. Original error: ${e.message}`,
|
|
122
94
|
);
|
|
123
95
|
} finally {
|
|
124
96
|
service.close();
|
|
125
97
|
}
|
|
126
|
-
}
|
|
127
|
-
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return /** @type {Location} */ ({latitude, longitude, altitude: 0});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Reset the location service on real device.
|
|
105
|
+
* Raises not implemented error for simulator.
|
|
106
|
+
* @throws {Error} If the device is simulator, or 'resetLocation' raises an error.
|
|
107
|
+
* @this {XCUITestDriver}
|
|
108
|
+
*/
|
|
109
|
+
export async function mobileResetLocationService() {
|
|
110
|
+
if (this.isSimulator()) {
|
|
111
|
+
throw new errors.NotImplementedError();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const service = await services.startSimulateLocationService(this.opts.udid);
|
|
115
|
+
try {
|
|
116
|
+
service.resetLocation();
|
|
117
|
+
} catch (err) {
|
|
118
|
+
throw this.log.errorWithException(
|
|
119
|
+
`Failed to reset the location on the device on device '${this.opts.udid}'. ` +
|
|
120
|
+
`Original error: ${err.message}`,
|
|
121
|
+
);
|
|
122
|
+
} finally {
|
|
123
|
+
service.close();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
128
126
|
|
|
129
127
|
/**
|
|
130
128
|
* @typedef {import('../driver').XCUITestDriver} XCUITestDriver
|