ios - 用户界面测试: Slider fails to adjust when nested in Table View Cell

标签 ios swift tableview uislider xcode-ui-testing

在 Xcode 9.0 (9A235) 上的 UI 测试中,当 UISlider 时,使用 adjust(toNormalizedSliderPosition:)UISlider 交互根本不起作用嵌套在 UITableViewCell 中。

我在许多不同的场景中进行了测试: - 未嵌入 UITableView 的普通 UISlider 可以与 adjust 方法配合使用。 - 与 UITableView 共存但不在 TableView 单元格内的 UISlider 继续与 adjust 一起使用 - UITableView 中的 UISlider 可以被唯一标识。 - UITableView 中标识的 UISlider 可以响应简单事件,例如 tap() - UITableView 中标识的 UISlider 根本无法与 adjust 方法一起使用,即使我将行数修改为 1 也是如此。错误消息是:

Failure fetching attributes for element pid: 24415, elementOrHash.elementID: 106102876671744.43: Error Domain=XCTDaemonErrorDomain Code=13 "Fetching value for attribute 5011 returned AX error -25205." UserInfo={NSLocalizedDescription=Fetching value for attribute 5011 returned AX error -25205.}

网上找到的相关讨论: https://forums.developer.apple.com/thread/77445

我已上传my code online如果有人有兴趣的话也可以看看。

我已经提交了bug report向苹果公司询问此事。我要问的是,有谁知道当 slider 嵌套在 UITableViewCell 中时可以用来调整 UISlider 值的可能解决方法?谢谢!

最佳答案

您可以使用此作为解决方法:

func testSliderAdjustsInTableView() {
    let app = XCUIApplication()

    app.staticTexts["Slider in Table View UI Test"].tap()

    let cell = app.tables.element.cells["cell 0"]
    let button = cell.buttons["Test Button"]
    button.tap()

    let slider = cell.sliders["value slider"]
    XCTAssert(slider.exists)

    let fiftyPercent = slider.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.5))
    let ninetyPercent = slider.coordinate(withNormalizedOffset: CGVector(dx: 0.9, dy: 0.5))

    fiftyPercent.press(forDuration: 0.1, thenDragTo: ninetyPercent)

    XCTAssertEqual(slider.value as! String, "90 %")
}

关于ios - 用户界面测试: Slider fails to adjust when nested in Table View Cell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46785790/

相关文章:

ios - 在 rails 中显示 base64 编码的图像

ios - 如何设置 Collection View 的搜索栏

ios - 将 indexpath 标记传递给 tableview 中原型(prototype)单元格内的按钮

ios - 获取 JSON 数据并在 Xcode 的 tableview 中显示

ios - 按距离(纬度和经度)排序表

swift - NStableView 不显示我的数据

ios - 更改 NSMutableAttributedString 时 TextView 中的 subview 按钮消失,直到滚动到顶部

ios - 核心绘图栏 - 仅几个栏的图例

iOS 从文件中读取

ios - tableView.reloadData() 不调用 cellForRowAtindexPath()