Answer the question
In order to leave comments, you need to log in
Espresso No views in hierarchy found matching: with id is id/btn
I have only one button on the screen with id btn, in the test I press it, and as I read, check(matches(isDisplayed()) means check the display of the screen, when the test starts, the button is pressed, the transition to another activity is performed (as and it should be), but in the test it writes an error Espresso No views in hierarchy found matching: with id is id/btn
I don’t understand what is the reason, because I have this button and it is pressed in the test
.
class MainActivityTest{
@Rule
fun activityTestRule():ActivityScenarioRule<MainActivity> = ActivityScenarioRule(MainActivity::class.java)
@Test
fun clickBTN(){
onView(withId(R.id.btn)).perform(click()).check(matches(isDisplayed()))
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question