Skip to content

Commit

Permalink
Merge pull request #56 from appium/master
Browse files Browse the repository at this point in the history
Fork Sync: Update from parent repository
  • Loading branch information
github-actions[bot] authored Feb 1, 2024
2 parents 1ad9436 + 925f358 commit 25c8978
Show file tree
Hide file tree
Showing 5 changed files with 165 additions and 97 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## [6.0.0](https://github.com/appium/WebDriverAgent/compare/v5.15.8...v6.0.0) (2024-01-31)


### ⚠ BREAKING CHANGES

* The /wda/tap/:uuid endpoint has been replaced by /wda/element/:uuid/tap and /wda/tap ones

### Features

* Add coordinate-based APIs for gesture calls ([#843](https://github.com/appium/WebDriverAgent/issues/843)) ([feda373](https://github.com/appium/WebDriverAgent/commit/feda373b6147d3e87b29dceb871887c77febe76b))

## [5.15.8](https://github.com/appium/WebDriverAgent/compare/v5.15.7...v5.15.8) (2024-01-24)


Expand Down
14 changes: 14 additions & 0 deletions WebDriverAgentLib/Categories/XCUIElement+FBSwiping.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,18 @@ NS_ASSUME_NONNULL_BEGIN

@end

#if !TARGET_OS_TV
@interface XCUICoordinate (FBSwiping)

/**
* Performs swipe gesture on the coordinate
*
* @param direction Swipe direction. The following values are supported: up, down, left and right
* @param velocity Swipe speed in pixels per second
*/
- (void)fb_swipeWithDirection:(NSString *)direction velocity:(nullable NSNumber*)velocity;

@end
#endif

NS_ASSUME_NONNULL_END
37 changes: 27 additions & 10 deletions WebDriverAgentLib/Categories/XCUIElement+FBSwiping.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,46 @@
#import "FBLogger.h"
#import "XCUIElement.h"

@implementation XCUIElement (FBSwiping)

- (void)fb_swipeWithDirection:(NSString *)direction velocity:(nullable NSNumber*)velocity
{
void swipeWithDirection(NSObject *target, NSString *direction, NSNumber* _Nullable velocity) {
double velocityValue = .0;
if (nil != velocity) {
velocityValue = [velocity doubleValue];
}

if (velocityValue > 0) {
SEL selector = NSSelectorFromString([NSString stringWithFormat:@"swipe%@WithVelocity:", direction.lowercaseString.capitalizedString]);
NSMethodSignature *signature = [self methodSignatureForSelector:selector];
SEL selector = NSSelectorFromString([NSString stringWithFormat:@"swipe%@WithVelocity:",
direction.lowercaseString.capitalizedString]);
NSMethodSignature *signature = [target methodSignatureForSelector:selector];
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
[invocation setSelector:selector];
[invocation setArgument:&velocityValue atIndex:2];
[invocation invokeWithTarget:self];
[invocation invokeWithTarget:target];
} else {
SEL selector = NSSelectorFromString([NSString stringWithFormat:@"swipe%@", direction.lowercaseString.capitalizedString]);
NSMethodSignature *signature = [self methodSignatureForSelector:selector];
SEL selector = NSSelectorFromString([NSString stringWithFormat:@"swipe%@",
direction.lowercaseString.capitalizedString]);
NSMethodSignature *signature = [target methodSignatureForSelector:selector];
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
[invocation setSelector:selector];
[invocation invokeWithTarget:self];
[invocation invokeWithTarget:target];
}
}

@implementation XCUIElement (FBSwiping)

- (void)fb_swipeWithDirection:(NSString *)direction velocity:(nullable NSNumber*)velocity
{
swipeWithDirection(self, direction, velocity);
}

@end

#if !TARGET_OS_TV
@implementation XCUICoordinate (FBSwiping)

- (void)fb_swipeWithDirection:(NSString *)direction velocity:(nullable NSNumber*)velocity
{
swipeWithDirection(self, direction, velocity);
}

@end
#endif
Loading

0 comments on commit 25c8978

Please sign in to comment.