appium-mac2-driver 0.12.0 → 0.14.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.
Files changed (28) hide show
  1. package/README.md +193 -41
  2. package/WebDriverAgentMac/IntegrationTests/AMVariousElementTests.m +56 -0
  3. package/WebDriverAgentMac/WebDriverAgentLib/Categories/XCUICoordinate+AMSwipe.h +38 -0
  4. package/WebDriverAgentMac/WebDriverAgentLib/Categories/XCUICoordinate+AMSwipe.m +31 -0
  5. package/WebDriverAgentMac/WebDriverAgentLib/Categories/XCUIElement+AMSwipe.h +38 -0
  6. package/WebDriverAgentMac/WebDriverAgentLib/Categories/XCUIElement+AMSwipe.m +30 -0
  7. package/WebDriverAgentMac/WebDriverAgentLib/Commands/FBElementCommands.m +262 -39
  8. package/WebDriverAgentMac/WebDriverAgentLib/Routing/FBWebServer.m +7 -3
  9. package/WebDriverAgentMac/WebDriverAgentLib/Utilities/AMSwipeHelpers.h +34 -0
  10. package/WebDriverAgentMac/WebDriverAgentLib/Utilities/AMSwipeHelpers.m +63 -0
  11. package/WebDriverAgentMac/WebDriverAgentLib/Utilities/FBXPath.m +15 -44
  12. package/WebDriverAgentMac/WebDriverAgentLib/Utilities/LRUCache/LRUCache.h +2 -2
  13. package/WebDriverAgentMac/WebDriverAgentLib/Utilities/LRUCache/LRUCache.m +69 -36
  14. package/WebDriverAgentMac/WebDriverAgentLib/Utilities/LRUCache/LRUCacheNode.m +0 -8
  15. package/WebDriverAgentMac/WebDriverAgentMac.xcodeproj/project.pbxproj +28 -0
  16. package/WebDriverAgentMac/WebDriverAgentMac.xcodeproj/project.xcworkspace/xcuserdata/elf.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  17. package/WebDriverAgentMac/WebDriverAgentRunner/WebDriverAgentRunner.m +8 -0
  18. package/build/index.js +8 -5
  19. package/build/lib/commands/applescript.js +8 -3
  20. package/build/lib/commands/execute.js +7 -2
  21. package/build/lib/commands/gestures.js +156 -37
  22. package/build/lib/wda-mac.js +26 -4
  23. package/index.js +6 -3
  24. package/lib/commands/applescript.js +7 -1
  25. package/lib/commands/execute.js +7 -1
  26. package/lib/commands/gestures.js +271 -51
  27. package/lib/wda-mac.js +27 -5
  28. package/package.json +5 -5
package/README.md CHANGED
@@ -82,24 +82,15 @@ Perform click gesture on an element or by relative/absolute coordinates
82
82
 
83
83
  Name | Type | Required | Description | Example
84
84
  --- | --- | --- | --- | ---
