我們使用此代碼來模擬一個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'在屏幕內。然而,它仍然是不可接受的。 –