appium-mac2-driver 3.2.3 → 3.2.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 +7 -0
- package/build/lib/commands/app-management.d.ts +18 -21
- package/build/lib/commands/app-management.d.ts.map +1 -1
- package/build/lib/commands/app-management.js +14 -25
- package/build/lib/commands/app-management.js.map +1 -1
- package/build/lib/commands/applescript.d.ts +8 -9
- package/build/lib/commands/applescript.d.ts.map +1 -1
- package/build/lib/commands/applescript.js +14 -13
- package/build/lib/commands/applescript.js.map +1 -1
- package/build/lib/commands/execute.d.ts +5 -8
- package/build/lib/commands/execute.d.ts.map +1 -1
- package/build/lib/commands/execute.js +5 -13
- package/build/lib/commands/execute.js.map +1 -1
- package/build/lib/commands/find.d.ts +6 -8
- package/build/lib/commands/find.d.ts.map +1 -1
- package/build/lib/commands/find.js +8 -13
- package/build/lib/commands/find.js.map +1 -1
- package/build/lib/commands/gestures.d.ts +105 -118
- package/build/lib/commands/gestures.d.ts.map +1 -1
- package/build/lib/commands/gestures.js +141 -154
- package/build/lib/commands/gestures.js.map +1 -1
- package/build/lib/commands/navigation.d.ts +4 -6
- package/build/lib/commands/navigation.d.ts.map +1 -1
- package/build/lib/commands/navigation.js +2 -8
- package/build/lib/commands/navigation.js.map +1 -1
- package/build/lib/commands/record-screen.d.ts +57 -98
- package/build/lib/commands/record-screen.d.ts.map +1 -1
- package/build/lib/commands/record-screen.js +81 -84
- package/build/lib/commands/record-screen.js.map +1 -1
- package/build/lib/commands/screenshots.d.ts +5 -5
- package/build/lib/commands/screenshots.d.ts.map +1 -1
- package/build/lib/commands/screenshots.js +3 -8
- package/build/lib/commands/screenshots.js.map +1 -1
- package/build/lib/commands/source.d.ts +4 -5
- package/build/lib/commands/source.d.ts.map +1 -1
- package/build/lib/commands/source.js +3 -8
- package/build/lib/commands/source.js.map +1 -1
- package/lib/commands/app-management.ts +88 -0
- package/lib/commands/{applescript.js → applescript.ts} +28 -24
- package/lib/commands/execute.ts +32 -0
- package/lib/commands/find.ts +34 -0
- package/lib/commands/{gestures.js → gestures.ts} +333 -238
- package/lib/commands/navigation.ts +19 -0
- package/lib/commands/{record-screen.js → record-screen.ts} +165 -138
- package/lib/commands/screenshots.ts +18 -0
- package/lib/commands/{source.js → source.ts} +10 -11
- package/npm-shrinkwrap.json +5 -5
- package/package.json +1 -1
- package/lib/commands/app-management.js +0 -83
- package/lib/commands/execute.js +0 -33
- package/lib/commands/find.js +0 -31
- package/lib/commands/navigation.js +0 -18
- package/lib/commands/screenshots.js +0 -18
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import { util } from 'appium/support';
|
|
3
3
|
import { errors } from 'appium/driver';
|
|
4
|
+
import type { Mac2Driver } from '../driver';
|
|
5
|
+
import type { KeyOptions } from '../types';
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* Set value to the given element.
|
|
@@ -8,483 +10,574 @@ import { errors } from 'appium/driver';
|
|
|
8
10
|
* This is not exposed as 'macos: setValue' because this is the same as
|
|
9
11
|
* element.send_keys in W3C WebDriver spec.
|
|
10
12
|
*
|
|
11
|
-
* @
|
|
12
|
-
* @param
|
|
13
|
-
* @param
|
|
14
|
-
* @param
|
|
15
|
-
* @param {number} [keyModifierFlags] If set then the given key modifiers will
|
|
13
|
+
* @param elementId - Uuid of the element to set value for.
|
|
14
|
+
* @param value - Value to set. Could also be an array.
|
|
15
|
+
* @param text - Text to set. If both value and text are set then `value` is preferred
|
|
16
|
+
* @param keyModifierFlags - If set then the given key modifiers will
|
|
16
17
|
* be applied while the element value is being set. See
|
|
17
18
|
* https://developer.apple.com/documentation/xctest/xcuikeymodifierflags
|
|
18
19
|
* for more details.
|
|
19
20
|
*/
|
|
20
|
-
export async function macosSetValue
|
|
21
|
+
export async function macosSetValue(
|
|
22
|
+
this: Mac2Driver,
|
|
23
|
+
elementId: string,
|
|
24
|
+
value?: any,
|
|
25
|
+
text?: string,
|
|
26
|
+
keyModifierFlags?: number
|
|
27
|
+
): Promise<unknown> {
|
|
21
28
|
return await this.wda.proxy.command(`/element/${elementId}/value`, 'POST', {
|
|
22
|
-
value,
|
|
29
|
+
value,
|
|
30
|
+
text,
|
|
23
31
|
keyModifierFlags,
|
|
24
32
|
});
|
|
25
|
-
}
|
|
26
|
-
|
|
33
|
+
}
|
|
27
34
|
|
|
28
35
|
/**
|
|
29
36
|
* Perform click gesture on an element or by relative/absolute coordinates
|
|
30
37
|
*
|
|
31
|
-
* @this
|
|
32
|
-
* @param {string} [elementId] Uuid of the element to click. Either this property
|
|
38
|
+
* @param elementId - Uuid of the element to click. Either this property
|
|
33
39
|
* or/and x and y must be set. If both are set then x and y are
|
|
34
40
|
* considered as relative element coordinates. If only x and y
|
|
35
41
|
* are set then these are parsed as absolute coordinates.
|
|
36
|
-
* @param
|
|
37
|
-
* @param
|
|
38
|
-
* @param
|
|
42
|
+
* @param x - Click X coordinate
|
|
43
|
+
* @param y - Click Y coordinate
|
|
44
|
+
* @param keyModifierFlags - If set then the given key modifiers will be
|
|
39
45
|
* applied while click is performed. See
|
|
40
46
|
* https://developer.apple.com/documentation/xctest/xcuikeymodifierflags
|
|
41
47
|
* for more details
|
|
42
48
|
*/
|
|
43
|
-
export async function macosClick
|
|
49
|
+
export async function macosClick(
|
|
50
|
+
this: Mac2Driver,
|
|
51
|
+
elementId?: string,
|
|
52
|
+
x?: number,
|
|
53
|
+
y?: number,
|
|
54
|
+
keyModifierFlags?: number
|
|
55
|
+
): Promise<unknown> {
|
|
44
56
|
requireElementIdOrXY(elementId, x, y);
|
|
45
57
|
const url = elementId ? `/element/${elementId}/click` : '/wda/click';
|
|
46
58
|
return await this.wda.proxy.command(url, 'POST', {
|
|
47
|
-
x,
|
|
59
|
+
x,
|
|
60
|
+
y,
|
|
48
61
|
keyModifierFlags,
|
|
49
62
|
});
|
|
50
|
-
}
|
|
63
|
+
}
|
|
51
64
|
|
|
52
65
|
/**
|
|
53
66
|
* Perform scroll gesture on an element or by relative/absolute coordinates
|
|
54
67
|
*
|
|
55
|
-
* @
|
|
56
|
-
* @param
|
|
57
|
-
* @param
|
|
58
|
-
* @param {string} [elementId] Uuid of the element to be scrolled. Either this property
|
|
68
|
+
* @param deltaX - Horizontal delta as float number
|
|
69
|
+
* @param deltaY - Vertical delta as float number
|
|
70
|
+
* @param elementId - Uuid of the element to be scrolled. Either this property
|
|
59
71
|
* or/and x and y must be set. If both are set then x and y are
|
|
60
72
|
* considered as relative element coordinates. If only x and y are
|
|
61
73
|
* set then these are parsed as absolute coordinates.
|
|
62
|
-
* @param
|
|
63
|
-
* @param
|
|
64
|
-
* @param
|
|
74
|
+
* @param x - Scroll X coordinate
|
|
75
|
+
* @param y - Scroll Y coordinate
|
|
76
|
+
* @param keyModifierFlags - If set then the given key modifiers will be
|
|
65
77
|
* applied while scroll is performed. See
|
|
66
78
|
* https://developer.apple.com/documentation/xctest/xcuikeymodifierflags
|
|
67
79
|
* for more details
|
|
68
80
|
*/
|
|
69
|
-
export async function macosScroll
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
81
|
+
export async function macosScroll(
|
|
82
|
+
this: Mac2Driver,
|
|
83
|
+
deltaX: number,
|
|
84
|
+
deltaY: number,
|
|
85
|
+
elementId?: string,
|
|
86
|
+
x?: number,
|
|
87
|
+
y?: number,
|
|
88
|
+
keyModifierFlags?: number
|
|
89
|
+
): Promise<unknown> {
|
|
75
90
|
requireElementIdOrXY(elementId, x, y);
|
|
76
91
|
const url = elementId ? `/wda/element/${elementId}/scroll` : '/wda/scroll';
|
|
77
92
|
return await this.wda.proxy.command(url, 'POST', {
|
|
78
|
-
deltaX,
|
|
79
|
-
|
|
93
|
+
deltaX,
|
|
94
|
+
deltaY,
|
|
95
|
+
x,
|
|
96
|
+
y,
|
|
80
97
|
keyModifierFlags,
|
|
81
98
|
});
|
|
82
|
-
}
|
|
99
|
+
}
|
|
83
100
|
|
|
84
101
|
/**
|
|
85
102
|
* Perform swipe gesture on an element
|
|
86
103
|
*
|
|
87
|
-
* @
|
|
88
|
-
* @param
|
|
89
|
-
* @param {string} [elementId] Uuid of the element to be swiped. Either this property
|
|
104
|
+
* @param direction - Swipe direction
|
|
105
|
+
* @param elementId - Uuid of the element to be swiped. Either this property
|
|
90
106
|
* or/and x and y must be set. If both are set then x and y are
|
|
91
107
|
* considered as relative element coordinates. If only x and y are
|
|
92
108
|
* set then these are parsed as absolute coordinates.
|
|
93
|
-
* @param
|
|
94
|
-
* @param
|
|
95
|
-
* @param
|
|
109
|
+
* @param x - Swipe X coordinate
|
|
110
|
+
* @param y - Swipe Y coordinate
|
|
111
|
+
* @param velocity - The value is measured in pixels per second and same
|
|
96
112
|
* values could behave differently on different devices depending
|
|
97
113
|
* on their display density. Higher values make swipe gesture faster
|
|
98
114
|
* (which usually scrolls larger areas if we apply it to a list)
|
|
99
115
|
* and lower values slow it down. Only values greater than zero have effect.
|
|
100
|
-
* @param
|
|
116
|
+
* @param keyModifierFlags - If set then the given key modifiers will be
|
|
101
117
|
* applied while scroll is performed. See
|
|
102
118
|
* https://developer.apple.com/documentation/xctest/xcuikeymodifierflags
|
|
103
119
|
* for more details
|
|
104
120
|
*/
|
|
105
|
-
export async function macosSwipe
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
121
|
+
export async function macosSwipe(
|
|
122
|
+
this: Mac2Driver,
|
|
123
|
+
direction: 'up' | 'down' | 'left' | 'right',
|
|
124
|
+
elementId?: string,
|
|
125
|
+
x?: number,
|
|
126
|
+
y?: number,
|
|
127
|
+
velocity?: number,
|
|
128
|
+
keyModifierFlags?: number
|
|
129
|
+
): Promise<unknown> {
|
|
112
130
|
requireElementIdOrXY(elementId, x, y);
|
|
113
131
|
const url = elementId ? `/wda/element/${elementId}/swipe` : `/wda/swipe`;
|
|
114
132
|
return await this.wda.proxy.command(url, 'POST', {
|
|
115
|
-
x,
|
|
133
|
+
x,
|
|
134
|
+
y,
|
|
116
135
|
direction,
|
|
117
136
|
velocity,
|
|
118
137
|
keyModifierFlags,
|
|
119
138
|
});
|
|
120
|
-
}
|
|
139
|
+
}
|
|
121
140
|
|
|
122
141
|
/**
|
|
123
142
|
* Perform right click gesture on an element or by relative/absolute coordinates
|
|
124
143
|
*
|
|
125
|
-
* @this
|
|
126
|
-
* @param {string} [elementId] Uuid of the element to click. Either this property
|
|
144
|
+
* @param elementId - Uuid of the element to click. Either this property
|
|
127
145
|
* or/and x and y must be set. If both are set then x and y are
|
|
128
146
|
* considered as relative element coordinates. If only x and y
|
|
129
147
|
* are set then these are parsed as absolute coordinates.
|
|
130
|
-
* @param
|
|
131
|
-
* @param
|
|
132
|
-
* @param
|
|
148
|
+
* @param x - Click X coordinate
|
|
149
|
+
* @param y - Click Y coordinate
|
|
150
|
+
* @param keyModifierFlags - If set then the given key modifiers will be
|
|
133
151
|
* applied while click is performed. See
|
|
134
152
|
* https://developer.apple.com/documentation/xctest/xcuikeymodifierflags
|
|
135
153
|
* for more details
|
|
136
154
|
*/
|
|
137
|
-
export async function macosRightClick
|
|
155
|
+
export async function macosRightClick(
|
|
156
|
+
this: Mac2Driver,
|
|
157
|
+
elementId?: string,
|
|
158
|
+
x?: number,
|
|
159
|
+
y?: number,
|
|
160
|
+
keyModifierFlags?: number
|
|
161
|
+
): Promise<unknown> {
|
|
138
162
|
requireElementIdOrXY(elementId, x, y);
|
|
139
163
|
const url = elementId ? `/wda/element/${elementId}/rightClick` : '/wda/rightClick';
|
|
140
164
|
return await this.wda.proxy.command(url, 'POST', {
|
|
141
|
-
x,
|
|
165
|
+
x,
|
|
166
|
+
y,
|
|
142
167
|
keyModifierFlags,
|
|
143
168
|
});
|
|
144
|
-
}
|
|
169
|
+
}
|
|
145
170
|
|
|
146
171
|
/**
|
|
147
172
|
* Perform hover gesture on an element or by relative/absolute coordinates
|
|
148
173
|
*
|
|
149
|
-
* @this
|
|
150
|
-
* @param {string} [elementId] Uuid of the element to hover. Either this property
|
|
174
|
+
* @param elementId - Uuid of the element to hover. Either this property
|
|
151
175
|
* or/and x and y must be set. If both are set then x and y are
|
|
152
176
|
* considered as relative element coordinates. If only x and y
|
|
153
177
|
* are set then these are parsed as absolute coordinates.
|
|
154
|
-
* @param
|
|
155
|
-
* @param
|
|
156
|
-
* @param
|
|
178
|
+
* @param x - Click X coordinate
|
|
179
|
+
* @param y - Click Y coordinate
|
|
180
|
+
* @param keyModifierFlags - If set then the given key modifiers will be
|
|
157
181
|
* applied while click is performed. See
|
|
158
182
|
* https://developer.apple.com/documentation/xctest/xcuikeymodifierflags
|
|
159
183
|
* for more details
|
|
160
184
|
*/
|
|
161
|
-
export async function macosHover
|
|
185
|
+
export async function macosHover(
|
|
186
|
+
this: Mac2Driver,
|
|
187
|
+
elementId?: string,
|
|
188
|
+
x?: number,
|
|
189
|
+
y?: number,
|
|
190
|
+
keyModifierFlags?: number
|
|
191
|
+
): Promise<unknown> {
|
|
162
192
|
requireElementIdOrXY(elementId, x, y);
|
|
163
193
|
const url = elementId ? `/wda/element/${elementId}/hover` : '/wda/hover';
|
|
164
194
|
return await this.wda.proxy.command(url, 'POST', {
|
|
165
|
-
x,
|
|
195
|
+
x,
|
|
196
|
+
y,
|
|
166
197
|
keyModifierFlags,
|
|
167
198
|
});
|
|
168
|
-
}
|
|
199
|
+
}
|
|
169
200
|
|
|
170
201
|
/**
|
|
171
202
|
* Perform double click gesture on an element or by relative/absolute coordinates
|
|
172
203
|
*
|
|
173
|
-
* @this
|
|
174
|
-
* @param {string} [elementId] Uuid of the element to hover. Either this property
|
|
204
|
+
* @param elementId - Uuid of the element to hover. Either this property
|
|
175
205
|
* or/and x and y must be set. If both are set then x and y are
|
|
176
206
|
* considered as relative element coordinates. If only x and y
|
|
177
207
|
* are set then these are parsed as absolute coordinates.
|
|
178
|
-
* @param
|
|
179
|
-
* @param
|
|
180
|
-
* @param
|
|
208
|
+
* @param x - Click X coordinate
|
|
209
|
+
* @param y - Click Y coordinate
|
|
210
|
+
* @param keyModifierFlags - If set then the given key modifiers will be
|
|
181
211
|
* applied while click is performed. See
|
|
182
212
|
* https://developer.apple.com/documentation/xctest/xcuikeymodifierflags
|
|
183
213
|
* for more details
|
|
184
214
|
*/
|
|
185
|
-
export async function macosDoubleClick
|
|
215
|
+
export async function macosDoubleClick(
|
|
216
|
+
this: Mac2Driver,
|
|
217
|
+
elementId?: string,
|
|
218
|
+
x?: number,
|
|
219
|
+
y?: number,
|
|
220
|
+
keyModifierFlags?: number
|
|
221
|
+
): Promise<unknown> {
|
|
186
222
|
requireElementIdOrXY(elementId, x, y);
|
|
187
223
|
const url = elementId ? `/wda/element/${elementId}/doubleClick` : '/wda/doubleClick';
|
|
188
224
|
return await this.wda.proxy.command(url, 'POST', {
|
|
189
|
-
x,
|
|
225
|
+
x,
|
|
226
|
+
y,
|
|
190
227
|
keyModifierFlags,
|
|
191
228
|
});
|
|
192
|
-
}
|
|
229
|
+
}
|
|
193
230
|
|
|
194
231
|
/**
|
|
195
232
|
* Perform long click and drag gesture on an element or by absolute coordinates
|
|
196
233
|
*
|
|
197
|
-
* @
|
|
198
|
-
* @param
|
|
199
|
-
* @param {string} [sourceElementId] Uuid of the element to start the drag from.
|
|
234
|
+
* @param duration - Long click duration in float seconds
|
|
235
|
+
* @param sourceElementId - Uuid of the element to start the drag from.
|
|
200
236
|
* Either this property and `destinationElement` must be provided
|
|
201
237
|
* or `startX`, `startY`, `endX`, `endY` coordinates must be set.
|
|
202
|
-
* @param
|
|
238
|
+
* @param destinationElementId - Uuid of the element to end the drag on.
|
|
203
239
|
* Either this property and `sourceElement` must be provided or
|
|
204
240
|
* `startX`, `startY`, `endX`, `endY` coordinatesmust be set.
|
|
205
|
-
* @param
|
|
206
|
-
* @param
|
|
207
|
-
* @param
|
|
208
|
-
* @param
|
|
209
|
-
* @param
|
|
241
|
+
* @param startX - Starting X coordinate
|
|
242
|
+
* @param startY - Starting Y coordinate
|
|
243
|
+
* @param endX - Ending X coordinate
|
|
244
|
+
* @param endY - Ending Y coordinate
|
|
245
|
+
* @param keyModifierFlags - If set then the given key modifiers will be
|
|
210
246
|
* applied while drag is performed. See
|
|
211
247
|
* https://developer.apple.com/documentation/xctest/xcuikeymodifierflags
|
|
212
248
|
* for more details
|
|
213
249
|
*/
|
|
214
|
-
export async function macosClickAndDrag
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
250
|
+
export async function macosClickAndDrag(
|
|
251
|
+
this: Mac2Driver,
|
|
252
|
+
duration: number,
|
|
253
|
+
sourceElementId?: string,
|
|
254
|
+
destinationElementId?: string,
|
|
255
|
+
startX?: number,
|
|
256
|
+
startY?: number,
|
|
257
|
+
endX?: number,
|
|
258
|
+
endY?: number,
|
|
259
|
+
keyModifierFlags?: number
|
|
260
|
+
): Promise<unknown> {
|
|
222
261
|
requireSourceDestWithElementsOrCoordinates(
|
|
223
|
-
sourceElementId,
|
|
224
|
-
|
|
262
|
+
sourceElementId,
|
|
263
|
+
destinationElementId,
|
|
264
|
+
startX,
|
|
265
|
+
startY,
|
|
266
|
+
endX,
|
|
267
|
+
endY
|
|
225
268
|
);
|
|
226
|
-
const url =
|
|
227
|
-
|
|
228
|
-
|
|
269
|
+
const url =
|
|
270
|
+
sourceElementId && destinationElementId
|
|
271
|
+
? `/wda/element/${sourceElementId}/clickAndDrag`
|
|
272
|
+
: '/wda/clickAndDrag';
|
|
229
273
|
const dest = destinationElementId && util.wrapElement(destinationElementId);
|
|
230
274
|
return await this.wda.proxy.command(url, 'POST', {
|
|
231
|
-
startX,
|
|
232
|
-
|
|
275
|
+
startX,
|
|
276
|
+
startY,
|
|
277
|
+
endX,
|
|
278
|
+
endY,
|
|
233
279
|
duration,
|
|
234
280
|
dest,
|
|
235
281
|
keyModifierFlags,
|
|
236
282
|
});
|
|
237
|
-
}
|
|
283
|
+
}
|
|
238
284
|
|
|
239
285
|
/**
|
|
240
286
|
* Perform long click, drag and hold gesture on an element or by absolute coordinates
|
|
241
287
|
*
|
|
242
|
-
* @
|
|
243
|
-
* @param
|
|
244
|
-
* @param
|
|
245
|
-
* @param {string} [sourceElementId] Uuid of the element to start the drag from.
|
|
288
|
+
* @param duration - Long click duration in float seconds
|
|
289
|
+
* @param holdDuration - Touch hold duration in float seconds
|
|
290
|
+
* @param sourceElementId - Uuid of the element to start the drag from.
|
|
246
291
|
* Either this property and `destinationElement` must be provided
|
|
247
292
|
* or `startX`, `startY`, `endX`, `endY` coordinates must be set.
|
|
248
|
-
* @param
|
|
293
|
+
* @param destinationElementId - Uuid of the element to end the drag on.
|
|
249
294
|
* Either this property and `sourceElement` must be provided
|
|
250
295
|
* or `startX`, `startY`, `endX`, `endY` coordinates must be set.
|
|
251
|
-
* @param
|
|
252
|
-
* @param
|
|
253
|
-
* @param
|
|
254
|
-
* @param
|
|
255
|
-
* @param
|
|
296
|
+
* @param startX - Starting X coordinate
|
|
297
|
+
* @param startY - Starting Y coordinate
|
|
298
|
+
* @param endX - Ending X coordinate
|
|
299
|
+
* @param endY - Ending Y coordinate
|
|
300
|
+
* @param velocity - Dragging velocity in pixels per second.
|
|
256
301
|
* If not provided then the default velocity is used. See
|
|
257
302
|
* https://developer.apple.com/documentation/xctest/xcuigesturevelocity
|
|
258
303
|
* for more details
|
|
259
|
-
* @param
|
|
304
|
+
* @param keyModifierFlags - If set then the given key modifiers will be
|
|
260
305
|
* applied while drag is performed. See
|
|
261
306
|
* https://developer.apple.com/documentation/xctest/xcuikeymodifierflags
|
|
262
|
-
* for more details
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
307
|
+
* for more details
|
|
308
|
+
*/
|
|
309
|
+
export async function macosClickAndDragAndHold(
|
|
310
|
+
this: Mac2Driver,
|
|
311
|
+
duration: number,
|
|
312
|
+
holdDuration: number,
|
|
313
|
+
sourceElementId?: string,
|
|
314
|
+
destinationElementId?: string,
|
|
315
|
+
startX?: number,
|
|
316
|
+
startY?: number,
|
|
317
|
+
endX?: number,
|
|
318
|
+
endY?: number,
|
|
319
|
+
velocity?: number,
|
|
320
|
+
keyModifierFlags?: number
|
|
321
|
+
): Promise<unknown> {
|
|
273
322
|
requireSourceDestWithElementsOrCoordinates(
|
|
274
|
-
sourceElementId,
|
|
275
|
-
|
|
323
|
+
sourceElementId,
|
|
324
|
+
destinationElementId,
|
|
325
|
+
startX,
|
|
326
|
+
startY,
|
|
327
|
+
endX,
|
|
328
|
+
endY
|
|
276
329
|
);
|
|
277
|
-
const url =
|
|
278
|
-
|
|
279
|
-
|
|
330
|
+
const url =
|
|
331
|
+
sourceElementId && destinationElementId
|
|
332
|
+
? `/wda/element/${sourceElementId}/clickAndDragAndHold`
|
|
333
|
+
: '/wda/clickAndDragAndHold';
|
|
280
334
|
const dest = destinationElementId && util.wrapElement(destinationElementId);
|
|
281
335
|
return await this.wda.proxy.command(url, 'POST', {
|
|
282
|
-
startX,
|
|
283
|
-
|
|
284
|
-
|
|
336
|
+
startX,
|
|
337
|
+
startY,
|
|
338
|
+
endX,
|
|
339
|
+
endY,
|
|
340
|
+
duration,
|
|
341
|
+
holdDuration,
|
|
285
342
|
velocity,
|
|
286
343
|
dest,
|
|
287
344
|
keyModifierFlags,
|
|
288
345
|
});
|
|
289
|
-
}
|
|
346
|
+
}
|
|
290
347
|
|
|
291
348
|
/**
|
|
292
349
|
* Send keys to the given element or to the application under test
|
|
293
350
|
*
|
|
294
|
-
* @
|
|
295
|
-
* @param {(import('../types').KeyOptions | string)[]} keys Array of keys to type.
|
|
351
|
+
* @param keys - Array of keys to type.
|
|
296
352
|
* Each item could either be a string, that represents a key itself (see
|
|
297
353
|
* https://developer.apple.com/documentation/xctest/xcuielement/1500604-typekey
|
|
298
354
|
* and https://developer.apple.com/documentation/xctest/xcuikeyboardkey)
|
|
299
355
|
* or a dictionary, if the key should also be entered with modifiers.
|
|
300
|
-
* @param
|
|
356
|
+
* @param elementId - Uuid of the element to send the keys to.
|
|
301
357
|
* If unset then keys are sent to the current application
|
|
302
358
|
* under test.
|
|
303
359
|
*/
|
|
304
|
-
export async function macosKeys
|
|
360
|
+
export async function macosKeys(
|
|
361
|
+
this: Mac2Driver,
|
|
362
|
+
keys: (KeyOptions | string)[],
|
|
363
|
+
elementId?: string
|
|
364
|
+
): Promise<unknown> {
|
|
305
365
|
const url = elementId ? `/wda/element/${elementId}/keys` : '/wda/keys';
|
|
306
366
|
return await this.wda.proxy.command(url, 'POST', { keys });
|
|
307
|
-
}
|
|
367
|
+
}
|
|
308
368
|
|
|
309
369
|
/**
|
|
310
370
|
* Perform tap gesture on a Touch Bar element or by relative/absolute coordinates
|
|
311
371
|
*
|
|
312
|
-
* @this
|
|
313
|
-
* @param {string} [elementId] Uuid of the Touch Bar element to tap. Either this property
|
|
372
|
+
* @param elementId - Uuid of the Touch Bar element to tap. Either this property
|
|
314
373
|
* or/and x and y must be set. If both are set then x and y are considered
|
|
315
374
|
* as relative element coordinates. If only x and y are set then
|
|
316
375
|
* these are parsed as absolute Touch Bar coordinates.
|
|
317
|
-
* @param
|
|
318
|
-
* @param
|
|
319
|
-
* @param
|
|
376
|
+
* @param x - Tap X coordinate
|
|
377
|
+
* @param y - Tap Y coordinate
|
|
378
|
+
* @param keyModifierFlags - If set then the given key modifiers will be
|
|
320
379
|
* applied while click is performed. See
|
|
321
380
|
* https://developer.apple.com/documentation/xctest/xcuikeymodifierflags
|
|
322
381
|
* for more details
|
|
323
382
|
*/
|
|
324
|
-
export async function macosTap
|
|
383
|
+
export async function macosTap(
|
|
384
|
+
this: Mac2Driver,
|
|
385
|
+
elementId?: string,
|
|
386
|
+
x?: number,
|
|
387
|
+
y?: number,
|
|
388
|
+
keyModifierFlags?: number
|
|
389
|
+
): Promise<unknown> {
|
|
325
390
|
requireElementIdOrXY(elementId, x, y);
|
|
326
391
|
const url = elementId ? `/wda/element/${elementId}/tap` : '/wda/tap';
|
|
327
392
|
return await this.wda.proxy.command(url, 'POST', {
|
|
328
|
-
x,
|
|
393
|
+
x,
|
|
394
|
+
y,
|
|
329
395
|
keyModifierFlags,
|
|
330
396
|
});
|
|
331
|
-
}
|
|
397
|
+
}
|
|
332
398
|
|
|
333
399
|
/**
|
|
334
400
|
* Perform tap gesture on a Touch Bar element or by relative/absolute coordinates
|
|
335
401
|
*
|
|
336
|
-
* @this
|
|
337
|
-
*
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
* @param
|
|
342
|
-
* @param
|
|
343
|
-
* @param {number} [keyModifierFlags] If set then the given key modifiers will be
|
|
402
|
+
* @param elementId - Uuid of the Touch Bar element to tap. Either this property
|
|
403
|
+
* or/and x and y must be set. If both are set then x and y are considered
|
|
404
|
+
* as relative element coordinates. If only x and y are set then
|
|
405
|
+
* these are parsed as absolute Touch Bar coordinates.
|
|
406
|
+
* @param x - Tap X coordinate
|
|
407
|
+
* @param y - Tap Y coordinate
|
|
408
|
+
* @param keyModifierFlags - If set then the given key modifiers will be
|
|
344
409
|
* applied while click is performed. See
|
|
345
410
|
* https://developer.apple.com/documentation/xctest/xcuikeymodifierflags
|
|
346
411
|
* for more details
|
|
347
412
|
*/
|
|
348
|
-
export async function macosDoubleTap
|
|
413
|
+
export async function macosDoubleTap(
|
|
414
|
+
this: Mac2Driver,
|
|
415
|
+
elementId?: string,
|
|
416
|
+
x?: number,
|
|
417
|
+
y?: number,
|
|
418
|
+
keyModifierFlags?: number
|
|
419
|
+
): Promise<unknown> {
|
|
349
420
|
requireElementIdOrXY(elementId, x, y);
|
|
350
421
|
const url = elementId ? `/wda/element/${elementId}/doubleTap` : '/wda/doubleTap';
|
|
351
422
|
return await this.wda.proxy.command(url, 'POST', {
|
|
352
|
-
x,
|
|
423
|
+
x,
|
|
424
|
+
y,
|
|
353
425
|
keyModifierFlags,
|
|
354
426
|
});
|
|
355
|
-
}
|
|
427
|
+
}
|
|
356
428
|
|
|
357
429
|
/**
|
|
358
430
|
* Perform press gesture on a Touch Bar element or by relative/absolute coordinates
|
|
359
431
|
*
|
|
360
|
-
* @
|
|
361
|
-
* @param
|
|
362
|
-
* @param {string} [elementId] Uuid of the Touch Bar element to be pressed. Either this property
|
|
432
|
+
* @param duration - The number of float seconds to hold the mouse button
|
|
433
|
+
* @param elementId - Uuid of the Touch Bar element to be pressed. Either this property
|
|
363
434
|
* or/and x and y must be set. If both are set then x and y are considered
|
|
364
435
|
* as relative element coordinates. If only x and y are set then these are
|
|
365
436
|
* parsed as absolute Touch Bar coordinates.
|
|
366
|
-
* @param
|
|
367
|
-
* @param
|
|
368
|
-
* @param
|
|
437
|
+
* @param x - Press X coordinate
|
|
438
|
+
* @param y - Press Y coordinate
|
|
439
|
+
* @param keyModifierFlags - If set then the given key modifiers will be
|
|
369
440
|
* applied while click is performed. See
|
|
370
441
|
* https://developer.apple.com/documentation/xctest/xcuikeymodifierflags
|
|
371
442
|
* for more details
|
|
372
443
|
*/
|
|
373
|
-
export async function macosPressAndHold
|
|
444
|
+
export async function macosPressAndHold(
|
|
445
|
+
this: Mac2Driver,
|
|
446
|
+
duration: number,
|
|
447
|
+
elementId?: string,
|
|
448
|
+
x?: number,
|
|
449
|
+
y?: number,
|
|
450
|
+
keyModifierFlags?: number
|
|
451
|
+
): Promise<unknown> {
|
|
374
452
|
const url = elementId ? `/wda/element/${elementId}/press` : '/wda/press';
|
|
375
453
|
return await this.wda.proxy.command(url, 'POST', {
|
|
376
|
-
x,
|
|
454
|
+
x,
|
|
455
|
+
y,
|
|
377
456
|
duration,
|
|
378
457
|
keyModifierFlags,
|
|
379
458
|
});
|
|
380
|
-
}
|
|
459
|
+
}
|
|
381
460
|
|
|
382
461
|
/**
|
|
383
462
|
* Perform long press and drag gesture on a Touch Bar element or by absolute coordinates
|
|
384
463
|
*
|
|
385
|
-
* @
|
|
386
|
-
* @param
|
|
387
|
-
* @param {string} [sourceElementId] Uuid of a Touch Bar element to start the drag from.
|
|
464
|
+
* @param duration - Long press duration in float seconds
|
|
465
|
+
* @param sourceElementId - Uuid of a Touch Bar element to start the drag from.
|
|
388
466
|
* Either this property and `destinationElement` must be provided or
|
|
389
467
|
* `startX`, `startY`, `endX`, `endY` coordinates must be set.
|
|
390
|
-
* @param
|
|
468
|
+
* @param destinationElementId - Uuid of a Touch Bar element to end the drag on.
|
|
391
469
|
* Either this property and `sourceElement` must be provided or
|
|
392
470
|
* `startX`, `startY`, `endX`, `endY` coordinates must be set.
|
|
393
|
-
* @param
|
|
394
|
-
* @param
|
|
395
|
-
* @param
|
|
396
|
-
* @param
|
|
397
|
-
* @param
|
|
471
|
+
* @param startX - Starting X coordinate
|
|
472
|
+
* @param startY - Starting Y coordinate
|
|
473
|
+
* @param endX - Ending X coordinate
|
|
474
|
+
* @param endY - Ending Y coordinate
|
|
475
|
+
* @param keyModifierFlags - If set then the given key modifiers will be
|
|
398
476
|
* applied while drag is performed. See
|
|
399
477
|
* https://developer.apple.com/documentation/xctest/xcuikeymodifierflags
|
|
400
478
|
* for more details
|
|
401
479
|
*/
|
|
402
|
-
export async function macosPressAndDrag
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
480
|
+
export async function macosPressAndDrag(
|
|
481
|
+
this: Mac2Driver,
|
|
482
|
+
duration: number,
|
|
483
|
+
sourceElementId?: string,
|
|
484
|
+
destinationElementId?: string,
|
|
485
|
+
startX?: number,
|
|
486
|
+
startY?: number,
|
|
487
|
+
endX?: number,
|
|
488
|
+
endY?: number,
|
|
489
|
+
keyModifierFlags?: number
|
|
490
|
+
): Promise<unknown> {
|
|
410
491
|
// requireSourceDestWithElementsOrCoordinates(
|
|
411
492
|
// sourceElementId, destinationElementId,
|
|
412
493
|
// startX, startY, endX, endY,
|
|
413
494
|
// );
|
|
414
|
-
const url =
|
|
415
|
-
|
|
416
|
-
|
|
495
|
+
const url =
|
|
496
|
+
sourceElementId && destinationElementId
|
|
497
|
+
? `/wda/element/${sourceElementId}/pressAndDrag`
|
|
498
|
+
: '/wda/pressAndDrag';
|
|
417
499
|
const dest = destinationElementId && util.wrapElement(destinationElementId);
|
|
418
500
|
return await this.wda.proxy.command(url, 'POST', {
|
|
419
|
-
startX,
|
|
420
|
-
|
|
501
|
+
startX,
|
|
502
|
+
startY,
|
|
503
|
+
endX,
|
|
504
|
+
endY,
|
|
421
505
|
duration,
|
|
422
506
|
dest,
|
|
423
507
|
keyModifierFlags,
|
|
424
508
|
});
|
|
425
|
-
}
|
|
509
|
+
}
|
|
426
510
|
|
|
427
511
|
/**
|
|
428
512
|
* Perform press, drag and hold gesture on a Touch Bar element or by absolute Touch Bar coordinates
|
|
429
513
|
*
|
|
430
|
-
* @
|
|
431
|
-
* @param
|
|
432
|
-
* @param
|
|
433
|
-
* @param {string} [sourceElementId] Uuid of a Touch Bar element to start the drag from.
|
|
514
|
+
* @param duration - Long press duration in float seconds
|
|
515
|
+
* @param holdDuration - Touch hold duration in float seconds
|
|
516
|
+
* @param sourceElementId - Uuid of a Touch Bar element to start the drag from.
|
|
434
517
|
* Either this property and `destinationElement` must be provided or
|
|
435
518
|
* `startX`, `startY`, `endX`, `endY` coordinates must be set.
|
|
436
|
-
* @param
|
|
519
|
+
* @param destinationElementId - Uuid of a Touch Bar element to end the drag on.
|
|
437
520
|
* Either this property and `sourceElement` must be provided or
|
|
438
521
|
* `startX`, `startY`, `endX`, `endY` coordinates must be set.
|
|
439
|
-
* @param
|
|
440
|
-
* @param
|
|
441
|
-
* @param
|
|
442
|
-
* @param
|
|
443
|
-
* @param
|
|
522
|
+
* @param startX - Starting X coordinate
|
|
523
|
+
* @param startY - Starting Y coordinate
|
|
524
|
+
* @param endX - Ending X coordinate
|
|
525
|
+
* @param endY - Ending Y coordinate
|
|
526
|
+
* @param velocity - Dragging velocity in pixels per second.
|
|
444
527
|
* If not provided then the default velocity is used. See
|
|
445
528
|
* https://developer.apple.com/documentation/xctest/xcuigesturevelocity
|
|
446
529
|
* for more details
|
|
447
|
-
* @param
|
|
530
|
+
* @param keyModifierFlags - If set then the given key modifiers will be
|
|
448
531
|
* applied while drag is performed. See
|
|
449
532
|
* https://developer.apple.com/documentation/xctest/xcuikeymodifierflags
|
|
450
533
|
* for more details
|
|
451
534
|
*/
|
|
452
|
-
export async function macosPressAndDragAndHold
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
535
|
+
export async function macosPressAndDragAndHold(
|
|
536
|
+
this: Mac2Driver,
|
|
537
|
+
duration: number,
|
|
538
|
+
holdDuration: number,
|
|
539
|
+
sourceElementId?: string,
|
|
540
|
+
destinationElementId?: string,
|
|
541
|
+
startX?: number,
|
|
542
|
+
startY?: number,
|
|
543
|
+
endX?: number,
|
|
544
|
+
endY?: number,
|
|
545
|
+
velocity?: number,
|
|
546
|
+
keyModifierFlags?: number
|
|
547
|
+
): Promise<unknown> {
|
|
462
548
|
requireSourceDestWithElementsOrCoordinates(
|
|
463
|
-
sourceElementId,
|
|
464
|
-
|
|
549
|
+
sourceElementId,
|
|
550
|
+
destinationElementId,
|
|
551
|
+
startX,
|
|
552
|
+
startY,
|
|
553
|
+
endX,
|
|
554
|
+
endY
|
|
465
555
|
);
|
|
466
|
-
const url =
|
|
467
|
-
|
|
468
|
-
|
|
556
|
+
const url =
|
|
557
|
+
sourceElementId && destinationElementId
|
|
558
|
+
? `/wda/element/${sourceElementId}/pressAndDragAndHold`
|
|
559
|
+
: '/wda/pressAndDragAndHold';
|
|
469
560
|
const dest = destinationElementId && util.wrapElement(destinationElementId);
|
|
470
561
|
return await this.wda.proxy.command(url, 'POST', {
|
|
471
|
-
startX,
|
|
472
|
-
|
|
473
|
-
|
|
562
|
+
startX,
|
|
563
|
+
startY,
|
|
564
|
+
endX,
|
|
565
|
+
endY,
|
|
566
|
+
duration,
|
|
567
|
+
holdDuration,
|
|
474
568
|
velocity,
|
|
475
569
|
dest,
|
|
476
570
|
keyModifierFlags,
|
|
477
571
|
});
|
|
478
|
-
}
|
|
572
|
+
}
|
|
479
573
|
|
|
480
574
|
/**
|
|
481
575
|
* Raise invalid argument error if element id was unset or x and y were unset.
|
|
482
|
-
* @param
|
|
483
|
-
* @param
|
|
484
|
-
* @param
|
|
485
|
-
* @returns {void}
|
|
576
|
+
* @param elementId - Optional element ID
|
|
577
|
+
* @param x - Optional X coordinate
|
|
578
|
+
* @param y - Optional Y coordinate
|
|
486
579
|
*/
|
|
487
|
-
function requireElementIdOrXY
|
|
580
|
+
function requireElementIdOrXY(elementId?: string, x?: number, y?: number): void {
|
|
488
581
|
if (!_.isString(elementId) && !(_.isNumber(x) && _.isNumber(y))) {
|
|
489
582
|
throw new errors.InvalidArgumentError(`'elementId' or 'x' and 'y' is required.`);
|
|
490
583
|
}
|
|
@@ -493,27 +586,29 @@ function requireElementIdOrXY (elementId, x, y) {
|
|
|
493
586
|
/**
|
|
494
587
|
* Raise invalid argument error if sourceElementId and destinationElementId were unset
|
|
495
588
|
* or startX, startY, endX and endY were unset.
|
|
496
|
-
* @param
|
|
497
|
-
* @param
|
|
498
|
-
* @param
|
|
499
|
-
* @param
|
|
500
|
-
* @param
|
|
501
|
-
* @param
|
|
502
|
-
* @returns {void}
|
|
589
|
+
* @param sourceElementId - Optional source element ID
|
|
590
|
+
* @param destinationElementId - Optional destination element ID
|
|
591
|
+
* @param startX - Optional starting X coordinate
|
|
592
|
+
* @param startY - Optional starting Y coordinate
|
|
593
|
+
* @param endX - Optional ending X coordinate
|
|
594
|
+
* @param endY - Optional ending Y coordinate
|
|
503
595
|
*/
|
|
504
|
-
function requireSourceDestWithElementsOrCoordinates
|
|
505
|
-
sourceElementId
|
|
506
|
-
|
|
507
|
-
|
|
596
|
+
function requireSourceDestWithElementsOrCoordinates(
|
|
597
|
+
sourceElementId?: string,
|
|
598
|
+
destinationElementId?: string,
|
|
599
|
+
startX?: number,
|
|
600
|
+
startY?: number,
|
|
601
|
+
endX?: number,
|
|
602
|
+
endY?: number
|
|
603
|
+
): void {
|
|
508
604
|
if (
|
|
509
|
-
!(_.isString(sourceElementId) && _.isString(destinationElementId))
|
|
510
|
-
|
|
605
|
+
!(_.isString(sourceElementId) && _.isString(destinationElementId)) &&
|
|
606
|
+
!(_.isNumber(startX) && _.isNumber(startY) && _.isNumber(endX) && _.isNumber(endY))
|
|
511
607
|
) {
|
|
512
|
-
throw new errors.InvalidArgumentError(
|
|
513
|
-
`
|
|
608
|
+
throw new errors.InvalidArgumentError(
|
|
609
|
+
`'sourceElementId' and 'destinationElementId' ` +
|
|
610
|
+
`or 'startX', 'startY', 'endX' and 'endY' are required.`
|
|
611
|
+
);
|
|
514
612
|
}
|
|
515
613
|
}
|
|
516
614
|
|
|
517
|
-
/**
|
|
518
|
-
* @typedef {import('../driver').Mac2Driver} Mac2Driver
|
|
519
|
-
*/
|