我们使用此代码来模拟一个UICollectionView
对Xcode的UI测试第一小区自来水:Xcode的UI测试集合视图细胞变得不hittable iOS上11
XCUIElementQuery *query = [application descendantsMatchingType:XCUIElementTypeAny];
XCUIElement *collectionView = [query objectForKeyedSubscript:collectionViewAccessibilityIdentifier];
XCUIElement *targetCell = [lensesCollectionView.cells elementBoundByIndex:cellIndex];
if (targetCell.hittable) {
[targetCell tap];
}
这工作得很好iOS上10 ,但停止在iOS 11上工作。无论如何,targetCell
从不是hittable
。在XCUIElement *targetCell = [lensesCollectionView.cells elementBoundByIndex:lensIndex]
之前添加sleep(10)
没有帮助。
我见过哈克解决方案
func forceTapElement() {
if self.isHittable {
self.tap()
} else {
var coordinate: XCUICoordinate = self.coordinateWithNormalizedOffset(CGVectorMake(0.0, 0.0))
coordinate.tap()
}
}
别的地方,例如提及,但看起来不很干净。什么是最简单的方法来实现这一点?
更新:如果我试图挖掘它不检查hittable
我得到这个错误:
error: Error -25204 performing AXAction 2003 on element pid: 43616, elementOrHash.elementID: 4882574576.240
我遇到了这个问题,它不是在屏幕上的单元格 - 它们以前是在iOS 10上运行时自动滚屏到屏幕上的。当您尝试点击它时,您的单元格是否在屏幕上? – Oletha
这绝对是在屏幕上。我可以在手机上看到它,并且'targetCell.frame'在屏幕内。然而,它仍然是不可接受的。 –