【发布时间】:2016-09-21 22:43:43
【问题描述】:
我有以下浓缩咖啡测试:
openActionBarOverflowOrOptionsMenu(InstrumentationRegistry.getTargetContext());
// if I Thread.sleep() here, I can see that the MenuItem has been clicked already
onView(withText("Sign in")) //<= click on the MenuItem
.perform(click());
onView(withId(R.id.signupButton)) //<= click the signup button in my UI
.perform(click());
那里的第一行打开溢出菜单并同时单击第一项(恰好是登录项)。所以测试失败,因为它找不到 MenuItem 视图。有什么我做错了吗?我正在使用模拟器 API 22,再次编译 targetSdk 24 并使用 espresso 2.2.1。
【问题讨论】:
-
我想您在测试类中使用了 ActivityTest Rule。请尝试使用
openActionBarOverflowOrOptionsMenu(mActivityRule.getActivity());
标签: android functional-testing android-espresso