目前点击溢出菜单中某些设备上的菜单项我正在执行以下操作:
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())
}
}
Run Code Online (Sandbox Code Playgroud)
但我正在寻找一种更好的方法 - 理想情况下,我必须知道菜单ID.你如何在浓咖啡测试中做到这一点?