When i run my test case,I got follow exception .
android.support.test.espresso.NoMatchingViewException: No views in hierarchy found matching: with id: android:id/home
This is my TestCase code.
public void nav_to_alarm_test(){
onView(withId(R.id.navigation_notifications)).perform(click());
onView(withId(R.id.rl_reminder)).perform(click());
onView(withId(R.id.item_test)).perform(click());
onView(withId(android.R.id.home)).perform(click());//throw exception here
onView(withId(android.R.id.home)).perform(click());
}
This is android.R.id.home,belongs to button provided by ActionBar
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
case R.id.item_test:
startActivityForResult(CreateOrUpdateReminderActivity.class,CMD_ADD_REMINDER);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
why can't find views in hierarchy for resource id android.R.id.home?
I have Google my problem, but answers isn't what i want.
Thanks for any help.
Same question like here(click home icon with espresso)
what solve my question is this line
Espresso.pressBack();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With