【问题标题】:Recording tap on UISegmentedControl gets assertion fail during test在 UISegmentedControl 上记录点击在测试期间断言失败
【发布时间】:2018-08-17 19:20:00
【问题描述】:

我有一个带有三个按钮的分段控件,分别标记为“I”、“II”和奇怪的是“III”。

当我在模拟器中运行并记录时,它会发出以下形式的代码:

let app = XCUIApplication()
app.buttons["I"].tap()
app.buttons["II"].tap()
app.buttons["III"].tap()

当我执行这个测试时,它在 tap() 上崩溃,但表单除外:

Assertion Failure: <unknown>:0: Failed to scroll to visible (by AX action) Button, label: 'I', error: Error -25204 performing AXAction 2003 on element

我尝试通过它的分段控件向下钻取按钮:

let presetCtl = app.segmentedControls["preset"]
presetCtl.children(matching: .button).element(boundBy: 0).tap()

但这会在调用 tap() 时产生相同的断言失败:

Assertion Failure: <unknown>:0: Failed to scroll to visible (by AX action) Button,label: 'I', error: Error -25204 performing AXAction 2003 on element...

【问题讨论】:

    标签: ios xcode-ui-testing


    【解决方案1】:

    天啊,这看起来像是 XCode 中的一个错误,我在这里找到了解决方法:Xcode UI test - UI Testing Failure - Failed to scroll to visible (by AX action) when tap on Search field "Cancel' button

    您会认为在UISegmentedControl 中合成的按钮会将其isHittable 属性设置为true,但是,这就是您思考后会得到的结果...爱你!

    【讨论】:

      猜你喜欢
      • 2017-04-10
      • 1970-01-01
      • 2020-01-03
      • 1970-01-01
      • 2018-08-29
      • 1970-01-01
      • 2016-12-15
      • 2015-08-03
      • 2021-12-31
      相关资源
      最近更新 更多