Home > Net >  Difference between specifying a view as isRoot() & withId
Difference between specifying a view as isRoot() & withId

Time:08-24

I want to know the difference in specifying a view in different ways

onView(withId(R.id.btnAuthLogin)).perform(click());

onView(isRoot()).perform(waitId(R.id.btnAuthLogin, 1000));

It's not the delay thing that i want to know

What happens when we specify isRoot() rather than specifying withID.

Hope there is no confusion.

CodePudding user response:

isRoot() returns the root view of your layout, such as the constraint or relative layout hosting your views.

withId() return the view with a matching ID from the layout, or throws an error showing the structure of your view hierarchy

You set a views Id in XML using android:id="@ id/your_id_here"

  • Related