repeatWhileCanSelect, doUntilTrue

in Japanese(日本語)

Repeats a block while a selector resolves, or until an arbitrary condition becomes true.

Functions

function description
repeatWhileCanSelect(sel, maxLoopCount: 10, waitSeconds: 0, title:) { } Repeats the block while the selector keeps resolving. For an unknown number of matching items (e.g. dismissing a variable number of cards). Reaching maxLoopCount is not a failure, but it is recorded.
doUntilTrue("description", waitSeconds: 10, intervalSeconds: 0.5, maxLoopCount: 100) { condition } Repeats the block until it returns true. You can call commands such as scrollDown() and select(...) inside the block. A thrown error fails immediately without retrying.

Example

repeatWhileCanSelect("#dismiss_card", maxLoopCount: 10) {
    tap("#dismiss_card")
}

doUntilTrue("background job finished", waitSeconds: 10, intervalSeconds: 0.5) {
    select("#job_status").text == "done"
}

doUntilTrue("scroll down until Settings shows") {
    scrollDown()
    return select("Settings").isNotEmpty
}
tap("Settings")

Notes