Click on menu-item that is sometimes in the overflow-menu
问题 currently to click on menu-item that is sometimes on some devices in the overflow-menu I am doing the following: fun invokeMenu(@IdRes menuId: Int, @StringRes menuStringRes: Int) { try { onView(withId(menuId)).perform(click()) } catch (nmv: NoMatchingViewException) { openActionBarOverflowOrOptionsMenu(InstrumentationRegistry.getInstrumentation().targetContext) onView(withText(menuStringRes)).perform(click()) } } But I am searching for a better approach - ideally something where I just have to