【问题标题】:UITest interruption handler calling tap() twiceUITest 中断处理程序调用 tap() 两次
【发布时间】:2019-11-21 12:38:10
【问题描述】:

我的 UITest 需要点击一个按钮,并且 UIInteruptionMonitor 应该处理它。但是,发生的情况是按钮被点击,中断出现并得到处理,然后它尝试再次点击按钮。它似乎认为它实际上并没有点击按钮......

我有以下代码:

addUIInterruptionMonitor(withDescription: "Permissions") { alert -> Bool in
    let okButton = alert.buttons["OK"]
    if okButton.exists {
      okButton.tap()
    }

    return true
}

app.buttons["Enable"].tap()

会发生以下情况:

t =    91.24s     Find the "Enable" Button
    t =    91.40s     Check for interrupting elements affecting "Enable" Button
    t =    91.42s         Wait for com.apple.springboard to idle
    t =    91.85s     Found 1 interrupting element:
    t =    91.86s         Find the "“MyApp” Would Like to Access the Camera" Alert
    t =    92.03s         "“MyApp” Would Like to Access the Camera" Alert from Application 'com.apple.springboard'
    t =    92.03s     Invoking UI interruption monitors for "“MyApp” Would Like to Access the Camera" Alert from Application 'com.apple.springboard'
    t =    92.03s         Invoking Permissions
    t =    92.04s             Checking existence of `"OK" Button`
    t =    92.21s             Tap "OK" Button
    t =    92.21s                 Wait for com.apple.springboard to idle
    t =    92.50s                 Find the "OK" Button
    t =    92.66s                 Check for interrupting elements affecting "OK" Button
    t =    92.82s                 Synthesize event
    t =    93.14s                 Wait for com.apple.springboard to idle
    t =    93.54s         Verifying handling...
    t =    93.54s             Check for interrupting elements affecting "Enable" Button
    t =    93.55s                 Wait for com.apple.springboard to idle
    t =    94.10s         Confirmed successful handling of interrupting element
    t =    94.10s     Synthesize event
    t =    95.39s         Scroll element to visible
    t =    96.55s         Failed: Failed to scroll to visible (by AX action) Button, label: 'Enable', error: Error kAXErrorCannotComplete performing AXAction 2003 on element AX element pid: 62934, elementOrHash.elementID: 140664883255456.613
    t =    97.57s     Retrying `Tap "Enable" Button` (attempt #2)

【问题讨论】:

    标签: ios xcode-ui-testing


    【解决方案1】:

    这是正常的。当被系统警报中断时,无法执行预期的操作,因此在成功处理中断后重试。

    更一般地,你必须在处理程序中检查你是否成功处理了中断(例如你找到了确定按钮并可以点击它),否则你必须返回 false。

    【讨论】:

      猜你喜欢
      • 2012-09-17
      • 2018-10-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-17
      • 2011-08-29
      相关资源
      最近更新 更多