XCTest Fast Swipe

Viewed 356

I'd like to create custom swipes for XCTest that are simply faster to shorten test duration:

public class func swipeLeftFast(element:XCUIElement)
{
    customSwipe(refElement: element, startCoord: CGVector(dx: 1, dy: 5), endCoord: CGVector(dx: -1, dy: 5))
}


public class func customSwipe(refElement:XCUIElement, startCoord:CGVector, endCoord:CGVector)
{
    let swipeStartPoint = refElement.coordinate(withNormalizedOffset: startCoord)
    let swipeEndPoint = refElement.coordinate(withNormalizedOffset: endCoord)
    swipeStartPoint.press(forDuration: 0.1, thenDragTo: swipeEndPoint)
}

However this is even slower than the default XCUIElement swipe API. Is it possible to create faster swipes and how can I understand the vector values used in above code? I suppose they are not concrete screen coordinates and if I set them for example to x:10, x:-10 respectively, the swipe will be very slow, if I set them to x:0.1, x:-0.1 the swipe will be too short to have any effect.

0 Answers
Related