diff --git a/WebDriverAgentLib/Commands/FBElementCommands.m b/WebDriverAgentLib/Commands/FBElementCommands.m index 18f9167d4..4aeb66cfa 100644 --- a/WebDriverAgentLib/Commands/FBElementCommands.m +++ b/WebDriverAgentLib/Commands/FBElementCommands.m @@ -320,8 +320,10 @@ + (NSArray *)routes CGPoint startPoint = CGPointMake((CGFloat)[request.arguments[@"fromX"] doubleValue], (CGFloat)[request.arguments[@"fromY"] doubleValue]); CGPoint endPoint = CGPointMake((CGFloat)[request.arguments[@"toX"] doubleValue], (CGFloat)[request.arguments[@"toY"] doubleValue]); NSTimeInterval duration = [request.arguments[@"duration"] doubleValue]; - XCUICoordinate *endCoordinate = [self.class gestureCoordinateWithCoordinate:endPoint application:session.activeApplication shouldApplyOrientationWorkaround:isSDKVersionLessThan(@"11.0")]; - XCUICoordinate *startCoordinate = [self.class gestureCoordinateWithCoordinate:startPoint application:session.activeApplication shouldApplyOrientationWorkaround:isSDKVersionLessThan(@"11.0")]; + //XCUICoordinate *endCoordinate = [self.class gestureCoordinateWithCoordinate:endPoint application:session.activeApplication shouldApplyOrientationWorkaround:isSDKVersionLessThan(@"11.0")]; + //XCUICoordinate *startCoordinate = [self.class gestureCoordinateWithCoordinate:startPoint application:session.activeApplication shouldApplyOrientationWorkaround:isSDKVersionLessThan(@"11.0")]; + XCUICoordinate *startCoordinate = [self.class getGlobalCoordinateWithPoint:startPoint application:session.activeApplication shouldApplyOrientationWorkaround:isSDKVersionLessThan(@"11.0")]; + XCUICoordinate *endCoordinate = [self.class getGlobalCoordinateWithPoint:endPoint application:session.activeApplication shouldApplyOrientationWorkaround:isSDKVersionLessThan(@"11.0")]; [startCoordinate pressForDuration:duration thenDragToCoordinate:endCoordinate]; return FBResponseWithOK(); } @@ -363,12 +365,31 @@ + (NSArray *)routes return FBResponseWithOK(); } ++ (XCUICoordinate*)getGlobalCoordinateWithPoint:(CGPoint)point application:(XCUIApplication*)application shouldApplyOrientationWorkaround:(BOOL)shouldApplyOrientationWorkaround +{ + if (shouldApplyOrientationWorkaround) { + point = FBInvertPointForApplication(point, application.frame.size, application.interfaceOrientation); + } + return [[application coordinateWithNormalizedOffset:CGVectorMake(0.0, 0.0)] coordinateWithOffset:CGVectorMake(point.x, point.y)]; +} + ++ (id)customTapWithPoint:(CGPoint)point request:(FBRouteRequest*)request +{ + XCUICoordinate *coordinate = [self.class getGlobalCoordinateWithPoint:point application:request.session.activeApplication shouldApplyOrientationWorkaround:isSDKVersionLessThan(@"11.0")]; + [coordinate tap]; + return FBResponseWithOK(); +} + + + (id)handleTap:(FBRouteRequest *)request { FBElementCache *elementCache = request.session.elementCache; CGPoint tapPoint = CGPointMake((CGFloat)[request.arguments[@"x"] doubleValue], (CGFloat)[request.arguments[@"y"] doubleValue]); XCUIElement *element = [elementCache elementForUUID:request.parameters[@"uuid"]]; if (nil == element) { + if ([request.parameters[@"uuid"] isEqualToString:@"0"]) { + return [self.class customTapWithPoint:tapPoint request:request]; + } XCUICoordinate *tapCoordinate = [self.class gestureCoordinateWithCoordinate:tapPoint application:request.session.activeApplication shouldApplyOrientationWorkaround:isSDKVersionLessThan(@"11.0")]; [tapCoordinate tap]; } else {