No matchers inside InteractionBuilder. How to specify Kakao view UI-element using its classes?


I use Espresso framework for my UI-tests and now i want to use Kakao. I have a MainPage with some view and that view can be found in next way:

class MainPage() {
    val screenTitle 
            withText("Main page"),

In Espresso test case these lines work without problems

val mainPage  MainPage()

Then I tried to rewrite this MainPage with its view in Kakao style:

class MainScreen : Screen<MainScreen>() {
    // here i faced a problem
    val screenTitle  KBaseView<Matcher<View>>{    // this 2-nd line* is refferenced by error 
            ViewMatchers.withText("Main page"),

And if try to write test case in Kakao style

val mainScreen  MainScreen()
mainScreen {
    screenTitle {

Then i get next error:

E/TestRunner: failed: should_check_main_page(
    ----- begin exception -----
    java.lang.IllegalStateException: No matchers inside InteractionBuilder
        at com.agoda.kakao.common.views.KBaseView.<init>(KBaseView.kt:42)
        at<init>(MainScreen.kt:2)* - 2-nd line

I understand that i specify screenTitle in MainScreen by wrong way, but how is correct? Thank you!


I was also facing similar issue while trying to use kaspresso (a wrapper built on top of Kakao) The idea is more or less same that’s used in previous answer, but you have to add withMatcher() function before using any custom matcher. So in your case, it will become something like

val screenTitle  KTextView {
  withText("Main page")
  withMatcher { //your custom matcher }

Answered By – vjrock

Leave a Comment