如何在 UI 测试中使用 table 的视图底部刷新两次?

How can I use table's view bottom refresh twice on UI Testing?

我在 table 视图中使用底部刷新时遇到问题,但只有第一次工作正常。刷新 table 后,我的测试冻结了。这是我的代码:

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)

}

我做错了什么?

我找到了解决方案。我只是想将这一行添加到我的 table 视图的方法中:

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

当我重新加载数据时,此函数在我的 table 视图中创建了一个静态位置。所以只要我输入这段代码,测试就可以正常工作。