我正在考虑从XCUIApplication
CollectionViews
这将返回collectionView
let count = XCUIApplication().collectionViews.cells.count
答案 0 :(得分:0)
我解决了一个问题,只是做了XCUIApplciation
extension
来计算可见细胞:
Swift 3.x
extension XCUIApplication {
func getVisibleCellsCount()-> Int {
var visibleCount = 0
var isInitialCellVisible = true
for i in 0...cells.count {
let cell = cells.element(boundBy: UInt(i))
if cell.exists, !cell.isHittable {
if i == 0 || !isInitialCellVisible {
isInitialCellVisible = false
} else {
return visibleCount
}
} else {
isInitialCellVisible = true
visibleCount += 1
}
}
return visibleCount
}
}