【问题标题】:When using KIF test framework UIButton is not working for UIControlEventTouchUpInside当使用 KIF 测试框架 UIButton 不适用于 UIControlEventTouchUpInside
【发布时间】:2013-01-29 10:37:15
【问题描述】:

我尝试使用 KIF 框架制作一些场景。当我添加例如:

[scenario addStep:[KIFTestStep stepToTapViewWithAccessibilityLabel:@"MyUIButtonAccessibilityLabel"]];

UIControlEventTouchUpInside 不会为具有 accessibilityLabel @"MyUIButtonAccessibilityLabel" 的 UIButton 触发。

uigesturerecognizer 是否会干扰 KIF 中的 UIControlEventTouchUpInside?在 KIF 中是否有解决此问题的方法?

【问题讨论】:

    标签: objective-c uibutton uigesturerecognizer kif-framework kif


    【解决方案1】:

    我昨天真的遇到了这个。 stepToTapViewWithAccessibilityLabel 对我的应用程序中的所有内容都工作得很好,但我遇到了一个按钮,它绝对不能工作。

    为了解决这个问题,我最终使用了 stepToTapScreenAtPoint(我不是特别喜欢),但它似乎工作正常。我还在我的类别中添加了一个 void initialize 方法,以便我可以确定哪个设备在运行时执行测试,并据此确定我需要点击的确切位置:

    @implementation KIFTestStep (SLAdditions)
    
    static CGPoint kButtonLocation;
    
    + (void)initialize
    {
        if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
            kButtonLocation = CGPointMake(498.0, 622.0);
        else
            kButtonLocation = CGPointMake(247.0, 316.0);
    }
    
    + (NSArray *)stepsToDoSomething
    {
        NSMutableArray *steps = [NSMutableArray array];
    
        [steps addObject:[KIFTestStep stepToWaitForTappableViewWithAccessibilityLabel:@"The Button Label"]];
        [steps addObject:[KIFTestStep stepToTapScreenAtPoint:kButtonLocation]];
    
        // Verify that tapping succeeded
        [steps addObject:[KIFTestStep stepToWaitForAbsenceOfViewWithAccessibilityLabel:@"The Button Label"]];
    
        return steps;
    }
    

    【讨论】:

      猜你喜欢
      • 2014-12-04
      • 1970-01-01
      • 1970-01-01
      • 2015-07-13
      • 2020-12-14
      • 1970-01-01
      • 2020-03-04
      • 1970-01-01
      • 2018-05-05
      相关资源
      最近更新 更多