appium-webdriveragent 5.15.8 → 6.0.0
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
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
## [6.0.0](https://github.com/appium/WebDriverAgent/compare/v5.15.8...v6.0.0) (2024-01-31)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### ⚠ BREAKING CHANGES
|
|
5
|
+
|
|
6
|
+
* The /wda/tap/:uuid endpoint has been replaced by /wda/element/:uuid/tap and /wda/tap ones
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* Add coordinate-based APIs for gesture calls ([#843](https://github.com/appium/WebDriverAgent/issues/843)) ([feda373](https://github.com/appium/WebDriverAgent/commit/feda373b6147d3e87b29dceb871887c77febe76b))
|
|
11
|
+
|
|
1
12
|
## [5.15.8](https://github.com/appium/WebDriverAgent/compare/v5.15.7...v5.15.8) (2024-01-24)
|
|
2
13
|
|
|
3
14
|
|
|
@@ -22,4 +22,18 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
22
22
|
|
|
23
23
|
@end
|
|
24
24
|
|
|
25
|
+
#if !TARGET_OS_TV
|
|
26
|
+
@interface XCUICoordinate (FBSwiping)
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Performs swipe gesture on the coordinate
|
|
30
|
+
*
|
|
31
|
+
* @param direction Swipe direction. The following values are supported: up, down, left and right
|
|
32
|
+
* @param velocity Swipe speed in pixels per second
|
|
33
|
+
*/
|
|
34
|
+
- (void)fb_swipeWithDirection:(NSString *)direction velocity:(nullable NSNumber*)velocity;
|
|
35
|
+
|
|
36
|
+
@end
|
|
37
|
+
#endif
|
|
38
|
+
|
|
25
39
|
NS_ASSUME_NONNULL_END
|
|
@@ -12,29 +12,46 @@
|
|
|
12
12
|
#import "FBLogger.h"
|
|
13
13
|
#import "XCUIElement.h"
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
- (void)fb_swipeWithDirection:(NSString *)direction velocity:(nullable NSNumber*)velocity
|
|
18
|
-
{
|
|
15
|
+
void swipeWithDirection(NSObject *target, NSString *direction, NSNumber* _Nullable velocity) {
|
|
19
16
|
double velocityValue = .0;
|
|
20
17
|
if (nil != velocity) {
|
|
21
18
|
velocityValue = [velocity doubleValue];
|
|
22
19
|
}
|
|
23
20
|
|
|
24
21
|
if (velocityValue > 0) {
|
|
25
|
-
SEL selector = NSSelectorFromString([NSString stringWithFormat:@"swipe%@WithVelocity:",
|
|
26
|
-
|
|
22
|
+
SEL selector = NSSelectorFromString([NSString stringWithFormat:@"swipe%@WithVelocity:",
|
|
23
|
+
direction.lowercaseString.capitalizedString]);
|
|
24
|
+
NSMethodSignature *signature = [target methodSignatureForSelector:selector];
|
|
27
25
|
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
|
|
28
26
|
[invocation setSelector:selector];
|
|
29
27
|
[invocation setArgument:&velocityValue atIndex:2];
|
|
30
|
-
[invocation invokeWithTarget:
|
|
28
|
+
[invocation invokeWithTarget:target];
|
|
31
29
|
} else {
|
|
32
|
-
SEL selector = NSSelectorFromString([NSString stringWithFormat:@"swipe%@",
|
|
33
|
-
|
|
30
|
+
SEL selector = NSSelectorFromString([NSString stringWithFormat:@"swipe%@",
|
|
31
|
+
direction.lowercaseString.capitalizedString]);
|
|
32
|
+
NSMethodSignature *signature = [target methodSignatureForSelector:selector];
|
|
34
33
|
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
|
|
35
34
|
[invocation setSelector:selector];
|
|
36
|
-
[invocation invokeWithTarget:
|
|
35
|
+
[invocation invokeWithTarget:target];
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
38
|
|
|
39
|
+
@implementation XCUIElement (FBSwiping)
|
|
40
|
+
|
|
41
|
+
- (void)fb_swipeWithDirection:(NSString *)direction velocity:(nullable NSNumber*)velocity
|
|
42
|
+
{
|
|
43
|
+
swipeWithDirection(self, direction, velocity);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@end
|
|
47
|
+
|
|
48
|
+
#if !TARGET_OS_TV
|
|
49
|
+
@implementation XCUICoordinate (FBSwiping)
|
|
50
|
+
|
|
51
|
+
- (void)fb_swipeWithDirection:(NSString *)direction velocity:(nullable NSNumber*)velocity
|
|
52
|
+
{
|
|
53
|
+
swipeWithDirection(self, direction, velocity);
|
|
54
|
+
}
|
|
55
|
+
|
|
40
56
|
@end
|
|
57
|
+
#endif
|
|
@@ -74,24 +74,46 @@
|
|
|
74
74
|
[[FBRoute POST:@"/wda/element/:uuid/focuse"] respondWithTarget:self action:@selector(handleFocuse:)],
|
|
75
75
|
#else
|
|
76
76
|
[[FBRoute POST:@"/wda/element/:uuid/swipe"] respondWithTarget:self action:@selector(handleSwipe:)],
|
|
77
|
+
[[FBRoute POST:@"/wda/swipe"] respondWithTarget:self action:@selector(handleSwipe:)],
|
|
78
|
+
|
|
77
79
|
[[FBRoute POST:@"/wda/element/:uuid/pinch"] respondWithTarget:self action:@selector(handlePinch:)],
|
|
80
|
+
[[FBRoute POST:@"/wda/pinch"] respondWithTarget:self action:@selector(handlePinch:)],
|
|
81
|
+
|
|
78
82
|
[[FBRoute POST:@"/wda/element/:uuid/rotate"] respondWithTarget:self action:@selector(handleRotate:)],
|
|
83
|
+
[[FBRoute POST:@"/wda/rotate"] respondWithTarget:self action:@selector(handleRotate:)],
|
|
84
|
+
|
|
79
85
|
[[FBRoute POST:@"/wda/element/:uuid/doubleTap"] respondWithTarget:self action:@selector(handleDoubleTap:)],
|
|
86
|
+
[[FBRoute POST:@"/wda/doubleTap"] respondWithTarget:self action:@selector(handleDoubleTap:)],
|
|
87
|
+
|
|
80
88
|
[[FBRoute POST:@"/wda/element/:uuid/twoFingerTap"] respondWithTarget:self action:@selector(handleTwoFingerTap:)],
|
|
81
|
-
[[FBRoute POST:@"/wda/
|
|
89
|
+
[[FBRoute POST:@"/wda/twoFingerTap"] respondWithTarget:self action:@selector(handleTwoFingerTap:)],
|
|
90
|
+
|
|
91
|
+
[[FBRoute POST:@"/wda/element/:uuid/tapWithNumberOfTaps"] respondWithTarget:self
|
|
92
|
+
action:@selector(handleTapWithNumberOfTaps:)],
|
|
93
|
+
[[FBRoute POST:@"/wda/tapWithNumberOfTaps"] respondWithTarget:self
|
|
94
|
+
action:@selector(handleTapWithNumberOfTaps:)],
|
|
95
|
+
|
|
82
96
|
[[FBRoute POST:@"/wda/element/:uuid/touchAndHold"] respondWithTarget:self action:@selector(handleTouchAndHold:)],
|
|
97
|
+
[[FBRoute POST:@"/wda/touchAndHold"] respondWithTarget:self action:@selector(handleTouchAndHold:)],
|
|
98
|
+
|
|
83
99
|
[[FBRoute POST:@"/wda/element/:uuid/scroll"] respondWithTarget:self action:@selector(handleScroll:)],
|
|
100
|
+
[[FBRoute POST:@"/wda/scroll"] respondWithTarget:self action:@selector(handleScroll:)],
|
|
101
|
+
|
|
84
102
|
[[FBRoute POST:@"/wda/element/:uuid/scrollTo"] respondWithTarget:self action:@selector(handleScrollTo:)],
|
|
103
|
+
|
|
85
104
|
[[FBRoute POST:@"/wda/element/:uuid/dragfromtoforduration"] respondWithTarget:self action:@selector(handleDrag:)],
|
|
105
|
+
[[FBRoute POST:@"/wda/dragfromtoforduration"] respondWithTarget:self action:@selector(handleDrag:)],
|
|
106
|
+
|
|
86
107
|
[[FBRoute POST:@"/wda/element/:uuid/pressAndDragWithVelocity"] respondWithTarget:self action:@selector(handlePressAndDragWithVelocity:)],
|
|
87
|
-
[[FBRoute POST:@"/wda/element/:uuid/forceTouch"] respondWithTarget:self action:@selector(handleForceTouch:)],
|
|
88
|
-
[[FBRoute POST:@"/wda/dragfromtoforduration"] respondWithTarget:self action:@selector(handleDragCoordinate:)],
|
|
89
108
|
[[FBRoute POST:@"/wda/pressAndDragWithVelocity"] respondWithTarget:self action:@selector(handlePressAndDragCoordinateWithVelocity:)],
|
|
90
|
-
|
|
91
|
-
[[FBRoute POST:@"/wda/
|
|
92
|
-
[[FBRoute POST:@"/wda/doubleTap"] respondWithTarget:self action:@selector(handleDoubleTapCoordinate:)],
|
|
93
|
-
[[FBRoute POST:@"/wda/pickerwheel/:uuid/select"] respondWithTarget:self action:@selector(handleWheelSelect:)],
|
|
109
|
+
|
|
110
|
+
[[FBRoute POST:@"/wda/element/:uuid/forceTouch"] respondWithTarget:self action:@selector(handleForceTouch:)],
|
|
94
111
|
[[FBRoute POST:@"/wda/forceTouch"] respondWithTarget:self action:@selector(handleForceTouch:)],
|
|
112
|
+
|
|
113
|
+
[[FBRoute POST:@"/wda/element/:uuid/tap"] respondWithTarget:self action:@selector(handleTap:)],
|
|
114
|
+
[[FBRoute POST:@"/wda/tap"] respondWithTarget:self action:@selector(handleTap:)],
|
|
115
|
+
|
|
116
|
+
[[FBRoute POST:@"/wda/pickerwheel/:uuid/select"] respondWithTarget:self action:@selector(handleWheelSelect:)],
|
|
95
117
|
#endif
|
|
96
118
|
[[FBRoute POST:@"/wda/keys"] respondWithTarget:self action:@selector(handleKeys:)],
|
|
97
119
|
];
|
|
@@ -285,38 +307,30 @@
|
|
|
285
307
|
#else
|
|
286
308
|
+ (id<FBResponsePayload>)handleDoubleTap:(FBRouteRequest *)request
|
|
287
309
|
{
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
{
|
|
296
|
-
CGVector offset = CGVectorMake([request.arguments[@"x"] doubleValue],
|
|
297
|
-
[request.arguments[@"y"] doubleValue]);
|
|
298
|
-
XCUICoordinate *doubleTapCoordinate = [self.class gestureCoordinateWithOffset:offset
|
|
299
|
-
element:request.session.activeApplication];
|
|
300
|
-
[doubleTapCoordinate doubleTap];
|
|
310
|
+
NSError *error;
|
|
311
|
+
id target = [self targetWithXyCoordinatesFromRequest:request error:&error];
|
|
312
|
+
if (nil == target) {
|
|
313
|
+
return FBResponseWithStatus([FBCommandStatus invalidArgumentErrorWithMessage:error.localizedDescription
|
|
314
|
+
traceback:nil]);
|
|
315
|
+
}
|
|
316
|
+
[target doubleTap];
|
|
301
317
|
return FBResponseWithOK();
|
|
302
318
|
}
|
|
303
319
|
|
|
304
320
|
+ (id<FBResponsePayload>)handleTwoFingerTap:(FBRouteRequest *)request
|
|
305
321
|
{
|
|
306
|
-
|
|
307
|
-
XCUIElement *element = [elementCache elementForUUID:(NSString *)request.parameters[@"uuid"]];
|
|
322
|
+
XCUIElement *element = [self targetFromRequest:request];
|
|
308
323
|
[element twoFingerTap];
|
|
309
324
|
return FBResponseWithOK();
|
|
310
325
|
}
|
|
311
326
|
|
|
312
327
|
+ (id<FBResponsePayload>)handleTapWithNumberOfTaps:(FBRouteRequest *)request
|
|
313
328
|
{
|
|
314
|
-
FBElementCache *elementCache = request.session.elementCache;
|
|
315
329
|
if (nil == request.arguments[@"numberOfTaps"] || nil == request.arguments[@"numberOfTouches"]) {
|
|
316
330
|
return FBResponseWithStatus([FBCommandStatus invalidArgumentErrorWithMessage:@"Both 'numberOfTaps' and 'numberOfTouches' arguments must be provided"
|
|
317
331
|
traceback:nil]);
|
|
318
332
|
}
|
|
319
|
-
XCUIElement *element = [
|
|
333
|
+
XCUIElement *element = [self targetFromRequest:request];
|
|
320
334
|
[element tapWithNumberOfTaps:[request.arguments[@"numberOfTaps"] integerValue]
|
|
321
335
|
numberOfTouches:[request.arguments[@"numberOfTouches"] integerValue]];
|
|
322
336
|
return FBResponseWithOK();
|
|
@@ -324,26 +338,20 @@
|
|
|
324
338
|
|
|
325
339
|
+ (id<FBResponsePayload>)handleTouchAndHold:(FBRouteRequest *)request
|
|
326
340
|
{
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
{
|
|
335
|
-
CGVector offset = CGVectorMake([request.arguments[@"x"] doubleValue],
|
|
336
|
-
[request.arguments[@"y"] doubleValue]);
|
|
337
|
-
XCUICoordinate *pressCoordinate = [self.class gestureCoordinateWithOffset:offset
|
|
338
|
-
element:request.session.activeApplication];
|
|
339
|
-
[pressCoordinate pressForDuration:[request.arguments[@"duration"] doubleValue]];
|
|
341
|
+
NSError *error;
|
|
342
|
+
id target = [self targetWithXyCoordinatesFromRequest:request error:&error];
|
|
343
|
+
if (nil == target) {
|
|
344
|
+
return FBResponseWithStatus([FBCommandStatus invalidArgumentErrorWithMessage:error.localizedDescription
|
|
345
|
+
traceback:nil]);
|
|
346
|
+
}
|
|
347
|
+
[target pressForDuration:[request.arguments[@"duration"] doubleValue]];
|
|
340
348
|
return FBResponseWithOK();
|
|
341
349
|
}
|
|
342
350
|
|
|
343
351
|
+ (id<FBResponsePayload>)handlePressAndDragWithVelocity:(FBRouteRequest *)request
|
|
344
352
|
{
|
|
345
353
|
FBElementCache *elementCache = request.session.elementCache;
|
|
346
|
-
XCUIElement *element = [
|
|
354
|
+
XCUIElement *element = [self targetFromRequest:request];
|
|
347
355
|
if (![element respondsToSelector:@selector(pressForDuration:thenDragToElement:withVelocity:thenHoldForDuration:)]) {
|
|
348
356
|
return FBResponseWithStatus([FBCommandStatus unsupportedOperationErrorWithMessage:@"This method is only supported in Xcode 12 and above"
|
|
349
357
|
traceback:nil]);
|
|
@@ -379,8 +387,7 @@
|
|
|
379
387
|
|
|
380
388
|
+ (id<FBResponsePayload>)handleScroll:(FBRouteRequest *)request
|
|
381
389
|
{
|
|
382
|
-
|
|
383
|
-
XCUIElement *element = [elementCache elementForUUID:(NSString *)request.parameters[@"uuid"]];
|
|
390
|
+
XCUIElement *element = [self targetFromRequest:request];
|
|
384
391
|
// Using presence of arguments as a way to convey control flow seems like a pretty bad idea but it's
|
|
385
392
|
// what ios-driver did and sadly, we must copy them.
|
|
386
393
|
NSString *const name = request.arguments[@"name"];
|
|
@@ -440,33 +447,18 @@
|
|
|
440
447
|
traceback:nil]);
|
|
441
448
|
}
|
|
442
449
|
|
|
443
|
-
+ (id<FBResponsePayload>)handleDragCoordinate:(FBRouteRequest *)request
|
|
444
|
-
{
|
|
445
|
-
FBSession *session = request.session;
|
|
446
|
-
CGVector startOffset = CGVectorMake([request.arguments[@"fromX"] doubleValue],
|
|
447
|
-
[request.arguments[@"fromY"] doubleValue]);
|
|
448
|
-
XCUICoordinate *startCoordinate = [self.class gestureCoordinateWithOffset:startOffset
|
|
449
|
-
element:session.activeApplication];
|
|
450
|
-
CGVector endOffset = CGVectorMake([request.arguments[@"toX"] doubleValue],
|
|
451
|
-
[request.arguments[@"toY"] doubleValue]);
|
|
452
|
-
XCUICoordinate *endCoordinate = [self.class gestureCoordinateWithOffset:endOffset
|
|
453
|
-
element:session.activeApplication];
|
|
454
|
-
NSTimeInterval duration = [request.arguments[@"duration"] doubleValue];
|
|
455
|
-
[startCoordinate pressForDuration:duration thenDragToCoordinate:endCoordinate];
|
|
456
|
-
return FBResponseWithOK();
|
|
457
|
-
}
|
|
458
|
-
|
|
459
450
|
+ (id<FBResponsePayload>)handleDrag:(FBRouteRequest *)request
|
|
460
451
|
{
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
452
|
+
NSString *elementUdid = (NSString *)request.parameters[@"uuid"];
|
|
453
|
+
XCUIElement *target = nil == elementUdid
|
|
454
|
+
? request.session.activeApplication
|
|
455
|
+
: [request.session.elementCache elementForUUID:elementUdid];
|
|
464
456
|
CGVector startOffset = CGVectorMake([request.arguments[@"fromX"] doubleValue],
|
|
465
457
|
[request.arguments[@"fromY"] doubleValue]);
|
|
466
|
-
XCUICoordinate *startCoordinate = [self.class gestureCoordinateWithOffset:startOffset element:
|
|
458
|
+
XCUICoordinate *startCoordinate = [self.class gestureCoordinateWithOffset:startOffset element:target];
|
|
467
459
|
CGVector endOffset = CGVectorMake([request.arguments[@"toX"] doubleValue],
|
|
468
460
|
[request.arguments[@"toY"] doubleValue]);
|
|
469
|
-
XCUICoordinate *endCoordinate = [self.class gestureCoordinateWithOffset:endOffset element:
|
|
461
|
+
XCUICoordinate *endCoordinate = [self.class gestureCoordinateWithOffset:endOffset element:target];
|
|
470
462
|
NSTimeInterval duration = [request.arguments[@"duration"] doubleValue];
|
|
471
463
|
[startCoordinate pressForDuration:duration thenDragToCoordinate:endCoordinate];
|
|
472
464
|
return FBResponseWithOK();
|
|
@@ -474,39 +466,41 @@
|
|
|
474
466
|
|
|
475
467
|
+ (id<FBResponsePayload>)handleSwipe:(FBRouteRequest *)request
|
|
476
468
|
{
|
|
477
|
-
FBElementCache *elementCache = request.session.elementCache;
|
|
478
|
-
XCUIElement *element = [elementCache elementForUUID:(NSString *)request.parameters[@"uuid"]];
|
|
479
469
|
NSString *const direction = request.arguments[@"direction"];
|
|
480
470
|
if (!direction) {
|
|
481
471
|
return FBResponseWithStatus([FBCommandStatus invalidArgumentErrorWithMessage:@"Missing 'direction' parameter" traceback:nil]);
|
|
482
472
|
}
|
|
483
473
|
NSArray<NSString *> *supportedDirections = @[@"up", @"down", @"left", @"right"];
|
|
484
474
|
if (![supportedDirections containsObject:direction.lowercaseString]) {
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
475
|
+
NSString *message = [NSString stringWithFormat:@"Unsupported swipe direction '%@'. Only the following directions are supported: %@", direction, supportedDirections];
|
|
476
|
+
return FBResponseWithStatus([FBCommandStatus invalidArgumentErrorWithMessage:message
|
|
477
|
+
traceback:nil]);
|
|
488
478
|
}
|
|
489
|
-
|
|
479
|
+
NSError *error;
|
|
480
|
+
id target = [self targetWithXyCoordinatesFromRequest:request error:&error];
|
|
481
|
+
if (nil == target) {
|
|
482
|
+
return FBResponseWithStatus([FBCommandStatus invalidArgumentErrorWithMessage:error.localizedDescription
|
|
483
|
+
traceback:nil]);
|
|
484
|
+
}
|
|
485
|
+
[target fb_swipeWithDirection:direction velocity:request.arguments[@"velocity"]];
|
|
490
486
|
return FBResponseWithOK();
|
|
491
487
|
}
|
|
492
488
|
|
|
493
489
|
+ (id<FBResponsePayload>)handleTap:(FBRouteRequest *)request
|
|
494
490
|
{
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
[tapCoordinate tap];
|
|
491
|
+
NSError *error;
|
|
492
|
+
id target = [self targetWithXyCoordinatesFromRequest:request error:&error];
|
|
493
|
+
if (nil == target) {
|
|
494
|
+
return FBResponseWithStatus([FBCommandStatus invalidArgumentErrorWithMessage:error.localizedDescription
|
|
495
|
+
traceback:nil]);
|
|
496
|
+
}
|
|
497
|
+
[target tap];
|
|
503
498
|
return FBResponseWithOK();
|
|
504
499
|
}
|
|
505
500
|
|
|
506
501
|
+ (id<FBResponsePayload>)handlePinch:(FBRouteRequest *)request
|
|
507
502
|
{
|
|
508
|
-
|
|
509
|
-
XCUIElement *element = [elementCache elementForUUID:(NSString *)request.parameters[@"uuid"]];
|
|
503
|
+
XCUIElement *element = [self targetFromRequest:request];
|
|
510
504
|
CGFloat scale = (CGFloat)[request.arguments[@"scale"] doubleValue];
|
|
511
505
|
CGFloat velocity = (CGFloat)[request.arguments[@"velocity"] doubleValue];
|
|
512
506
|
[element pinchWithScale:scale velocity:velocity];
|
|
@@ -515,8 +509,7 @@
|
|
|
515
509
|
|
|
516
510
|
+ (id<FBResponsePayload>)handleRotate:(FBRouteRequest *)request
|
|
517
511
|
{
|
|
518
|
-
|
|
519
|
-
XCUIElement *element = [elementCache elementForUUID:(NSString *)request.parameters[@"uuid"]];
|
|
512
|
+
XCUIElement *element = [self targetFromRequest:request];
|
|
520
513
|
CGFloat rotation = (CGFloat)[request.arguments[@"rotation"] doubleValue];
|
|
521
514
|
CGFloat velocity = (CGFloat)[request.arguments[@"velocity"] doubleValue];
|
|
522
515
|
[element rotate:rotation withVelocity:velocity];
|
|
@@ -525,13 +518,7 @@
|
|
|
525
518
|
|
|
526
519
|
+ (id<FBResponsePayload>)handleForceTouch:(FBRouteRequest *)request
|
|
527
520
|
{
|
|
528
|
-
XCUIElement *element =
|
|
529
|
-
if (nil == request.parameters[@"uuid"]) {
|
|
530
|
-
element = XCUIApplication.fb_activeApplication;
|
|
531
|
-
} else {
|
|
532
|
-
FBElementCache *elementCache = request.session.elementCache;
|
|
533
|
-
element = [elementCache elementForUUID:(NSString *)request.parameters[@"uuid"]];
|
|
534
|
-
}
|
|
521
|
+
XCUIElement *element = [self targetFromRequest:request];
|
|
535
522
|
NSNumber *pressure = request.arguments[@"pressure"];
|
|
536
523
|
NSNumber *duration = request.arguments[@"duration"];
|
|
537
524
|
NSNumber *x = request.arguments[@"x"];
|
|
@@ -673,6 +660,45 @@ static const NSInteger DEFAULT_MAX_PICKER_ATTEMPTS = 25;
|
|
|
673
660
|
return [[element coordinateWithNormalizedOffset:CGVectorMake(0, 0)] coordinateWithOffset:offset];
|
|
674
661
|
}
|
|
675
662
|
|
|
663
|
+
/**
|
|
664
|
+
Returns either coordinates or the target element for the given request that expects 'x' and 'y' coordannates
|
|
665
|
+
|
|
666
|
+
@param request HTTP request object
|
|
667
|
+
@param error Error instance if any
|
|
668
|
+
@return Either XCUICoordinate or XCUIElement instance. nil if the input data is invalid
|
|
669
|
+
*/
|
|
670
|
+
+ (nullable id)targetWithXyCoordinatesFromRequest:(FBRouteRequest *)request error:(NSError **)error
|
|
671
|
+
{
|
|
672
|
+
NSNumber *x = request.arguments[@"x"];
|
|
673
|
+
NSNumber *y = request.arguments[@"y"];
|
|
674
|
+
if (nil == x && nil == y) {
|
|
675
|
+
return [self targetFromRequest:request];
|
|
676
|
+
}
|
|
677
|
+
if ((nil == x && nil != y) || (nil != x && nil == y)) {
|
|
678
|
+
[[[FBErrorBuilder alloc]
|
|
679
|
+
withDescription:@"Both x and y coordinates must be provided"]
|
|
680
|
+
buildError:error];
|
|
681
|
+
return nil;
|
|
682
|
+
}
|
|
683
|
+
return [self gestureCoordinateWithOffset:CGVectorMake(x.doubleValue, y.doubleValue)
|
|
684
|
+
element:[self targetFromRequest:request]];
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
/**
|
|
688
|
+
Returns the target element for the given request
|
|
689
|
+
|
|
690
|
+
@param request HTTP request object
|
|
691
|
+
@return Matching XCUIElement instance
|
|
692
|
+
*/
|
|
693
|
+
+ (XCUIElement *)targetFromRequest:(FBRouteRequest *)request
|
|
694
|
+
{
|
|
695
|
+
FBElementCache *elementCache = request.session.elementCache;
|
|
696
|
+
NSString *elementUuid = (NSString *)request.parameters[@"uuid"];
|
|
697
|
+
return nil == elementUuid
|
|
698
|
+
? request.session.activeApplication
|
|
699
|
+
: [elementCache elementForUUID:elementUuid];
|
|
700
|
+
}
|
|
701
|
+
|
|
676
702
|
#endif
|
|
677
703
|
|
|
678
704
|
@end
|