Skip to content

Instantly share code, notes, and snippets.

@matthewreagan
Created February 11, 2016 02:20
Show Gist options
  • Save matthewreagan/d5da35f7604da5673c24 to your computer and use it in GitHub Desktop.
Save matthewreagan/d5da35f7604da5673c24 to your computer and use it in GitHub Desktop.
Click-drag on XCUIElement category method
- (void)clickAtPoint:(CGPoint)pointInElement thenDragTo:(CGPoint)point2InElement
{
CGRect frame = self.frame;
CGFloat width = CGRectGetWidth(frame);
CGFloat height = CGRectGetHeight(frame);
XCUICoordinate *coord1 = [self coordinateWithNormalizedOffset:CGVectorMake(pointInElement.x / width, pointInElement.y / height)];
XCUICoordinate *coord2 = [coord1 coordinateWithOffset:CGVectorMake(point2InElement.x - pointInElement.x, point2InElement.y - pointInElement.y)];
[coord1 clickForDuration:0.1 thenDragToCoordinate:coord2];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment