Created
May 8, 2019 13:25
-
-
Save xanderblinov/3fc21a9b8be8dc73d981b65f4cb6e339 to your computer and use it in GitHub Desktop.
Pagination extantion for Kakao test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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