2017-08-22 71 views
0

我有一個問題,我使用表視圖的底部刷新,但只有第一次正常工作。刷新表格後,我的測試已經結束。有我的代碼:如何在UI測試中使用表格的視圖底部刷新兩次?

func test_lista(){ 

    //Entrar a la lista de ofertas 
    app.tables.element(boundBy: 0).cells.element(boundBy: 2).tap() 
    sleep(2) 

    //Arrastrar la ultima fila 
    app.swipeUp() 
    app.swipeUp() 
    let cell = app.tables.element(boundBy: 0).cells.element(boundBy: 2) 
    let start = cell.coordinate(withNormalizedOffset: CGVector(dx: 0,dy: 0)) 
    let finish = cell.coordinate(withNormalizedOffset: CGVector(dx: 0,dy: -30.0)) 
    start.press(forDuration: 0, thenDragTo: finish) 

    app.swipeUp() 
    app.swipeUp() 
    let cell2 = app.tables.element(boundBy: 0).cells.element(boundBy: 4) 
    let start2 = cell2.coordinate(withNormalizedOffset: CGVector(dx: 0,dy: 0)) 
    let finish2 = cell2.coordinate(withNormalizedOffset: CGVector(dx: 0,dy: -30.0)) 
    start2.press(forDuration: 0, thenDragTo: finish2) 

} 

我在做什麼錯?

回答

0

我找到了解決方案。我剛剛纔使這條線添加到我的表視圖的方法:

self.offerTableView.scrollToRow(at: IndexPath(row: lastIndex, section: 0), at: .bottom, animated: false) 

此功能由從我的表視圖的靜態位置時,我重裝數據。所以只是我把這個代碼和測試正常工作。

相關問題