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

636 views Asked by At

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)
}
1

There are 1 answers

1
Andy Obusek On BEST ANSWER

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))")