Xcode UITest试图读取UITableviewcell Right Detail值

时间:2016-07-28 01:37:28

标签: swift xcode uitableview xcode-ui-testing uitest

我正在尝试将UITest添加到我的应用程序中,计算结果显示在表视图中(样式:右侧详细信息)。我已经能够阅读'静态文本'它显示在单元格的左侧(下面的第一行),但我无法确定如何阅读'右侧细节&#39 ;;第二行显示我想测试右侧细节值的位置(本例中为2点)。

XCTAssert(app.tables.cells.staticTexts["Best of Breed"].exists)
//2 Points

任何帮助都将不胜感激。

----- 2016年7月28日更新-----

我找到了一种方法来指定文本应该在哪个表格的单元格中,并且我已经验证了' 2点'确实存在于单元格中

更具体的XCTAssert

XCTAssert(app.tables.element.cells.element(boundBy: 0).staticTexts["Best of Breed Best of Winners Winners Dog"].exists)
XCTAssert(app.tables.element.cells.element(boundBy: 0).staticTexts["2 Points"].exists)

print app.tables.element.cells.element(boundBy:0).debugDescription

(String) $R2 = "Attributes: Cell 0x600000364bc0: traits: 8589934593, {{16.0, 95.0}, {343.0, 78.0}}
Element subtree:
 →Cell 0x600000364bc0: traits: 8589934593, {{16.0, 95.0}, {343.0, 78.0}}
    StaticText 0x6000003651c0: traits: 8589934656, {{31.0, 105.0}, {115.0, 57.5}},
        label: \'Best of Breed Best of Winners Winners Bitch\'
    StaticText 0x600000365100: traits: 8589934656, {{265.5, 105.0}, {58.5, 19.5}},
        label: \'2 Points\'
    Path to element:
    →Application 0x6000003642c0: {{0.0, 0.0}, {375.0, 667.0}}, label: \'Best of Breed\'
    ↳Window 0x600000364500: Main Window, {{0.0, 0.0}, {375.0, 667.0}}
    ↳Other 0x6000003645c0: traits: 8589934592, {{0.0, 0.0}, {375.0, 667.0}}
    ↳Other 0x600000364380: traits: 8589934592, {{0.0, 0.0"...

1 个答案:

答案 0 :(得分:0)

这些工作

XCTAssert(app.tables.cells.element(boundBy: 0).staticTexts["Best of Breed"].exists)
XCTAssert(app.tables.cells.element(boundBy: 0).staticTexts["2 Points"].exists)