Skip to content

Instantly share code, notes, and snippets.

@xanderblinov
Created May 8, 2019 13:25
Show Gist options
  • Save xanderblinov/3fc21a9b8be8dc73d981b65f4cb6e339 to your computer and use it in GitHub Desktop.
Save xanderblinov/3fc21a9b8be8dc73d981b65f4cb6e339 to your computer and use it in GitHub Desktop.
Pagination extantion for Kakao test
fun RecyclerActions.scrollToEndWithPagination() {
scrollToEnd()
view.perform(ViewActions.swipeUp())
}
fun <T : KRecyclerItem<T>> KRecyclerView.paginateUntilChildMatching(
childMatcher: ViewBuilder.() -> Unit,
timeoutS: Long = WAITER_TIMEOUT_S) {
while (true) {
val count = getSize()
try {
val child = childWith<KRecyclerItem<T>>(childMatcher)
child.isVisible()
break
} catch (e: NoMatchingViewException) {
scrollToEndWithPagination()
waitSeconds(timeoutS)
if (count == getSize()) {
throw e
}
}
}
}
fun waitSeconds(timeoutS: Long = WAITER_TIMEOUT_S) {
Thread.sleep(TimeUnit.SECONDS.toMillis(timeoutS))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment