lundi 26 février 2018

Android espresso detect subview is gone

I want to check if a subView "B" is gone or visible in the view "A".

To check if the subView is visible in A, I'm doing this and it works well :

mainView.check(matches(allOf(isDisplayed(), hasDescendant(withId(R.id.subViewB)))));

But to check if "subViewB" is gone, I have crash for every things I tested. I can't used "not(isDisplayed())" because with "GONE" the subView B can't be found and so it crash. I see I can use "doesNotExist", but I have no idea how to do that for a subView. I can't do onView(mySubview).doesNotExist because I want to check if the specific subView of my view A does not exist and no the others.

Aucun commentaire:

Enregistrer un commentaire