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
package/lib/commands/execute.js
CHANGED
|
@@ -3,6 +3,78 @@ import {XCUITestDriver} from '../driver';
|
|
|
3
3
|
import {errors, errorFromCode, errorFromW3CJsonCode} from 'appium/driver';
|
|
4
4
|
import {util} from 'appium/support';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Collect the response of an async script execution
|
|
8
|
+
* @this {XCUITestDriver}
|
|
9
|
+
* @deprecated
|
|
10
|
+
* @privateRemarks It's unclear what this is for. Don't use it.
|
|
11
|
+
*/
|
|
12
|
+
export async function receiveAsyncResponse(status, value) {
|
|
13
|
+
this.log.debug(`Received async response: ${JSON.stringify(value)}`);
|
|
14
|
+
if (!util.hasValue(this.asyncPromise)) {
|
|
15
|
+
this.log.warn(
|
|
16
|
+
`Received async response when we were not expecting one! ` +
|
|
17
|
+
`Response was: ${JSON.stringify(value)}`,
|
|
18
|
+
);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (util.hasValue(status) && status !== 0) {
|
|
23
|
+
// MJSONWP
|
|
24
|
+
return this.asyncPromise.reject(errorFromCode(status, value.message));
|
|
25
|
+
}
|
|
26
|
+
if (!util.hasValue(status) && value && _.isString(value.error)) {
|
|
27
|
+
// W3C
|
|
28
|
+
return this.asyncPromise.reject(
|
|
29
|
+
errorFromW3CJsonCode(value.error, value.message, value.stacktrace),
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
return this.asyncPromise.resolve(value);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @template {ExecuteMethodArgs} [TArgs = unknown[]]
|
|
37
|
+
* @template [TReturn = unknown]
|
|
38
|
+
* @param {string} script - Either a script to run, or in the case of an Execute Method, the name of the script to execute.
|
|
39
|
+
* @param {TArgs} [args]
|
|
40
|
+
* @this {XCUITestDriver}
|
|
41
|
+
* @returns {Promise<TReturn>}
|
|
42
|
+
*/
|
|
43
|
+
export async function execute(script, args) {
|
|
44
|
+
// TODO: create a type that converts args to the parameters of the associated method using the `command` prop of `executeMethodMap`
|
|
45
|
+
script = script.trim().replace(/^mobile:\s*/, 'mobile: ');
|
|
46
|
+
if (isExecuteMethod(script)) {
|
|
47
|
+
const executeMethodArgs = preprocessExecuteMethodArgs(script, args);
|
|
48
|
+
return await this.executeMethod(script, [executeMethodArgs]);
|
|
49
|
+
} else if (this.isWebContext()) {
|
|
50
|
+
const atomsArgs = this.convertElementsForAtoms(/** @type {readonly any[]} */ (args));
|
|
51
|
+
const result = await this.executeAtom('execute_script', [script, atomsArgs]);
|
|
52
|
+
return this.cacheWebElements(result);
|
|
53
|
+
} else {
|
|
54
|
+
throw new errors.NotImplementedError();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @this {XCUITestDriver}
|
|
60
|
+
* @group Mobile Web Only
|
|
61
|
+
*/
|
|
62
|
+
export async function executeAsync(script, args) {
|
|
63
|
+
if (!this.isWebContext()) {
|
|
64
|
+
throw new errors.NotImplementedError();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
args = this.convertElementsForAtoms(args);
|
|
68
|
+
this.asyncWaitMs = this.asyncWaitMs || 0;
|
|
69
|
+
const promise = (/** @type {import('appium-remote-debugger').RemoteDebugger} */ (this.remote)).executeAtomAsync(
|
|
70
|
+
'execute_async_script',
|
|
71
|
+
[script, args, this.asyncWaitMs],
|
|
72
|
+
this.curWebFrames,
|
|
73
|
+
);
|
|
74
|
+
return this.cacheWebElements(await this.waitForAtom(promise));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
6
78
|
/**
|
|
7
79
|
* Checks if script expects a particular parameter (either optional or required).
|
|
8
80
|
* @template {keyof XCUITestDriver.executeMethodMap} Script
|
|
@@ -71,78 +143,6 @@ function preprocessExecuteMethodArgs(script, args) {
|
|
|
71
143
|
return executeMethodArgs;
|
|
72
144
|
}
|
|
73
145
|
|
|
74
|
-
export default {
|
|
75
|
-
/**
|
|
76
|
-
* Collect the response of an async script execution
|
|
77
|
-
* @this {XCUITestDriver}
|
|
78
|
-
* @deprecated
|
|
79
|
-
* @privateRemarks It's unclear what this is for. Don't use it.
|
|
80
|
-
*/
|
|
81
|
-
async receiveAsyncResponse(status, value) {
|
|
82
|
-
this.log.debug(`Received async response: ${JSON.stringify(value)}`);
|
|
83
|
-
if (!util.hasValue(this.asyncPromise)) {
|
|
84
|
-
this.log.warn(
|
|
85
|
-
`Received async response when we were not expecting one! ` +
|
|
86
|
-
`Response was: ${JSON.stringify(value)}`,
|
|
87
|
-
);
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (util.hasValue(status) && status !== 0) {
|
|
92
|
-
// MJSONWP
|
|
93
|
-
return this.asyncPromise.reject(errorFromCode(status, value.message));
|
|
94
|
-
}
|
|
95
|
-
if (!util.hasValue(status) && value && _.isString(value.error)) {
|
|
96
|
-
// W3C
|
|
97
|
-
return this.asyncPromise.reject(
|
|
98
|
-
errorFromW3CJsonCode(value.error, value.message, value.stacktrace),
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
return this.asyncPromise.resolve(value);
|
|
102
|
-
},
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* @template {ExecuteMethodArgs} [TArgs = unknown[]]
|
|
106
|
-
* @template [TReturn = unknown]
|
|
107
|
-
* @param {string} script - Either a script to run, or in the case of an Execute Method, the name of the script to execute.
|
|
108
|
-
* @param {TArgs} [args]
|
|
109
|
-
* @this {XCUITestDriver}
|
|
110
|
-
* @returns {Promise<TReturn>}
|
|
111
|
-
*/
|
|
112
|
-
async execute(script, args) {
|
|
113
|
-
// TODO: create a type that converts args to the parameters of the associated method using the `command` prop of `executeMethodMap`
|
|
114
|
-
script = script.trim().replace(/^mobile:\s*/, 'mobile: ');
|
|
115
|
-
if (isExecuteMethod(script)) {
|
|
116
|
-
const executeMethodArgs = preprocessExecuteMethodArgs(script, args);
|
|
117
|
-
return await this.executeMethod(script, [executeMethodArgs]);
|
|
118
|
-
} else if (this.isWebContext()) {
|
|
119
|
-
const atomsArgs = this.convertElementsForAtoms(/** @type {readonly any[]} */ (args));
|
|
120
|
-
const result = await this.executeAtom('execute_script', [script, atomsArgs]);
|
|
121
|
-
return this.cacheWebElements(result);
|
|
122
|
-
} else {
|
|
123
|
-
throw new errors.NotImplementedError();
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
/**
|
|
127
|
-
* @this {XCUITestDriver}
|
|
128
|
-
* @group Mobile Web Only
|
|
129
|
-
*/
|
|
130
|
-
async executeAsync(script, args) {
|
|
131
|
-
if (!this.isWebContext()) {
|
|
132
|
-
throw new errors.NotImplementedError();
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
args = this.convertElementsForAtoms(args);
|
|
136
|
-
this.asyncWaitMs = this.asyncWaitMs || 0;
|
|
137
|
-
const promise = (/** @type {import('appium-remote-debugger').RemoteDebugger} */ (this.remote)).executeAtomAsync(
|
|
138
|
-
'execute_async_script',
|
|
139
|
-
[script, args, this.asyncWaitMs],
|
|
140
|
-
this.curWebFrames,
|
|
141
|
-
);
|
|
142
|
-
return this.cacheWebElements(await this.waitForAtom(promise));
|
|
143
|
-
},
|
|
144
|
-
};
|
|
145
|
-
|
|
146
146
|
/**
|
|
147
147
|
* @template [T=any]
|
|
148
148
|
* @typedef {import('@appium/types').StringRecord<T>} StringRecord
|
|
@@ -2,7 +2,7 @@ import _ from 'lodash';
|
|
|
2
2
|
import {fs, tempDir, mkdirp, zip, util} from 'appium/support';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import {services} from 'appium-ios-device';
|
|
5
|
-
import {pullFile, pullFolder, pushFile} from '../ios-fs-helpers';
|
|
5
|
+
import {pullFile as iosPullFile, pullFolder as iosPullFolder, pushFile as iosPushFile} from '../ios-fs-helpers';
|
|
6
6
|
import {errors} from 'appium/driver';
|
|
7
7
|
|
|
8
8
|
const CONTAINER_PATH_MARKER = '@';
|
|
@@ -192,7 +192,7 @@ async function pushFileToSimulator(remotePath, base64Data) {
|
|
|
192
192
|
async function pushFileToRealDevice(remotePath, base64Data) {
|
|
193
193
|
const {service, relativePath} = await createService.bind(this)(remotePath);
|
|
194
194
|
try {
|
|
195
|
-
await
|
|
195
|
+
await iosPushFile(service, Buffer.from(base64Data, 'base64'), relativePath);
|
|
196
196
|
} catch (e) {
|
|
197
197
|
this.log.debug(e.stack);
|
|
198
198
|
throw new Error(`Could not push the file to '${remotePath}'. Original error: ${e.message}`);
|
|
@@ -291,8 +291,8 @@ async function pullFromRealDevice(remotePath, isFile) {
|
|
|
291
291
|
}
|
|
292
292
|
|
|
293
293
|
return fileInfo.isFile()
|
|
294
|
-
? (await
|
|
295
|
-
: (await
|
|
294
|
+
? (await iosPullFile(service, relativePath)).toString('base64')
|
|
295
|
+
: (await iosPullFolder(service, relativePath)).toString();
|
|
296
296
|
} finally {
|
|
297
297
|
service.close();
|
|
298
298
|
}
|
|
@@ -369,143 +369,141 @@ async function deleteFromRealDevice(remotePath) {
|
|
|
369
369
|
}
|
|
370
370
|
}
|
|
371
371
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
`
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
},
|
|
372
|
+
/**
|
|
373
|
+
* Pushes the given data to a file on the remote device
|
|
374
|
+
*
|
|
375
|
+
* @param {string} remotePath The full path to the remote file or
|
|
376
|
+
* a file inside a package bundle. Check the documentation on
|
|
377
|
+
* `pushFileToRealDevice` and `pushFileToSimulator` for more information
|
|
378
|
+
* on acceptable values.
|
|
379
|
+
* @param {string} base64Data Base64 encoded data to be written to the
|
|
380
|
+
* remote file. The remote file will be silently overridden if it already exists.
|
|
381
|
+
* @throws {Error} If there was an error while pushing the data
|
|
382
|
+
* @this {XCUITestDriver}
|
|
383
|
+
*/
|
|
384
|
+
export async function pushFile(remotePath, base64Data) {
|
|
385
|
+
if (remotePath.endsWith('/')) {
|
|
386
|
+
throw new errors.InvalidArgumentError(
|
|
387
|
+
`It is expected that remote path points to a file and not to a folder. ` +
|
|
388
|
+
`'${remotePath}' is given instead`,
|
|
389
|
+
);
|
|
390
|
+
}
|
|
391
|
+
if (_.isArray(base64Data)) {
|
|
392
|
+
// some clients (ahem) java, send a byte array encoding utf8 characters
|
|
393
|
+
// instead of a string, which would be infinitely better!
|
|
394
|
+
base64Data = Buffer.from(base64Data).toString('utf8');
|
|
395
|
+
}
|
|
396
|
+
return this.isSimulator()
|
|
397
|
+
? await pushFileToSimulator.bind(this)(remotePath, base64Data)
|
|
398
|
+
: await pushFileToRealDevice.bind(this)(remotePath, base64Data);
|
|
399
|
+
}
|
|
401
400
|
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
401
|
+
/**
|
|
402
|
+
* Pushes the given data to a file on the remote device.
|
|
403
|
+
*
|
|
404
|
+
* @param {string} remotePath - The full path to the remote file
|
|
405
|
+
* or a specially formatted path, which points to an item inside an app bundle.
|
|
406
|
+
* @param {string} payload - Base64-encoded content of the file to be pushed.
|
|
407
|
+
* @this {XCUITestDriver}
|
|
408
|
+
*/
|
|
409
|
+
export async function mobilePushFile(remotePath, payload) {
|
|
410
|
+
return await this.pushFile(remotePath, payload);
|
|
411
|
+
}
|
|
413
412
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
413
|
+
/**
|
|
414
|
+
* Pulls a remote file from the device.
|
|
415
|
+
*
|
|
416
|
+
* @param {string} remotePath The full path to the remote file
|
|
417
|
+
* or a specially formatted path, which points to an item inside app bundle.
|
|
418
|
+
* See the documentation for `pullFromRealDevice` and `pullFromSimulator`
|
|
419
|
+
* to get more information on acceptable values.
|
|
420
|
+
* @returns {Promise<string>} Base64 encoded content of the pulled file
|
|
421
|
+
* @throws {Error} If the pull operation failed
|
|
422
|
+
* @this {XCUITestDriver}
|
|
423
|
+
*/
|
|
424
|
+
export async function pullFile(remotePath) {
|
|
425
|
+
if (remotePath.endsWith('/')) {
|
|
426
|
+
throw new errors.InvalidArgumentError(
|
|
427
|
+
`It is expected that remote path points to a file and not to a folder. ` +
|
|
428
|
+
`'${remotePath}' is given instead`,
|
|
429
|
+
);
|
|
430
|
+
}
|
|
431
|
+
return this.isSimulator()
|
|
432
|
+
? await pullFromSimulator.bind(this)(remotePath, true)
|
|
433
|
+
: await pullFromRealDevice.bind(this)(remotePath, true);
|
|
434
|
+
}
|
|
436
435
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
436
|
+
/**
|
|
437
|
+
* Pulls a remote file from the device.
|
|
438
|
+
*
|
|
439
|
+
* @param {string} remotePath - The full path to the remote file
|
|
440
|
+
* or a specially formatted path, which points to an item inside app bundle. See the documentation for `pullFromRealDevice` and `pullFromSimulator` to get more information on acceptable values.
|
|
441
|
+
* @returns {Promise<string>} The same as in `pullFile`
|
|
442
|
+
* @this {XCUITestDriver}
|
|
443
|
+
*/
|
|
444
|
+
export async function mobilePullFile(remotePath) {
|
|
445
|
+
return await this.pullFile(remotePath);
|
|
446
|
+
}
|
|
448
447
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
448
|
+
/**
|
|
449
|
+
* Delete a remote folder from the device.
|
|
450
|
+
*
|
|
451
|
+
* @param {string} remotePath - The full path to the remote folder or a specially formatted path, which points to an item inside app bundle. See the documentation for `pullFromRealDevice` and `pullFromSimulator` to get more information on acceptable values.
|
|
452
|
+
* @this {XCUITestDriver}
|
|
453
|
+
* @returns {Promise<void>}
|
|
454
|
+
*/
|
|
455
|
+
export async function mobileDeleteFolder(remotePath) {
|
|
456
|
+
if (!remotePath.endsWith('/')) {
|
|
457
|
+
remotePath = `${remotePath}/`;
|
|
458
|
+
}
|
|
459
|
+
await deleteFileOrFolder.bind(this)(remotePath);
|
|
460
|
+
}
|
|
462
461
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
462
|
+
/**
|
|
463
|
+
* Delete a remote file from the device.
|
|
464
|
+
*
|
|
465
|
+
* @param {string} remotePath - The full path to the remote file or a specially formatted path, which points to an item inside app bundle. See the documentation for `pullFromRealDevice` and `pullFromSimulator` to get more information on acceptable values.
|
|
466
|
+
* @this {XCUITestDriver}
|
|
467
|
+
* @returns {Promise<void>}
|
|
468
|
+
*/
|
|
469
|
+
export async function mobileDeleteFile(remotePath) {
|
|
470
|
+
if (remotePath.endsWith('/')) {
|
|
471
|
+
throw new errors.InvalidArgumentError(
|
|
472
|
+
`It is expected that remote path points to a file and not to a folder. ` +
|
|
473
|
+
`'${remotePath}' is given instead`,
|
|
474
|
+
);
|
|
475
|
+
}
|
|
476
|
+
await deleteFileOrFolder.bind(this)(remotePath);
|
|
477
|
+
}
|
|
479
478
|
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
479
|
+
/**
|
|
480
|
+
* Pulls the whole folder from the remote device
|
|
481
|
+
*
|
|
482
|
+
* @param {string} remotePath The full path to a folder on the
|
|
483
|
+
* remote device or a folder inside an application bundle
|
|
484
|
+
* @returns {Promise<string>} Zipped and base64-encoded content of the folder
|
|
485
|
+
* @throws {Error} If there was a failure while getting the folder content
|
|
486
|
+
* @this {XCUITestDriver}
|
|
487
|
+
*/
|
|
488
|
+
export async function pullFolder(remotePath) {
|
|
489
|
+
if (!remotePath.endsWith('/')) {
|
|
490
|
+
remotePath = `${remotePath}/`;
|
|
491
|
+
}
|
|
492
|
+
return this.isSimulator()
|
|
493
|
+
? await pullFromSimulator.bind(this)(remotePath, false)
|
|
494
|
+
: await pullFromRealDevice.bind(this)(remotePath, false);
|
|
495
|
+
}
|
|
497
496
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
};
|
|
497
|
+
/**
|
|
498
|
+
* Pulls the whole folder from the device under test.
|
|
499
|
+
*
|
|
500
|
+
* @param {string} remotePath - The full path to the remote folder
|
|
501
|
+
* @returns {Promise<string>} The same as `pullFolder`
|
|
502
|
+
* @this {XCUITestDriver}
|
|
503
|
+
*/
|
|
504
|
+
export async function mobilePullFolder(remotePath) {
|
|
505
|
+
return await this.pullFolder(remotePath);
|
|
506
|
+
}
|
|
509
507
|
|
|
510
508
|
/**
|
|
511
509
|
* @typedef {import('../driver').XCUITestDriver} XCUITestDriver
|