85
- element | string | if `x` or `y` are unset | Unique identifier of the element to perform the click on. Either this property or/and x and y must be set. If both are set then x and y are considered as relative element coordinates. If only x and y are set then these are parsed as absolute coordinates. | 21045BC8-013C-43BD-9B1E-4C6DC7AB0744
86
- x | number | if `y` is set or `element` is unset | click X coordinate | 100
87
- y | number | if `y` is set or `element` is unset | click Y coordinate | 100
85
+ elementId ("element" prior to Appium v 1.22) | string | if `x` or `y` are unset | Unique identifier of the element to perform the click on. Either this property or/and x and y must be set. If both are set then x and y are considered as relative element coordinates. If only x and y are set then these are parsed as absolute coordinates. | 21045BC8-013C-43BD-9B1E-4C6DC7AB0744
86
+ x | number | if `y` is set or `elementId` is unset | click X coordinate | 100
87
+ y | number | if `y` is set or `elementId` is unset | click Y coordinate | 100
88
88
  keyModifierFlags | number | no | if set then the given key modifiers will be applied while click is performed. See the official documentation on [XCUIKeyModifierFlags enumeration](https://developer.apple.com/documentation/xctest/xcuikeymodifierflags) for more details | `1 << 1 | 1 << 2`
89
89
 
90
- ### macos: clickAndHold
90
+ #### References
91
91
 
92
- Perform long click gesture on an element or by relative/absolute coordinates
93
-
94
- #### Arguments
95
-
96
- Name | Type | Required | Description | Example
97
- --- | --- | --- | --- | ---
98
- element | string | if `x` or `y` are unset | Unique identifier of the element to perform the long click on. Either this property or/and x and y must be set. If both are set then x and y are considered as relative element coordinates. If only x and y are set then these are parsed as absolute coordinates. | 21045BC8-013C-43BD-9B1E-4C6DC7AB0744
99
- x | number | if `y` is set or `element` is unset | long click X coordinate | 100
100
- y | number | if `y` is set or `element` is unset | long click Y coordinate | 100
101
- duration | number | yes | The number of float seconds to hold the mouse button | 2.5
102
- keyModifierFlags | number | no | if set then the given key modifiers will be applied while long click is performed. See the official documentation on [XCUIKeyModifierFlags enumeration](https://developer.apple.com/documentation/xctest/xcuikeymodifierflags) for more details | `1 << 1 | 1 << 2`
92
+ - [click (XCUIElement)](https://developer.apple.com/documentation/xctest/xcuielement/1500316-click?language=objc)
93
+ - [click (XCUICoordinate)](https://developer.apple.com/documentation/xctest/xcuicoordinate/1500677-click?language=objc)
103
94
 
104
95
  ### macos: scroll
105
96
 
@@ -109,13 +100,18 @@ Perform scroll gesture on an element or by relative/absolute coordinates
109
100
 
110
101
  Name | Type | Required | Description | Example
111
102
  --- | --- | --- | --- | ---
112
- element | string | if `x` or `y` are unset | Unique identifier of the element to be scrolled. Either this property or/and x and y must be set. If both are set then x and y are considered as relative element coordinates. If only x and y are set then these are parsed as absolute coordinates. | 21045BC8-013C-43BD-9B1E-4C6DC7AB0744
113
- x | number | if `y` is set or `element` is unset | scroll X coordinate | 100
114
- y | number | if `y` is set or `element` is unset | scroll Y coordinate | 100
103
+ elementId ("element" prior to Appium v 1.22) | string | if `x` or `y` are unset | Unique identifier of the element to be scrolled. Either this property or/and x and y must be set. If both are set then x and y are considered as relative element coordinates. If only x and y are set then these are parsed as absolute coordinates. | 21045BC8-013C-43BD-9B1E-4C6DC7AB0744
104
+ x | number | if `y` is set or `elementId` is unset | scroll X coordinate | 100
105
+ y | number | if `y` is set or `elementId` is unset | scroll Y coordinate | 100
115
106
  deltaX | number | yes | Horizontal delta as float number. Could be negative | 100
116
107
  deltaY | number | yes | vertical delta as float number. Could be negative | 100
117
108
  keyModifierFlags | number | no | if set then the given key modifiers will be applied while scroll is performed. See the official documentation on [XCUIKeyModifierFlags enumeration](https://developer.apple.com/documentation/xctest/xcuikeymodifierflags) for more details | `1 << 1 | 1 << 2`
118
109
 
110
+ #### References
111
+
112
+ - [scrollByDeltaX:deltaY: (XCUIElement)](https://developer.apple.com/documentation/xctest/xcuielement/1500758-scrollbydeltax?language=objc)
113
+ - [scrollByDeltaX:deltaY: (XCUICoordinate)](https://developer.apple.com/documentation/xctest/xcuicoordinate?language=objc)
114
+
119
115
  ### macos: rightClick
120
116
 
121
117
  Perform right click gesture on an element or by relative/absolute coordinates
@@ -124,11 +120,18 @@ Perform right click gesture on an element or by relative/absolute coordinates
124
120
 
125
121
  Name | Type | Required | Description | Example
126
122
  --- | --- | --- | --- | ---
127
- element | string | if `x` or `y` are unset | Unique identifier of the element to perform the right click on. Either this property or/and x and y must be set. If both are set then x and y are considered as relative element coordinates. If only x and y are set then these are parsed as absolute coordinates. | 21045BC8-013C-43BD-9B1E-4C6DC7AB0744
128
- x | number | if `y` is set or `element` is unset | right click X coordinate | 100
129
- y | number | if `y` is set or `element` is unset | right click Y coordinate | 100
123
+ elementId ("element" prior to Appium v 1.22) | string | if `x` or `y` are unset | Unique identifier of the element to perform the right click on. Either this property or/and x and y must be set. If both are set then x and y are considered as relative element coordinates. If only x and y are set then these are parsed as absolute coordinates. | 21045BC8-013C-43BD-9B1E-4C6DC7AB0744
124
+ x | number | if `y` is set or `elementId` is unset | right click X coordinate | 100
125
+ y | number | if `y` is set or `elementId` is unset | right click Y coordinate | 100
130
126
  keyModifierFlags | number | no | if set then the given key modifiers will be applied while right click is performed. See the official documentation on [XCUIKeyModifierFlags enumeration](https://developer.apple.com/documentation/xctest/xcuikeymodifierflags) for more details | `1 << 1 | 1 << 2`
131
127
 
128
+ #### References
129
+
130
+ - [rightClick (XCUIElement)](https://developer.apple.com/documentation/xctest/xcuielement/1500469-rightclick?language=objc)
131
+ - [rightClick (XCUICoordinate)](https://developer.apple.com/documentation/xctest/xcuicoordinate/1500503-rightclick?language=objc)
132
+
133
+ ### macos: rightClick
134
+
132
135
  ### macos: hover
133
136
 
134
137
  Perform hover gesture on an element or by relative/absolute coordinates
@@ -137,11 +140,16 @@ Perform hover gesture on an element or by relative/absolute coordinates
137
140
 
138
141
  Name | Type | Required | Description | Example
139
142
  --- | --- | --- | --- | ---
140
- element | string | if `x` or `y` are unset | Unique identifier of the element to perform the hover on. Either this property or/and x and y must be set. If both are set then x and y are considered as relative element coordinates. If only x and y are set then these are parsed as absolute coordinates. | 21045BC8-013C-43BD-9B1E-4C6DC7AB0744
141
- x | number | if `y` is set or `element` is unset | long click X coordinate | 100
142
- y | number | if `y` is set or `element` is unset | long click Y coordinate | 100
143
+ elementId ("element" prior to Appium v 1.22) | string | if `x` or `y` are unset | Unique identifier of the element to perform the hover on. Either this property or/and x and y must be set. If both are set then x and y are considered as relative element coordinates. If only x and y are set then these are parsed as absolute coordinates. | 21045BC8-013C-43BD-9B1E-4C6DC7AB0744
144
+ x | number | if `y` is set or `elementId` is unset | long click X coordinate | 100
145
+ y | number | if `y` is set or `elementId` is unset | long click Y coordinate | 100
143
146
  keyModifierFlags | number | no | if set then the given key modifiers will be applied while hover is performed. See the official documentation on [XCUIKeyModifierFlags enumeration](https://developer.apple.com/documentation/xctest/xcuikeymodifierflags) for more details | `1 << 1 | 1 << 2`
144
147
 
148
+ #### References
149
+
150
+ - [hover (XCUIElement)](https://developer.apple.com/documentation/xctest/xcuielement/1500437-hover?language=objc)
151
+ - [hover (XCUICoordinate)](https://developer.apple.com/documentation/xctest/xcuicoordinate/1501021-hover?language=objc)
152
+
145
153
  ### macos: doubleClick
146
154
 
147
155
  Perform double click gesture on an element or by relative/absolute coordinates
@@ -150,11 +158,16 @@ Perform double click gesture on an element or by relative/absolute coordinates
150
158
 
151
159
  Name | Type | Required | Description | Example
152
160
  --- | --- | --- | --- | ---
153
- element | string | if `x` or `y` are unset | Unique identifier of the element to perform the double click on. Either this property or/and x and y must be set. If both are set then x and y are considered as relative element coordinates. If only x and y are set then these are parsed as absolute coordinates. | 21045BC8-013C-43BD-9B1E-4C6DC7AB0744
154
- x | number | if `y` is set or `element` is unset | double click X coordinate | 100
155
- y | number | if `y` is set or `element` is unset | double click Y coordinate | 100
161
+ elementId ("element" prior to Appium v 1.22) | string | if `x` or `y` are unset | Unique identifier of the element to perform the double click on. Either this property or/and x and y must be set. If both are set then x and y are considered as relative element coordinates. If only x and y are set then these are parsed as absolute coordinates. | 21045BC8-013C-43BD-9B1E-4C6DC7AB0744
162
+ x | number | if `y` is set or `elementId` is unset | double click X coordinate | 100
163
+ y | number | if `y` is set or `elementId` is unset | double click Y coordinate | 100
156
164
  keyModifierFlags | number | no | if set then the given key modifiers will be applied while click is performed. See the official documentation on [XCUIKeyModifierFlags enumeration](https://developer.apple.com/documentation/xctest/xcuikeymodifierflags) for more details | `1 << 1 | 1 << 2`
157
165
 
166
+ #### References
167
+
168
+ - [doubleClick (XCUIElement)](https://developer.apple.com/documentation/xctest/xcuielement/1500571-doubleclick?language=objc)
169
+ - [doubleClick (XCUICoordinate)](https://developer.apple.com/documentation/xctest/xcuicoordinate/1500302-doubleclick?language=objc)
170
+
158
171
  ### macos: clickAndDrag
159
172
 
160
173
  Perform long click and drag gesture on an element or by absolute coordinates
@@ -163,16 +176,21 @@ Perform long click and drag gesture on an element or by absolute coordinates
163
176
 
164
177
  Name | Type | Required | Description | Example
165
178
  --- | --- | --- | --- | ---
166
- sourceElement | string | if `startX`, `startY`, `endX` and `endY` are unset or if `destinationElement` is set | Uuid of the element to start the drag from. | 21045BC8-013C-43BD-9B1E-4C6DC7AB0744
167
- destinationElement | string | if `startX`, `startY`, `endX` and `endY` are unset or if `sourceElement` is set | Uuid of the element to end the drag on. | 21045BC8-013C-43BD-9B1E-4C6DC7AB0745
168
- startX | number | if `sourceElement` and `destinationElement` are unset | starting X coordinate | 100
169
- startY | number | if `sourceElement` and `destinationElement` are unset | starting Y coordinate | 110
170
- endX | number | if `sourceElement` and `destinationElement` are unset | end X coordinate | 200
171
- endY | number | if `sourceElement` and `destinationElement` are unset | end Y coordinate | 220
179
+ sourceElementId ("sourceElement" prior to Appium v 1.22) | string | if `startX`, `startY`, `endX` and `endY` are unset or if `destinationElementId` is set | Uuid of the element to start the drag from. | 21045BC8-013C-43BD-9B1E-4C6DC7AB0744
180
+ destinationElementId ("destinationElement" prior to Appium v 1.22) | string | if `startX`, `startY`, `endX` and `endY` are unset or if `sourceElementId` is set | Uuid of the element to end the drag on. | 21045BC8-013C-43BD-9B1E-4C6DC7AB0745
181
+ startX | number | if `sourceElementId` and `destinationElementId` are unset | starting X coordinate | 100
182
+ startY | number | if `sourceElementId` and `destinationElementId` are unset | starting Y coordinate | 110
183
+ endX | number | if `sourceElementId` and `destinationElementId` are unset | end X coordinate | 200
184
+ endY | number | if `sourceElementId` and `destinationElementId` are unset | end Y coordinate | 220
172
185
  duration | number | yes | The number of float seconds to hold the mouse button | 2.5
173
186
  keyModifierFlags | number | no | if set then the given key modifiers will be applied while drag is performed. See the official documentation on [XCUIKeyModifierFlags enumeration](https://developer.apple.com/documentation/xctest/xcuikeymodifierflags) for more details | `1 << 1 | 1 << 2`
174
187
 
175
- ### macos: clickDragAndDrag
188
+ #### References
189
+
190
+ - [clickForDuration:thenDragToElement (XCUIElement)](https://developer.apple.com/documentation/xctest/xcuielement/1500989-clickforduration?language=objc)
191
+ - [clickForDuration:thenDragToCoordinate: (XCUICoordinate)](https://developer.apple.com/documentation/xctest/xcuicoordinate/1500369-clickforduration?language=objc)
192
+
193
+ ### macos: clickAndDragAndHold
176
194
 
177
195
  Perform long click, drag and hold gesture on an element or by absolute coordinates
178
196
 
@@ -180,16 +198,145 @@ Perform long click, drag and hold gesture on an element or by absolute coordinat
180
198
 
181
199
  Name | Type | Required | Description | Example
182
200
  --- | --- | --- | --- | ---
183
- sourceElement | string | if `startX`, `startY`, `endX` and `endY` are unset or if `destinationElement` is set | Uuid of the element to start the drag from. | 21045BC8-013C-43BD-9B1E-4C6DC7AB0744
184
- destinationElement | string | if `startX`, `startY`, `endX` and `endY` are unset or if `sourceElement` is set | Uuid of the element to end the drag on. | 21045BC8-013C-43BD-9B1E-4C6DC7AB0745
185
- startX | number | if `sourceElement` and `destinationElement` are unset | starting X coordinate | 100
186
- startY | number | if `sourceElement` and `destinationElement` are unset | starting Y coordinate | 110
187
- endX | number | if `sourceElement` and `destinationElement` are unset | end X coordinate | 200
188
- endY | number | if `sourceElement` and `destinationElement` are unset | end Y coordinate | 220
201
+ sourceElementId ("sourceElement" prior to Appium v 1.22) | string | if `startX`, `startY`, `endX` and `endY` are unset or if `destinationElementId` is set | Uuid of the element to start the drag from. | 21045BC8-013C-43BD-9B1E-4C6DC7AB0744
202
+ destinationElementId ("destinationElement" prior to Appium v 1.22) | string | if `startX`, `startY`, `endX` and `endY` are unset or if `sourceElementId` is set | Uuid of the element to end the drag on. | 21045BC8-013C-43BD-9B1E-4C6DC7AB0745
203
+ startX | number | if `sourceElementId` and `destinationElementId` are unset | starting X coordinate | 100
204
+ startY | number | if `sourceElementId` and `destinationElementId` are unset | starting Y coordinate | 110
205
+ endX | number | if `sourceElementId` and `destinationElementId` are unset | end X coordinate | 200
206
+ endY | number | if `sourceElementId` and `destinationElementId` are unset | end Y coordinate | 220
189
207
  duration | number | yes | The number of float seconds to hold the mouse button | 2.5
190
208
  velocity | number | no | Dragging velocity in pixels per second. If not provided then the default velocity is used. See official documentation on [XCUIGestureVelocity structure](https://developer.apple.com/documentation/xctest/xcuigesturevelocity) for more details | 2500
191
209
  keyModifierFlags | number | no | if set then the given key modifiers will be applied while drag is performed. See the official documentation on [XCUIKeyModifierFlags enumeration](https://developer.apple.com/documentation/xctest/xcuikeymodifierflags) for more details | `1 << 1 | 1 << 2`
192
210
 
211
+ #### References
212
+
213
+ - [clickForDuration:thenDragToElement:withVelocity:thenHoldForDuration: (XCUIElement)](https://developer.apple.com/documentation/xctest/xcuielement/3553192-clickforduration?language=objc)
214
+ - [clickForDuration:thenDragToCoordinate:withVelocity:thenHoldForDuration: (XCUICoordinate)](https://developer.apple.com/documentation/xctest/xcuicoordinate/3553191-clickforduration?language=objc)
215
+
216
+ ### mobile: swipe
217
+
218
+ This extension performs a swipe gesture on the particular screen element or by given coordinates.
219
+ The API is only available on macOS since Xcode SDK 13.
220
+
221
+ #### Arguments
222
+
223
+ Name | Type | Required | Description | Example
224
+ --- | --- | --- | --- | ---
225
+ elementId ("element" prior to Appium v 1.22) | string | if `x` or `y` are unset | The internal element identifier (as hexadecimal hash string) to swipe on. If both are set then x and y are considered as relative element coordinates. If only x and y are set then these are parsed as absolute coordinates. | fe50b60b-916d-420b-8728-ee2072ec53eb
226
+ x | number | if `y` is set or `elementId` is unset | long click X coordinate | 100
227
+ y | number | if `y` is set or `elementId` is unset | long click Y coordinate | 100
228
+ direction | Either 'up', 'down', 'left' or 'right' | yes | The direction in which to swipe | up
229
+ velocity | number | no | The value is measured in pixels per second and same values could behave differently on different devices depending on their display density. Higher values make swipe gesture faster (which usually scrolls larger areas if we apply it to a list) and lower values slow it down. Only values greater than zero have effect. | 250
230
+ keyModifierFlags | number | no | if set then the given key modifiers will be applied while swipe is performed. See the official documentation on [XCUIKeyModifierFlags enumeration](https://developer.apple.com/documentation/xctest/xcuikeymodifierflags) for more details | `1 << 1 | 1 << 2`
231
+
232
+ #### References
233
+
234
+ - [swipeDown (XCUIElement)](https://developer.apple.com/documentation/xctest/xcuielement/1618664-swipedown?language=objc)
235
+ - [swipeDown (XCUICoordinate)](https://developer.apple.com/documentation/xctest/xcuicoordinate/3752780-swipedown?language=objc)
236
+ - [swipeDownWithVelocity: (XCUIElement)](https://developer.apple.com/documentation/xctest/xcuielement/3551694-swipedownwithvelocity?language=objc)
237
+ - [swipeDownWithVelocity: (XCUICoordinate)](https://developer.apple.com/documentation/xctest/xcuicoordinate/3752781-swipedownwithvelocity?language=objc)
238
+ - ...
239
+
240
+ ### macos: press
241
+
242
+ Perform press gesture on a Touch Bar element or by relative/absolute coordinates
243
+
244
+ #### Arguments
245
+
246
+ Name | Type | Required | Description | Example
247
+ --- | --- | --- | --- | ---
248
+ elementId | string | if `x` or `y` are unset | Unique identifier of a Touch Bar element to perform the press on. Either this property or/and x and y must be set. If both are set then x and y are considered as relative element coordinates. If only x and y are set then these are parsed as absolute Touch Bar coordinates. | 21045BC8-013C-43BD-9B1E-4C6DC7AB0744
249
+ x | number | if `y` is set or `elementId` is unset | long click X coordinate | 100
250
+ y | number | if `y` is set or `elementId` is unset | long click Y coordinate | 100
251
+ duration | number | yes | The number of float seconds to hold the touch | 2.5
252
+ keyModifierFlags | number | no | if set then the given key modifiers will be applied while the gesture is performed. See the official documentation on [XCUIKeyModifierFlags enumeration](https://developer.apple.com/documentation/xctest/xcuikeymodifierflags) for more details | `1 << 1 | 1 << 2`
253
+
254
+ #### References
255
+
256
+ - [pressForDuration: (XCUIElement)](https://developer.apple.com/documentation/xctest/xcuielement/1618663-pressforduration?language=objc)
257
+ - [pressForDuration: (XCUICoordinate)](https://developer.apple.com/documentation/xctest/xcuicoordinate/1615002-pressforduration?language=objc)
258
+
259
+ ### macos: tap
260
+
261
+ Perform tap gesture on a Touch Bar element or by relative/absolute coordinates
262
+
263
+ #### Arguments
264
+
265
+ Name | Type | Required | Description | Example
266
+ --- | --- | --- | --- | ---
267
+ elementId | string | if `x` or `y` are unset | Unique identifier of a Touch Bar element to perform the tap on. Either this property or/and x and y must be set. If both are set then x and y are considered as relative element coordinates. If only x and y are set then these are parsed as absolute Touch Bar coordinates. | 21045BC8-013C-43BD-9B1E-4C6DC7AB0744
268
+ x | number | if `y` is set or `elementId` is unset | click X coordinate | 100
269
+ y | number | if `y` is set or `elementId` is unset | click Y coordinate | 100
270
+ keyModifierFlags | number | no | if set then the given key modifiers will be applied while the gesture is performed. See the official documentation on [XCUIKeyModifierFlags enumeration](https://developer.apple.com/documentation/xctest/xcuikeymodifierflags) for more details | `1 << 1 | 1 << 2`
271
+
272
+ #### References
273
+
274
+ - [tap (XCUIElement)](https://developer.apple.com/documentation/xctest/xcuielement/1618666-tap?language=objc)
275
+ - [tap (XCUICoordinate)](https://developer.apple.com/documentation/xctest/xcuicoordinate/1615004-tap?language=objc)
276
+
277
+ ### macos: doubleTap
278
+
279
+ Perform double tap gesture on a Touch Bar element or by relative/absolute coordinates
280
+
281
+ #### Arguments
282
+
283
+ Name | Type | Required | Description | Example
284
+ --- | --- | --- | --- | ---
285
+ elementId | string | if `x` or `y` are unset | Unique identifier of a Touch Bar element to perform the double tap on. Either this property or/and x and y must be set. If both are set then x and y are considered as relative element coordinates. If only x and y are set then these are parsed as absolute Touch Bar coordinates. | 21045BC8-013C-43BD-9B1E-4C6DC7AB0744
286
+ x | number | if `y` is set or `elementId` is unset | click X coordinate | 100
287
+ y | number | if `y` is set or `elementId` is unset | click Y coordinate | 100
288
+ keyModifierFlags | number | no | if set then the given key modifiers will be applied while the gesture is performed. See the official documentation on [XCUIKeyModifierFlags enumeration](https://developer.apple.com/documentation/xctest/xcuikeymodifierflags) for more details | `1 << 1 | 1 << 2`
289
+
290
+ #### References
291
+
292
+ - [doubleTap (XCUIElement)](https://developer.apple.com/documentation/xctest/xcuielement/1618673-doubletap?language=objc)
293
+ - [doubleTap (XCUICoordinate)](https://developer.apple.com/documentation/xctest/xcuicoordinate/1615005-doubletap?language=objc)
294
+
295
+ ### macos: pressAndDrag
296
+
297
+ Perform long press and drag gesture on a Touch Bar element or by absolute Touch Bar coordinates
298
+
299
+ #### Arguments
300
+
301
+ Name | Type | Required | Description | Example
302
+ --- | --- | --- | --- | ---
303
+ sourceElementId | string | if `startX`, `startY`, `endX` and `endY` are unset or if `destinationElementId` is set | Uuid of a Touch Bar element to start the drag from. | 21045BC8-013C-43BD-9B1E-4C6DC7AB0744
304
+ destinationElementId | string | if `startX`, `startY`, `endX` and `endY` are unset or if `sourceElementId` is set | Uuid of a Touch Bar element to end the drag on. | 21045BC8-013C-43BD-9B1E-4C6DC7AB0745
305
+ startX | number | if `sourceElementId` and `destinationElementId` are unset | starting X coordinate | 100
306
+ startY | number | if `sourceElementId` and `destinationElementId` are unset | starting Y coordinate | 110
307
+ endX | number | if `sourceElementId` and `destinationElementId` are unset | end X coordinate | 200
308
+ endY | number | if `sourceElementId` and `destinationElementId` are unset | end Y coordinate | 220
309
+ duration | number | yes | The number of float seconds to hold the touch | 2.5
310
+ keyModifierFlags | number | no | if set then the given key modifiers will be applied while the gesture is performed. See the official documentation on [XCUIKeyModifierFlags enumeration](https://developer.apple.com/documentation/xctest/xcuikeymodifierflags) for more details | `1 << 1 | 1 << 2`
311
+
312
+ #### References
313
+
314
+ - [pressForDuration:thenDragToElement: (XCUIElement)](https://developer.apple.com/documentation/xctest/xcuielement/1618670-pressforduration?language=objc)
315
+ - [pressForDuration:thenDragToCoordinate: (XCUICoordinate)](https://developer.apple.com/documentation/xctest/xcuicoordinate/1615003-pressforduration?language=objc)
316
+
317
+ ### macos: pressAndDragAndHold
318
+
319
+ Perform long press, drag and hold gesture on a Touch Bar element or by absolute Touch Bar coordinates
320
+
321
+ #### Arguments
322
+
323
+ Name | Type | Required | Description | Example
324
+ --- | --- | --- | --- | ---
325
+ sourceElementId | string | if `startX`, `startY`, `endX` and `endY` are unset or if `destinationElementId` is set | Uuid of a Touch Bar element to start the drag from. | 21045BC8-013C-43BD-9B1E-4C6DC7AB0744
326
+ destinationElementId | string | if `startX`, `startY`, `endX` and `endY` are unset or if `sourceElementId` is set | Uuid of a Touch Bar element to end the drag on. | 21045BC8-013C-43BD-9B1E-4C6DC7AB0745
327
+ startX | number | if `sourceElementId` and `destinationElementId` are unset | starting X coordinate | 100
328
+ startY | number | if `sourceElementId` and `destinationElementId` are unset | starting Y coordinate | 110
329
+ endX | number | if `sourceElementId` and `destinationElementId` are unset | end X coordinate | 200
330
+ endY | number | if `sourceElementId` and `destinationElementId` are unset | end Y coordinate | 220
331
+ duration | number | yes | The number of float seconds to hold the touch | 2.5
332
+ velocity | number | no | Dragging velocity in pixels per second. If not provided then the default velocity is used. See official documentation on [XCUIGestureVelocity structure](https://developer.apple.com/documentation/xctest/xcuigesturevelocity) for more details | 2500
333
+ keyModifierFlags | number | no | if set then the given key modifiers will be applied while the gesture is performed. See the official documentation on [XCUIKeyModifierFlags enumeration](https://developer.apple.com/documentation/xctest/xcuikeymodifierflags) for more details | `1 << 1 | 1 << 2`
334
+
335
+ #### References
336
+
337
+ - [pressForDuration:thenDragToElement:withVelocity:thenHoldForDuration: (XCUIElement)](https://developer.apple.com/documentation/xctest/xcuielement/3551693-pressforduration?language=objc)
338
+ - [pressForDuration:thenDragToCoordinate:withVelocity:thenHoldForDuration: (XCUICoordinate)](https://developer.apple.com/documentation/xctest/xcuicoordinate/3551692-pressforduration?language=objc)
339
+
193
340
  ### macos: keys
194
341
 
195
342
  Send keys to the given element or to the application under test
@@ -198,9 +345,13 @@ Send keys to the given element or to the application under test
198
345
 
199
346
  Name | Type | Required | Description | Example
200
347
  --- | --- | --- | --- | ---
201
- element | string | no | Unique identifier of the element to send the keys to. If unset then keys are sent to the current application under test. | 21045BC8-013C-43BD-9B1E-4C6DC7AB0744
348
+ elementId ("element" prior to Appium v 1.22) | string | no | Unique identifier of the element to send the keys to. If unset then keys are sent to the current application under test. | 21045BC8-013C-43BD-9B1E-4C6DC7AB0744
202
349
  keys | array | yes | Array of keys to type. Each item could either be a string, that represents a key itself (see the official documentation on XCUIElement's [typeKey:modifierFlags: method](https://developer.apple.com/documentation/xctest/xcuielement/1500604-typekey?language=objc) and on [XCUIKeyboardKey constants](https://developer.apple.com/documentation/xctest/xcuikeyboardkey?language=objc)) or a dictionary with `key` and `modifierFlags` entries, if the key should also be entered with modifiers. | ['h', 'i'] or [{key: 'h', modifierFlags: 1 << 1}, {key: 'i', modifierFlags: 1 << 2}] or ['XCUIKeyboardKeyEscape'] |
203
350
 
351
+ #### References
352
+
353
+ - [typeKey:modifierFlags:](https://developer.apple.com/documentation/xctest/xcuielement/1500604-typekey?language=objc)
354
+
204
355
  ### macos: source
205
356
 
206
357
  Retrieves the string representation of the current application
@@ -287,6 +438,7 @@ Name | Type | Required | Description | Example
287
438
  --- | --- | --- | --- | ---
288
439
  command | string | yes if `script` is not provided | AppleScript command to execute | `do shell script "echo hello"`
289
440
  script | string | yes if `command` is not provided | AppleScript script to execute | `do shell script "echo hello"\ndo shell script "echo hello2"`
441
+ language | string | no | Overrides the scripting language. Basically, sets the value of `-l` command line argument of `osascript` tool. If unset the AppleScript language is assumed. | JavaScript
290
442
  timeout | number | no | The number of seconds to wait until a long-running blocking command is finished. An error is thrown if the command is still running after this timeout expires. | 60000
291
443
  cwd | string | no | The path to an existing folder which is going to be set as the working directory for the command/script being executed. | `/tmp`
292
444
 
@@ -0,0 +1,56 @@
1
+ /*
2
+ * Licensed under the Apache License, Version 2.0 (the "License");
3
+ * you may not use this file except in compliance with the License.
4
+ * See the NOTICE file distributed with this work for additional
5
+ * information regarding copyright ownership.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #import <XCTest/XCTest.h>
18
+
19
+ #import "AMIntegrationTestCase.h"
20
+ #import "XCUIElement+AMSwipe.h"
21
+ #import "XCUICoordinate+AMSwipe.h"
22
+
23
+ @interface AMVariousElementTests : AMIntegrationTestCase
24
+ @end
25
+
26
+ @implementation AMVariousElementTests
27
+
28
+ - (void)setUp
29
+ {
30
+ [super setUp];
31
+ static dispatch_once_t onceToken;
32
+ dispatch_once(&onceToken, ^{
33
+ [self launchApplication];
34
+ });
35
+ }
36
+
37
+ - (void)testSwipeElement
38
+ {
39
+ XCUIElement *slider = self.testedApplication.sliders.firstMatch;
40
+ NSError *error;
41
+ XCTAssertTrue([slider am_swipeWithDirection:@"right" velocity:nil error:&error]);
42
+ XCTAssertNil(error);
43
+ }
44
+
45
+ - (void)testSwipeCoordinates
46
+ {
47
+ XCUIElement *slider = self.testedApplication.sliders.firstMatch;
48
+ NSError *error;
49
+ XCUICoordinate *destPoint = [slider coordinateWithNormalizedOffset:CGVectorMake(0.5, 0.5)];
50
+ XCTAssertTrue([destPoint am_swipeWithDirection:@"right"
51
+ velocity:@(200)
52
+ error:&error]);
53
+ XCTAssertNil(error);
54
+ }
55
+
56
+ @end
@@ -0,0 +1,38 @@
1
+ /*
2
+ * Licensed under the Apache License, Version 2.0 (the "License");
3
+ * you may not use this file except in compliance with the License.
4
+ * See the NOTICE file distributed with this work for additional
5
+ * information regarding copyright ownership.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #import <XCTest/XCTest.h>
18
+
19
+ NS_ASSUME_NONNULL_BEGIN
20
+
21
+ @interface XCUICoordinate (AMSwipe)
22
+
23
+ /**
24
+ * Performs swipe gesture on the coordinate
25
+ *
26
+ * @param direction Swipe direction. The following values are supported: up, down, left and right
27
+ * @param velocity Swipe speed in pixels per second. This parameter is only supported since Xcode 11.4
28
+ * nil value means that the default velocity is going to be used.
29
+ * @param error The actual error description if the method fails to perform swipe
30
+ * @returns YES if the swipe action was successful
31
+ */
32
+ - (BOOL)am_swipeWithDirection:(NSString *)direction
33
+ velocity:(nullable NSNumber *)velocity
34
+ error:(NSError **)error;
35
+
36
+ @end
37
+
38
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,31 @@
1
+ /*
2
+ * Licensed under the Apache License, Version 2.0 (the "License");
3
+ * you may not use this file except in compliance with the License.
4
+ * See the NOTICE file distributed with this work for additional
5
+ * information regarding copyright ownership.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #import "XCUICoordinate+AMSwipe.h"
18
+
19
+ #import "AMSwipeHelpers.h"
20
+
21
+ @implementation XCUICoordinate (AMSwipe)
22
+
23
+
24
+ - (BOOL)am_swipeWithDirection:(NSString *)direction
25
+ velocity:(nullable NSNumber *)velocity
26
+ error:(NSError **)error
27
+ {
28
+ return AMPerformSwipe(self, direction, velocity, error);
29
+ }
30
+
31
+ @end
@@ -0,0 +1,38 @@
1
+ /*
2
+ * Licensed under the Apache License, Version 2.0 (the "License");
3
+ * you may not use this file except in compliance with the License.
4
+ * See the NOTICE file distributed with this work for additional
5
+ * information regarding copyright ownership.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #import <XCTest/XCTest.h>
18
+
19
+ NS_ASSUME_NONNULL_BEGIN
20
+
21
+ @interface XCUIElement (AMSwipe)
22
+
23
+ /**
24
+ * Performs swipe gesture on the element
25
+ *
26
+ * @param direction Swipe direction. The following values are supported: up, down, left and right
27
+ * @param velocity Swipe speed in pixels per second. This parameter is only supported since Xcode 11.4
28
+ * nil value means that the default velocity is going to be used.
29
+ * @param error The actual error description if the method fails to perform swipe
30
+ * @returns YES if the swipe action was successful
31
+ */
32
+ - (BOOL)am_swipeWithDirection:(NSString *)direction
33
+ velocity:(nullable NSNumber *)velocity
34
+ error:(NSError **)error;
35
+
36
+ @end
37
+
38
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,30 @@
1
+ /*
2
+ * Licensed under the Apache License, Version 2.0 (the "License");
3
+ * you may not use this file except in compliance with the License.
4
+ * See the NOTICE file distributed with this work for additional
5
+ * information regarding copyright ownership.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #import "XCUIElement+AMSwipe.h"
18
+
19
+ #import "AMSwipeHelpers.h"
20
+
21
+ @implementation XCUIElement (AMSwipe)
22
+
23
+ - (BOOL)am_swipeWithDirection:(NSString *)direction
24
+ velocity:(nullable NSNumber *)velocity
25
+ error:(NSError **)error
26
+ {
27
+ return AMPerformSwipe(self, direction, velocity, error);
28
+ }
29
+
30
+ @end