Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/108.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Xcode UI测试-UITableView部分_Ios_Xcode_Uitableview_Xcode7_Xcode Ui Testing - Fatal编程技术网

Ios Xcode UI测试-UITableView部分

Ios Xcode UI测试-UITableView部分,ios,xcode,uitableview,xcode7,xcode-ui-testing,Ios,Xcode,Uitableview,Xcode7,Xcode Ui Testing,我想使用Xcode的UI测试来计算tableview中的节数和每个节中的单元格数。我该怎么做呢?乔·马西洛蒂(Joe Masilotti)完全正确,因为应用程序代码不能直接从UI测试中访问,尽管如果您想过时,可以使用反向通道。假设你没有 Xcode的UI测试框架可以访问所有Swift语言以及应用程序的UI层次结构,但不能访问数据层;因此,您可以执行以下操作: 提供包含索引组件(例如photos.headers\u 0等)的tableview节可访问标识的页眉或页脚 完成后,使用条件确定节数 类

我想使用Xcode的UI测试来计算tableview中的节数和每个节中的单元格数。我该怎么做呢?

乔·马西洛蒂(Joe Masilotti)完全正确,因为应用程序代码不能直接从UI测试中访问,尽管如果您想过时,可以使用反向通道。假设你没有

Xcode的UI测试框架可以访问所有Swift语言以及应用程序的UI层次结构,但不能访问数据层;因此,您可以执行以下操作:

  • 提供包含索引组件(例如photos.headers\u 0等)的tableview节可访问标识的页眉或页脚
  • 完成后,使用条件确定节数
  • 类似地,photos.section_0.cell_0可以在数据源中分配,迭代器+条件可以存储section 0或任何其他节中的单元格数

从Xcode 7开始,表视图标题显示为
其他
元素

以下是我在应用程序中为(分组)表视图所做的操作:

extension TableLayoutTests {

    func testHasMessagesGroup() {
        XCTAssert(app.tables.otherElements["MESSAGES"].exists)
    }

    func testHasMessageCell() {
        let header = app.tables.otherElements["MESSAGES"]
        let cell = app.tables.cells.elementBoundByIndex(1)
        XCTAssertGreaterThanOrEqual(cell.accessibilityFrame.minY, header.accessibilityFrame.maxY)
    }

    func testHasOtherMessageCell() {
        let header = app.tables.otherElements["MESSAGES"]
        let cell = app.tables.cells.elementBoundByIndex(2)
        XCTAssertGreaterThanOrEqual(cell.accessibilityFrame.minY, header.accessibilityFrame.maxY)
    }

}

为什么不使用您的数据源呢。如何从UI测试中访问代码?2.我想确保从数据源正确解析了这些节,只需从UI测试类调用tableview的numberOfSection和numberOfRows?(不确定是否正确回答了您的问题)我无法从UI测试类访问tableview无法直接从UI测试目标访问应用程序代码。更多细节请参见。非常有创意,我喜欢