F
F
foonfyrick2020-09-09 09:42:37
Android
foonfyrick, 2020-09-09 09:42:37

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

1 answer(s)
F
foonfyrick, 2021-01-04
@foonfyrick

wrong sequence of writing code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question