I am making a test using Espresso, first I open the action bar:
openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext());
Everything ok up to here, but then I want to click on an option menu:
onView(withId(R.id.action_menu)).perform(click());
The menu layout xml has an option with id: "action_menu".
I get an error:
android.support.test.espresso.NoMatchingViewException: No views in hierarchy found matching: with id: ***.********.******.android.debug:id/action_menu
If the target view is not part of the view hierarchy, you may need to use Espresso.onData to load it from one of the following AdapterViews:android.support.v7.widget.ListPopupWindow$DropDownListView{43fd3f58 VFED.VC. .F...... 24,24-612,168}
I got this step to work by using:
onView(withText(R.string.action_report)).perform(click());
I would like to know what is going wrong with the id though.
Any ideas?
android:id="@+id/action_menu"
but espresso is only finding by text. Still don't know why... – Losel