【问题标题】:XCTest UI testing UIElements sizeXCTest UI 测试 UIElements 大小
【发布时间】:2015-12-10 14:31:38
【问题描述】:

我正在 XCode 中使用 XCTest 测试我的应用程序。

有人有示例如何测试 UIElement 大小吗? tableView 中单元格的高度,或 tableView 单元格中标签的高度。任何示例将不胜感激。

【问题讨论】:

    标签: ios swift xctest ui-testing xcode-ui-testing


    【解决方案1】:

    使用XCUIElement 上的XCUIElementAttributes 协议访问帧。这会返回一个标准的CGRect,您可以查询它的大小和来源。

    let height = app.buttons.element.frame.size.height
    let width = app.buttons.element.frame.size.width
    let x = app.buttons.element.frame.origin.x
    let y = app.buttons.element.frame.origin.y
    

    【讨论】:

    • @DejanZuza 不客气!如果这充分回答了您的问题,请单击左侧的灰色复选标记接受它。谢谢!
    • 嗨@Joe,我能请你看看我的这个问题吗?谢谢stackoverflow.com/questions/33872364/…
    • @JoeMasilotti 在 2017 年仍然有帮助!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-04-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多