我正在尝试为刷新控件添加uitest,但由于无法使用辅助功能标识符(refreshControl.accessibilityIdentifier = "refreshControlList")访问刷新控件,因此无法完成此操作

launchAppWithArgs(json: OrdersResultJSON.ok, xcuiApp: app)

        let table = app.tables["agendaTable"]

        DispatchQueue.main.async {
            table.otherElements["sectionHeader0"].press(forDuration: 2, thenDragTo: table.otherElements["sectionHeader2"])
        }

        if !table.otherElements[""].waitForExistence(timeout: 6) {
            print("XXX")
        }

有什么测试的建议吗?

最佳答案

要执行“拉”刷新,只需获取第一个单元格并将其向下拖动即可:

let firstCell = app.tables["agendaTable"].cells.firstMatch
let start = firstCell.coordinate(withNormalizedOffset: CGVector(dx: 0, dy: 0))
let finish = firstCell.coordinate(withNormalizedOffset: CGVector(dx: 0, dy: 10))
start.press(forDuration: 0, thenDragTo: finish)

希望这有帮助!

关于swift - 最快捷的刷新控制,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51262158/

10-14 10:10
查看更多