简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM