Issue
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 =
CoreMatchers.allOf(
withText("Main page"),
withParent(withId(R.id.mediaViewToolbar))
)
}
In Espresso test case these lines work without problems
val mainPage = MainPage()
onView(mainPage.screenTitle).check(matches(isDisplayed()))
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
CoreMatchers.allOf(
ViewMatchers.withText("Main page"),
ViewMatchers.withParent(ViewMatchers.withId(R.id.mediaViewToolbar))
)
}
}
And if try to write test case in Kakao style
val mainScreen = MainScreen()
mainScreen {
screenTitle {
isDisplayed()
}
}
Then i get next error:
E/TestRunner: failed: should_check_main_page(com.project.online.MainScreenKaspressoTest)
----- begin exception -----
java.lang.IllegalStateException: No matchers inside InteractionBuilder
at com.agoda.kakao.common.builders.ViewBuilder.getViewInteractionDelegate(ViewBuilder.kt:395)
at com.agoda.kakao.common.views.KBaseView.<init>(KBaseView.kt:42)
at com.project.online.MainScreen.<init>(MainScreen.kt:2)* - 2-nd line
I understand that i specify screenTitle
in MainScreen by wrong way, but how is correct?
Thank you!
Solution
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
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.