iOS 中的 UITesting:tap() 方法无法正常工作

UITesting in iOS: tap() method doesn't work properly

我在 Swift 下的 iOS 10.3.2 和 Xcode 8.3.3 中遇到了一个奇怪的 UITesting 问题。

我正在 运行 我的应用程序中进行一个简单的测试,它应该点击并验证 TableView 中的每一行(是我的应用程序的设置视图,因此每一行都是从磁盘加载的,没有任何内容在此步骤从网上下载),但由于一个奇怪的原因,当我点击以前不可见的行时,.tap() 方法不起作用。

示例代码:

let app = XCUIApplication()  

let myTableView = app.tables.element(matching: .table, identifier:    "tableView01")  
myTableView.swipeUp(). //I swipe so that the cell becomes visible...  

let myCell = myTableView.cells.element(matching: .cell, identifier: "tappableCell")  

myCell.tap()  

奇怪的是 我在 Xcode 中从控制台得到了正确的输出。

 t =   328.24s     Tap "tappableCell" Cell
    t =   328.24s         Wait for app to idle
    t =   328.80s         Find the "tappableCell" Cell
    t =   328.80s             Snapshot accessibility hierarchy for com.thefloow.enterprise.ownbrand
    t =   328.92s             Find: Descendants matching type Table
    t =   328.92s             Find: Element at index 0
    t =   328.92s             Find: Descendants matching type Cell
    t =   328.92s             Find: Elements matching predicate '"tappableCell" IN identifiers'
    t =   329.04s             Wait for app to idle
    t =   329.22s         Synthesize event
    t =   329.37s         Wait for app to idle

另一个奇怪的事情是,如果 我在 tap 方法之前放置了一个断点,然后我从命令行 运行 它完美地工作,从控制台给我相同的输出。

这种奇怪行为的原因可能是什么?


感谢您的帮助! 安德里亚

我发现是框架的问题。滚动后 UI 没有正确响应,所以我不得不双击单元格以退出 UIResponder 然后测试正常工作。我还向  报告了这个问题,以了解它是否属于正常行为。

不过谢谢大家!编码愉快!