fed*_*608 2 ui-testing ios swift xcode7 xcode-ui-testing
如何在我的一个集合视图中测试无限滚动?我尝试模拟滚动,就像在"拉动刷新"示例中解释的那样,但它没有奏效.
let app = XCUIApplication()
let start = app.coordinateWithNormalizedOffset(CGVectorMake(1, 6))
let finish = app.coordinateWithNormalizedOffset(CGVectorMake(1, 0))
var x = 0
while(x < 20){
x++
start.pressForDuration(0, thenDragToCoordinate: finish)
}
Run Code Online (Sandbox Code Playgroud)
(while条件仅用于测试,我将更改它以询问当滚动工作时是否存在特定元素)
如果您只测试无限滚动,则可能不需要下拉到坐标级API.相反,只需滑动集合视图,就像用户正在滚动一样.
let app = XCUIApplication()
let newCell = app.staticTexts["Page 2 Item"]
XCTAssertFalse(newCell.exists)
app.collectionView.element.swipeUp()
XCTAssert(newCell.exists)
Run Code Online (Sandbox Code Playgroud)