appium-xcuitest-driver 10.14.2 → 10.14.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- 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/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/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/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/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/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/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/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/simctl.d.ts +16 -22
- package/build/lib/commands/simctl.d.ts.map +1 -1
- package/build/lib/commands/simctl.js +8 -17
- package/build/lib/commands/simctl.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 +18 -14
- package/build/lib/commands/timeouts.js.map +1 -1
- package/lib/commands/alert.ts +98 -0
- package/lib/commands/appearance.ts +70 -0
- package/lib/commands/biometric.ts +52 -0
- package/lib/commands/content-size.ts +67 -0
- package/lib/commands/geolocation.ts +55 -0
- package/lib/commands/{iohid.js → iohid.ts} +15 -13
- package/lib/commands/keyboard.ts +70 -0
- package/lib/commands/{notifications.js → notifications.ts} +22 -14
- package/lib/commands/permissions.ts +90 -0
- package/lib/commands/{proxy-helper.js → proxy-helper.ts} +26 -26
- package/lib/commands/{simctl.js → simctl.ts} +27 -21
- package/lib/commands/timeouts.ts +95 -0
- package/npm-shrinkwrap.json +5 -5
- package/package.json +1 -1
- package/lib/commands/alert.js +0 -88
- package/lib/commands/appearance.js +0 -71
- package/lib/commands/biometric.js +0 -52
- package/lib/commands/content-size.js +0 -68
- package/lib/commands/geolocation.js +0 -56
- package/lib/commands/keyboard.js +0 -62
- package/lib/commands/permissions.js +0 -85
- package/lib/commands/timeouts.js +0 -68
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import type {XCUITestDriver} from '../driver';
|
|
3
|
+
import type {KeyboardKey} from './types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Hides the keyboard.
|
|
7
|
+
*
|
|
8
|
+
* @deprecated
|
|
9
|
+
*/
|
|
10
|
+
export async function hideKeyboard(
|
|
11
|
+
this: XCUITestDriver,
|
|
12
|
+
strategy?: string,
|
|
13
|
+
...possibleKeys: string[]
|
|
14
|
+
): Promise<boolean> {
|
|
15
|
+
// last parameter is the session id
|
|
16
|
+
const keyNames = _.compact(possibleKeys.slice(0, -1)).map((x) => `${x}`);
|
|
17
|
+
await this.mobileHideKeyboard(keyNames);
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Hides the keyboard using the specified key names.
|
|
23
|
+
*
|
|
24
|
+
* @param keys - Array of key names to use for dismissing the keyboard
|
|
25
|
+
*/
|
|
26
|
+
export async function mobileHideKeyboard(
|
|
27
|
+
this: XCUITestDriver,
|
|
28
|
+
keys: string[] = [],
|
|
29
|
+
): Promise<void> {
|
|
30
|
+
await this.proxyCommand('/wda/keyboard/dismiss', 'POST', {
|
|
31
|
+
keyNames: keys.includes('done') ? keys : [...keys, 'done'],
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Checks whether the keyboard is currently shown.
|
|
37
|
+
*
|
|
38
|
+
* @returns `true` if the keyboard is shown, `false` otherwise
|
|
39
|
+
*/
|
|
40
|
+
export async function isKeyboardShown(this: XCUITestDriver): Promise<boolean> {
|
|
41
|
+
try {
|
|
42
|
+
await this.findNativeElementOrElements('class name', 'XCUIElementTypeKeyboard', false);
|
|
43
|
+
return true;
|
|
44
|
+
} catch {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Send keys to the given element or to the application under test.
|
|
51
|
+
* This API is not supported on tvOS
|
|
52
|
+
*
|
|
53
|
+
* @since Xcode 15/iOS 17
|
|
54
|
+
* @param keys - Array of keys to type.
|
|
55
|
+
* Each item could either be a string, that represents a key itself (see
|
|
56
|
+
* https://developer.apple.com/documentation/xctest/xcuielement/1500604-typekey?language=objc
|
|
57
|
+
* and https://developer.apple.com/documentation/xctest/xcuikeyboardkey?language=objc)
|
|
58
|
+
* or a dictionary, if the key should also be entered with modifiers.
|
|
59
|
+
* @param elementId - UUID of the element to send keys to.
|
|
60
|
+
* If the element is not provided then the keys will be sent to the current application.
|
|
61
|
+
*/
|
|
62
|
+
export async function mobileKeys(
|
|
63
|
+
this: XCUITestDriver,
|
|
64
|
+
keys: (KeyboardKey | string)[],
|
|
65
|
+
elementId: string | null = null,
|
|
66
|
+
): Promise<void> {
|
|
67
|
+
const url = `/wda/element/${elementId || 0}/keyboardInput`;
|
|
68
|
+
await this.proxyCommand(url, 'POST', { keys });
|
|
69
|
+
}
|
|
70
|
+
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import {errors} from 'appium/driver';
|
|
2
2
|
import _ from 'lodash';
|
|
3
|
+
import type {XCUITestDriver} from '../driver';
|
|
4
|
+
import type {PushPayload, NotificationType} from './types';
|
|
5
|
+
import type {Simulator} from 'appium-ios-simulator';
|
|
3
6
|
|
|
4
7
|
/**
|
|
5
8
|
* Simulates push notification delivery to a simulated device.
|
|
@@ -7,12 +10,16 @@ import _ from 'lodash';
|
|
|
7
10
|
* **Only "remote" push notifications are supported.** VoIP, Complication, File Provider, and other types are unsupported.
|
|
8
11
|
*
|
|
9
12
|
* Supported in Xcode SDK 11.4+.
|
|
10
|
-
*
|
|
11
|
-
* @param
|
|
13
|
+
*
|
|
14
|
+
* @param bundleId - The bundle identifier of the target application
|
|
15
|
+
* @param payload - Valid push payload.
|
|
12
16
|
* @group Simulator Only
|
|
13
|
-
* @this {XCUITestDriver}
|
|
14
17
|
*/
|
|
15
|
-
export async function mobilePushNotification(
|
|
18
|
+
export async function mobilePushNotification(
|
|
19
|
+
this: XCUITestDriver,
|
|
20
|
+
bundleId: string,
|
|
21
|
+
payload: PushPayload,
|
|
22
|
+
): Promise<void> {
|
|
16
23
|
if (!this.isSimulator()) {
|
|
17
24
|
throw new Error('This extension only works on Simulator');
|
|
18
25
|
}
|
|
@@ -34,7 +41,7 @@ export async function mobilePushNotification(bundleId, payload) {
|
|
|
34
41
|
`Got ${JSON.stringify(payload.aps)} instead`,
|
|
35
42
|
);
|
|
36
43
|
}
|
|
37
|
-
|
|
44
|
+
await (this.device as Simulator).pushNotification({
|
|
38
45
|
...payload,
|
|
39
46
|
'Simulator Target Bundle': bundleId,
|
|
40
47
|
});
|
|
@@ -47,20 +54,21 @@ export async function mobilePushNotification(bundleId, payload) {
|
|
|
47
54
|
* [`XCTNSNotificationExpectation`](https://developer.apple.com/documentation/xctest/xctnsnotificationexpectation?language=objc) and
|
|
48
55
|
* [`XCTDarwinNotificationExpectation`](https://developer.apple.com/documentation/xctest/xctdarwinnotificationexpectation?language=objc) entities.
|
|
49
56
|
*
|
|
50
|
-
* @param
|
|
51
|
-
* @param
|
|
52
|
-
* @param
|
|
57
|
+
* @param name - The name of the notification to expect
|
|
58
|
+
* @param type - Which notification type to expect.
|
|
59
|
+
* @param timeoutSeconds - For how long to wait until the notification is delivered (in float seconds).
|
|
53
60
|
* @throws A [`TimeoutError`](https://www.selenium.dev/selenium/docs/api/javascript/module/selenium-webdriver/lib/error_exports_TimeoutError.html) if the expected notification has not been delivered within the given timeout.
|
|
54
|
-
* @this {XCUITestDriver}
|
|
55
61
|
*/
|
|
56
|
-
export async function mobileExpectNotification(
|
|
57
|
-
|
|
62
|
+
export async function mobileExpectNotification(
|
|
63
|
+
this: XCUITestDriver,
|
|
64
|
+
name: string,
|
|
65
|
+
type: NotificationType = 'plain',
|
|
66
|
+
timeoutSeconds: number = 60,
|
|
67
|
+
): Promise<void> {
|
|
68
|
+
await this.proxyCommand('/wda/expectNotification', 'POST', {
|
|
58
69
|
name,
|
|
59
70
|
type,
|
|
60
71
|
timeout: timeoutSeconds,
|
|
61
72
|
});
|
|
62
73
|
}
|
|
63
74
|
|
|
64
|
-
/**
|
|
65
|
-
* @typedef {import('../driver').XCUITestDriver} XCUITestDriver
|
|
66
|
-
*/
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import {PermissionService} from './enum';
|
|
3
|
+
import {assertSimulator as _assertSimulator} from '../utils';
|
|
4
|
+
import type {XCUITestDriver} from '../driver';
|
|
5
|
+
import type {PermissionState} from './types';
|
|
6
|
+
import type {Simulator} from 'appium-ios-simulator';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Resets the given permission for the active application under test.
|
|
10
|
+
* Works for both Simulator and real devices using Xcode SDK 11.4+
|
|
11
|
+
*
|
|
12
|
+
* @param service - One of the available service names. This could also be an integer protected resource identifier; see [this list](https://developer.apple.com/documentation/xctest/xcuiprotectedresource?language=objc)
|
|
13
|
+
* @throws If permission reset fails on the device.
|
|
14
|
+
*/
|
|
15
|
+
export async function mobileResetPermission(
|
|
16
|
+
this: XCUITestDriver,
|
|
17
|
+
service: PermissionService | number,
|
|
18
|
+
): Promise<void> {
|
|
19
|
+
if (!service) {
|
|
20
|
+
throw new Error(`The 'service' option is expected to be present`);
|
|
21
|
+
}
|
|
22
|
+
let resource: number;
|
|
23
|
+
if (_.isString(service)) {
|
|
24
|
+
resource = PermissionService[_.toLower(service) as keyof typeof PermissionService];
|
|
25
|
+
if (!resource) {
|
|
26
|
+
throw new Error(
|
|
27
|
+
`The 'service' value must be one of ` + `${JSON.stringify(_.keys(PermissionService))}`,
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
} else if (_.isInteger(service)) {
|
|
31
|
+
resource = service;
|
|
32
|
+
} else {
|
|
33
|
+
throw new Error(
|
|
34
|
+
`The 'service' value must be either a string or an integer. ` +
|
|
35
|
+
`'${service}' is passed instead`,
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
await this.proxyCommand('/wda/resetAppAuth', 'POST', {resource});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Gets application permission state on a simulated device.
|
|
44
|
+
*
|
|
45
|
+
* **This method requires [WIX applesimutils](https://github.com/wix/AppleSimulatorUtils) to be installed on the Appium server host.**
|
|
46
|
+
*
|
|
47
|
+
* @param bundleId - Bundle identifier of the target application
|
|
48
|
+
* @param service - Service name
|
|
49
|
+
* @returns Either 'yes', 'no', 'unset' or 'limited'
|
|
50
|
+
* @throws If permission getting fails or the device is not a Simulator.
|
|
51
|
+
* @group Simulator Only
|
|
52
|
+
*/
|
|
53
|
+
export async function mobileGetPermission(
|
|
54
|
+
this: XCUITestDriver,
|
|
55
|
+
bundleId: string,
|
|
56
|
+
service: PermissionService,
|
|
57
|
+
): Promise<PermissionState> {
|
|
58
|
+
if (!service) {
|
|
59
|
+
throw new Error(`The 'service' option is expected to be present`);
|
|
60
|
+
}
|
|
61
|
+
assertSimulator(this);
|
|
62
|
+
|
|
63
|
+
return await (this.device as Simulator).getPermission(
|
|
64
|
+
bundleId, String(service)
|
|
65
|
+
) as PermissionState;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Set application permission state on Simulator.
|
|
70
|
+
*
|
|
71
|
+
* @param access - One or more access rules to set.
|
|
72
|
+
* @param bundleId - Bundle identifier of the target application
|
|
73
|
+
* @since Xcode SDK 11.4
|
|
74
|
+
* @throws If permission setting fails or the device is not a Simulator.
|
|
75
|
+
* @group Simulator Only
|
|
76
|
+
*/
|
|
77
|
+
export async function mobileSetPermissions(
|
|
78
|
+
this: XCUITestDriver,
|
|
79
|
+
access: Record<string, PermissionState>,
|
|
80
|
+
bundleId: string,
|
|
81
|
+
): Promise<void> {
|
|
82
|
+
if (!_.isPlainObject(access)) {
|
|
83
|
+
throw new Error(`The 'access' option is expected to be a map`);
|
|
84
|
+
}
|
|
85
|
+
assertSimulator(this);
|
|
86
|
+
|
|
87
|
+
await (this.device as Simulator).setPermissions(bundleId, access);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const assertSimulator = (driver: XCUITestDriver) => _assertSimulator.call(driver, 'Permission-related operations');
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import {errors, routeToCommandName} from 'appium/driver';
|
|
2
2
|
import B from 'bluebird';
|
|
3
|
+
import type {XCUITestDriver} from '../driver';
|
|
3
4
|
|
|
4
5
|
const GET = 'GET';
|
|
5
6
|
const POST = 'POST';
|
|
6
7
|
const DELETE = 'DELETE';
|
|
7
|
-
const SUPPORTED_METHODS = Object.freeze(new Set(
|
|
8
|
+
const SUPPORTED_METHODS = Object.freeze(new Set([GET, POST, DELETE] as const));
|
|
8
9
|
|
|
9
|
-
const WDA_ROUTES =
|
|
10
|
+
const WDA_ROUTES = {
|
|
10
11
|
'/wda/screen': {
|
|
11
12
|
GET: 'getScreenInfo',
|
|
12
13
|
},
|
|
@@ -43,22 +44,30 @@ const WDA_ROUTES = /** @type {const} */ ({
|
|
|
43
44
|
'/wda/locked': {
|
|
44
45
|
GET: 'isLocked',
|
|
45
46
|
},
|
|
46
|
-
}
|
|
47
|
+
} as const;
|
|
48
|
+
|
|
49
|
+
export type AllowedHttpMethod = 'GET' | 'POST' | 'DELETE';
|
|
47
50
|
|
|
48
51
|
/**
|
|
49
52
|
* Proxies a command to WebDriverAgent
|
|
50
|
-
*
|
|
51
|
-
* @template
|
|
52
|
-
* @
|
|
53
|
-
* @param
|
|
54
|
-
* @param
|
|
55
|
-
* @param
|
|
56
|
-
* @this
|
|
57
|
-
* @returns
|
|
53
|
+
*
|
|
54
|
+
* @template TReq - Request body type
|
|
55
|
+
* @template TRes - Response type
|
|
56
|
+
* @param url - The endpoint URL
|
|
57
|
+
* @param method - HTTP method to use
|
|
58
|
+
* @param body - Optional request body
|
|
59
|
+
* @param isSessionCommand - Whether this is a session command (default: true)
|
|
60
|
+
* @returns Promise resolving to the response
|
|
58
61
|
*/
|
|
59
|
-
export async function proxyCommand
|
|
62
|
+
export async function proxyCommand<TReq = any, TRes = unknown>(
|
|
63
|
+
this: XCUITestDriver,
|
|
64
|
+
url: string,
|
|
65
|
+
method: AllowedHttpMethod,
|
|
66
|
+
body?: TReq,
|
|
67
|
+
isSessionCommand: boolean = true,
|
|
68
|
+
): Promise<TRes> {
|
|
60
69
|
if (this.shutdownUnexpectedly) {
|
|
61
|
-
return
|
|
70
|
+
return undefined as TRes;
|
|
62
71
|
}
|
|
63
72
|
|
|
64
73
|
if (!url) {
|
|
@@ -83,12 +92,12 @@ export async function proxyCommand(url, method, body, isSessionCommand = true) {
|
|
|
83
92
|
}
|
|
84
93
|
|
|
85
94
|
if (!timeout) {
|
|
86
|
-
return
|
|
95
|
+
return await proxy.command(url, method, body) as TRes;
|
|
87
96
|
}
|
|
88
97
|
|
|
89
98
|
this.log.debug(`Setting custom timeout to ${timeout} ms for '${cmdName}' command`);
|
|
90
99
|
try {
|
|
91
|
-
return
|
|
100
|
+
return await B.resolve(proxy.command(url, method, body)).timeout(timeout) as TRes;
|
|
92
101
|
} catch (e) {
|
|
93
102
|
if (!(e instanceof B.Promise.TimeoutError)) {
|
|
94
103
|
throw e;
|
|
@@ -102,18 +111,9 @@ export async function proxyCommand(url, method, body, isSessionCommand = true) {
|
|
|
102
111
|
}
|
|
103
112
|
}
|
|
104
113
|
|
|
105
|
-
|
|
106
|
-
* @param {string} endpoint
|
|
107
|
-
* @param {AllowedHttpMethod} method
|
|
108
|
-
* @returns {string|undefined}
|
|
109
|
-
*/
|
|
110
|
-
function wdaRouteToCommandName(endpoint, method) {
|
|
114
|
+
function wdaRouteToCommandName(endpoint: string, method: AllowedHttpMethod): string | undefined {
|
|
111
115
|
if (endpoint in WDA_ROUTES) {
|
|
112
|
-
return WDA_ROUTES[endpoint][method];
|
|
116
|
+
return WDA_ROUTES[endpoint as keyof typeof WDA_ROUTES]?.[method];
|
|
113
117
|
}
|
|
114
118
|
}
|
|
115
119
|
|
|
116
|
-
/**
|
|
117
|
-
* @typedef {import('../driver').XCUITestDriver} XCUITestDriver
|
|
118
|
-
* @typedef {'GET'|'POST'|'DELETE'} AllowedHttpMethod
|
|
119
|
-
*/
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { errors } from 'appium/driver';
|
|
2
|
+
import type {XCUITestDriver} from '../driver';
|
|
3
|
+
import type {Simulator} from 'appium-ios-simulator';
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* List of subcommands for `simctl` we provide as mobile simctl command.
|
|
@@ -27,19 +29,33 @@ const SUBCOMMANDS_HAS_DEVICE = [
|
|
|
27
29
|
'terminate',
|
|
28
30
|
'ui',
|
|
29
31
|
'uninstall'
|
|
30
|
-
];
|
|
32
|
+
] as const;
|
|
33
|
+
|
|
34
|
+
export interface SimctlExecResponse {
|
|
35
|
+
/** The output of standard out. */
|
|
36
|
+
stdout: string;
|
|
37
|
+
/** The output of standard error. */
|
|
38
|
+
stderr: string;
|
|
39
|
+
/** Return code. */
|
|
40
|
+
code: number;
|
|
41
|
+
}
|
|
31
42
|
|
|
32
43
|
/**
|
|
33
44
|
* Run the given command with arguments as `xcrun simctl` subcommand.
|
|
34
45
|
* This method works behind the 'simctl' security flag.
|
|
35
|
-
*
|
|
36
|
-
* @param
|
|
37
|
-
* @param
|
|
38
|
-
* @param
|
|
39
|
-
* @returns
|
|
40
|
-
* @throws
|
|
46
|
+
*
|
|
47
|
+
* @param command - Subcommand to run with `xcrun simctl`. Must be one of the supported commands.
|
|
48
|
+
* @param args - Arguments for the subcommand. The arguments should be after <device> in the help.
|
|
49
|
+
* @param timeout - The maximum number of milliseconds
|
|
50
|
+
* @returns The execution result with stdout, stderr, and return code
|
|
51
|
+
* @throws If the simctl subcommand command returns non-zero return code, or the given subcommand was invalid.
|
|
41
52
|
*/
|
|
42
|
-
export async function mobileSimctl(
|
|
53
|
+
export async function mobileSimctl(
|
|
54
|
+
this: XCUITestDriver,
|
|
55
|
+
command: string,
|
|
56
|
+
args: string[] = [],
|
|
57
|
+
timeout?: number,
|
|
58
|
+
): Promise<SimctlExecResponse> {
|
|
43
59
|
if (!this.isSimulator()) {
|
|
44
60
|
throw new errors.UnsupportedOperationError(`Only simulator is supported.`);
|
|
45
61
|
}
|
|
@@ -48,13 +64,13 @@ export async function mobileSimctl(command, args = [], timeout = undefined) {
|
|
|
48
64
|
throw new errors.InvalidArgumentError(`Unknown device or simulator UDID: '${this.opts.udid}'`);
|
|
49
65
|
}
|
|
50
66
|
|
|
51
|
-
if (!SUBCOMMANDS_HAS_DEVICE.includes(command)) {
|
|
67
|
+
if (!(SUBCOMMANDS_HAS_DEVICE as readonly string[]).includes(command)) {
|
|
52
68
|
throw new errors.InvalidArgumentError(`The given command '${command}' is not supported. ` +
|
|
53
69
|
`Available subcommands are ${SUBCOMMANDS_HAS_DEVICE.join(',')}`);
|
|
54
70
|
}
|
|
55
71
|
|
|
56
|
-
const result = await
|
|
57
|
-
command,
|
|
72
|
+
const result = await (this.device as Simulator).simctl.exec(
|
|
73
|
+
command as typeof SUBCOMMANDS_HAS_DEVICE[number],
|
|
58
74
|
{args: [this.opts.udid, ...args], timeout}
|
|
59
75
|
);
|
|
60
76
|
return {
|
|
@@ -64,13 +80,3 @@ export async function mobileSimctl(command, args = [], timeout = undefined) {
|
|
|
64
80
|
};
|
|
65
81
|
}
|
|
66
82
|
|
|
67
|
-
/**
|
|
68
|
-
* @typedef {Object} SimctlExecResponse
|
|
69
|
-
* @property {string} stdout The output of standard out.
|
|
70
|
-
* @property {string} stderr The output of standard error.
|
|
71
|
-
* @property {number} code Return code.
|
|
72
|
-
*/
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* @typedef {import('../driver').XCUITestDriver} XCUITestDriver
|
|
76
|
-
*/
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type {XCUITestDriver} from '../driver';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Sets the page load timeout using W3C protocol.
|
|
5
|
+
*
|
|
6
|
+
* @param ms - Timeout in milliseconds
|
|
7
|
+
*/
|
|
8
|
+
export async function pageLoadTimeoutW3C(
|
|
9
|
+
this: XCUITestDriver,
|
|
10
|
+
ms: number,
|
|
11
|
+
): Promise<void> {
|
|
12
|
+
await this.setPageLoadTimeout(this.parseTimeoutArgument(ms));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Sets the page load timeout using MJSONWP protocol.
|
|
17
|
+
*
|
|
18
|
+
* @param ms - Timeout in milliseconds
|
|
19
|
+
*/
|
|
20
|
+
export async function pageLoadTimeoutMJSONWP(
|
|
21
|
+
this: XCUITestDriver,
|
|
22
|
+
ms: number,
|
|
23
|
+
): Promise<void> {
|
|
24
|
+
await this.setPageLoadTimeout(this.parseTimeoutArgument(ms));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Sets the async script timeout using W3C protocol.
|
|
29
|
+
*
|
|
30
|
+
* @param ms - Timeout in milliseconds
|
|
31
|
+
*/
|
|
32
|
+
export async function scriptTimeoutW3C(
|
|
33
|
+
this: XCUITestDriver,
|
|
34
|
+
ms: number,
|
|
35
|
+
): Promise<void> {
|
|
36
|
+
// XXX: this is synchronous
|
|
37
|
+
await this.setAsyncScriptTimeout(this.parseTimeoutArgument(ms));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Alias for {@linkcode XCUITestDriver.scriptTimeoutW3C}.
|
|
42
|
+
*
|
|
43
|
+
* @param ms - The timeout in milliseconds
|
|
44
|
+
* @deprecated Use {@linkcode XCUITestDriver.scriptTimeoutW3C} instead
|
|
45
|
+
*/
|
|
46
|
+
export async function scriptTimeoutMJSONWP(
|
|
47
|
+
this: XCUITestDriver,
|
|
48
|
+
ms: number,
|
|
49
|
+
): Promise<void> {
|
|
50
|
+
await this.asyncScriptTimeout(ms);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Alias for {@linkcode XCUITestDriver.scriptTimeoutW3C}.
|
|
55
|
+
*
|
|
56
|
+
* @param ms - The timeout in milliseconds
|
|
57
|
+
* @deprecated Use {@linkcode XCUITestDriver.scriptTimeoutW3C} instead
|
|
58
|
+
*/
|
|
59
|
+
export async function asyncScriptTimeout(
|
|
60
|
+
this: XCUITestDriver,
|
|
61
|
+
ms: number,
|
|
62
|
+
): Promise<void> {
|
|
63
|
+
await this.scriptTimeoutW3C(ms);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Sets the page load timeout.
|
|
68
|
+
*
|
|
69
|
+
* @param ms - Timeout in milliseconds
|
|
70
|
+
*/
|
|
71
|
+
export function setPageLoadTimeout(
|
|
72
|
+
this: XCUITestDriver,
|
|
73
|
+
ms: number,
|
|
74
|
+
): void {
|
|
75
|
+
ms = parseInt(String(ms), 10);
|
|
76
|
+
this.pageLoadMs = ms;
|
|
77
|
+
if (this._remote) {
|
|
78
|
+
this.remote.pageLoadMs = ms;
|
|
79
|
+
}
|
|
80
|
+
this.log.debug(`Set page load timeout to ${ms}ms`);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Sets the async script timeout.
|
|
85
|
+
*
|
|
86
|
+
* @param ms - Timeout in milliseconds
|
|
87
|
+
*/
|
|
88
|
+
export function setAsyncScriptTimeout(
|
|
89
|
+
this: XCUITestDriver,
|
|
90
|
+
ms: number,
|
|
91
|
+
): void {
|
|
92
|
+
this.asyncWaitMs = ms;
|
|
93
|
+
this.log.debug(`Set async script timeout to ${ms}ms`);
|
|
94
|
+
}
|
|
95
|
+
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "appium-xcuitest-driver",
|
|
3
|
-
"version": "10.14.
|
|
3
|
+
"version": "10.14.4",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "appium-xcuitest-driver",
|
|
9
|
-
"version": "10.14.
|
|
9
|
+
"version": "10.14.4",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@appium/strongbox": "^1.0.0-rc.1",
|
|
@@ -692,9 +692,9 @@
|
|
|
692
692
|
}
|
|
693
693
|
},
|
|
694
694
|
"node_modules/appium-ios-remotexpc": {
|
|
695
|
-
"version": "0.
|
|
696
|
-
"resolved": "https://registry.npmjs.org/appium-ios-remotexpc/-/appium-ios-remotexpc-0.
|
|
697
|
-
"integrity": "sha512-
|
|
695
|
+
"version": "0.24.1",
|
|
696
|
+
"resolved": "https://registry.npmjs.org/appium-ios-remotexpc/-/appium-ios-remotexpc-0.24.1.tgz",
|
|
697
|
+
"integrity": "sha512-LJ83A/cHx+CFOX9yGLoG+bsfgYiJdN1PSBDDe7FkZ/C6DGTi+5zvDxOwaBSLmhgEh6uae40EGK8/FbFiKwR4Kg==",
|
|
698
698
|
"license": "Apache-2.0",
|
|
699
699
|
"optional": true,
|
|
700
700
|
"dependencies": {
|
package/package.json
CHANGED
package/lib/commands/alert.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @this {XCUITestDriver}
|
|
3
|
-
*/
|
|
4
|
-
export async function getAlertText() {
|
|
5
|
-
return /** @type {string|null} */ (await this.proxyCommand('/alert/text', 'GET'));
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @param {string} value
|
|
10
|
-
* @this {XCUITestDriver}
|
|
11
|
-
* @returns {Promise<void>}
|
|
12
|
-
*/
|
|
13
|
-
export async function setAlertText(value) {
|
|
14
|
-
await this.proxyCommand('/alert/text', 'POST', {value});
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @param { {buttonLabel?: string} } opts
|
|
19
|
-
* @returns {Promise<void>}
|
|
20
|
-
* @this {XCUITestDriver}
|
|
21
|
-
*/
|
|
22
|
-
export async function postAcceptAlert(opts = {}) {
|
|
23
|
-
await this.proxyCommand('/alert/accept', 'POST', toAlertParams(opts));
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* @param { {buttonLabel?: string} } opts
|
|
28
|
-
* @returns {Promise<void>}
|
|
29
|
-
* @this {XCUITestDriver}
|
|
30
|
-
*/
|
|
31
|
-
export async function postDismissAlert(opts = {}) {
|
|
32
|
-
await this.proxyCommand('/alert/dismiss', 'POST', toAlertParams(opts));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @internal
|
|
37
|
-
* @this {XCUITestDriver}
|
|
38
|
-
* @returns {Promise<string[]>} The list of button labels
|
|
39
|
-
*/
|
|
40
|
-
export async function getAlertButtons() {
|
|
41
|
-
return /** @type {string[]} */ (await this.proxyCommand('/wda/alert/buttons', 'GET'));
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Tries to apply the given action to the currently visible alert.
|
|
46
|
-
*
|
|
47
|
-
* @param {AlertAction} action - The actual action to apply.
|
|
48
|
-
* @param {string} [buttonLabel] - The name of the button used to perform the chosen alert action. Only makes sense if the action is `accept` or `dismiss`.
|
|
49
|
-
* @returns {Promise<string[]|void>} If `action` is `getButtons`, a list of alert button labelsp; otherwise nothing.
|
|
50
|
-
* @remarks This should really be separate commands.
|
|
51
|
-
* @this {XCUITestDriver}
|
|
52
|
-
*/
|
|
53
|
-
export async function mobileHandleAlert(action, buttonLabel) {
|
|
54
|
-
switch (action) {
|
|
55
|
-
case 'accept':
|
|
56
|
-
return await this.postAcceptAlert({buttonLabel});
|
|
57
|
-
case 'dismiss':
|
|
58
|
-
return await this.postDismissAlert({buttonLabel});
|
|
59
|
-
case 'getButtons':
|
|
60
|
-
return await this.getAlertButtons();
|
|
61
|
-
default:
|
|
62
|
-
throw new Error(
|
|
63
|
-
`The 'action' value should be either 'accept', 'dismiss' or 'getButtons'. ` +
|
|
64
|
-
`'${action}' is provided instead.`,
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
*
|
|
71
|
-
* @param { {buttonLabel?: string} } opts
|
|
72
|
-
* @returns { {name?: string} }
|
|
73
|
-
*/
|
|
74
|
-
function toAlertParams(opts = {}) {
|
|
75
|
-
const params = {};
|
|
76
|
-
if (opts.buttonLabel) {
|
|
77
|
-
params.name = opts.buttonLabel;
|
|
78
|
-
}
|
|
79
|
-
return params;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* @typedef {'accept'|'dismiss'|'getButtons'} AlertAction
|
|
84
|
-
*/
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* @typedef {import('../driver').XCUITestDriver} XCUITestDriver
|
|
88
|
-
*/
|