ioskifkif-framework

Use KIF to swipe from screen edge (test UIScreenEdgePanGestureRecognizer)?


As of yet I have been unable to do a edge swipe in KIF (specifically running KIF tests against a device). Has anyone pulled this off? Am I missing something?

Resulting function:

func panInViewFromLeftScreenEdge() {
    // Grab the menu & its frame.
    let menuView = UIApplication.sharedApplication().keyWindow!.subviews.last!
    let frame = menuView.bounds

    // Simulate a drag from the left edge to the right edge.
    let startPoint = CGPointMake(CGRectGetMinX(frame), CGRectGetMidY(frame))
    let endPoint = CGPointMake(CGRectGetMaxX(frame), CGRectGetMidY(frame))

    menuView.dragFromPoint(startPoint, toPoint: endPoint)
}

Solution

  • Try:

    let view = tester().waitForViewWithAccessibilityLabel("<The view controller on screen's view's accessibility label")
    view.dragFromPoint(CGPoint(x: 1, y: 150), toPoint: CGPoint(x: 40, y: 150))")