4

这是相当开放的。

有没有人知道如何在 KIF 测试中测试下拉刷新功能?

4

2 回答 2

3

只需从屏幕顶部向下拖动到屏幕底部即可,对吗?KIF 在 UIView-KIFAdditions 类别中实现了以下方法:

- (void)dragFromPoint:(CGPoint)startPoint toPoint:(CGPoint)endPoint;

我继续为简单的拖动操作创建了以下测试步骤:

+ (id)stepToDragFromStartPoint:(CGPoint)startPoint toEndPoint:(CGPoint)endPoint
{
    NSString *description = [NSString stringWithFormat:@"Simulate dragging finger from point %.1f,%.1f to point %.1f,%.1f", startPoint.x, startPoint.y, endPoint.x, endPoint.y];
    return [KIFTestStep stepWithDescription:description executionBlock:^(KIFTestStep *step, NSError **error) {
        UIView *viewToSwipe = [UIApplication sharedApplication].keyWindow.subviews.lastObject;

        [viewToSwipe dragFromPoint:startPoint toPoint:endPoint];

        return KIFTestStepResultSuccess;
    }];
}

希望有帮助!

于 2013-03-22T21:30:22.507 回答
0

发布此问题一段时间后,KIF 开发了内置的“拉动刷新”功能。请参阅以下方法KIFUITestActor

- (void)pullToRefreshViewWithAccessibilityLabel:(NSString *)label pullDownDuration:(KIFPullToRefreshTiming) pullDownDuration;
- (void)pullToRefreshViewWithAccessibilityLabel:(NSString *)label value:(NSString *)value;
- (void)pullToRefreshAccessibilityElement:(UIAccessibilityElement *)element inView:(UIView *)viewToSwipe pullDownDuration:(KIFPullToRefreshTiming) pullDownDuration;
于 2016-11-01T16:41:24.357 回答