Android 安卓API 28模拟器上的浓缩咖啡测试点击问题

Android 安卓API 28模拟器上的浓缩咖啡测试点击问题,android,testing,android-espresso,Android,Testing,Android Espresso,这仅适用于api级别为28的Android设备。 单击微调器后尝试匹配文本失败 两种方法,一种是查找非活动的窗口,另一种是查找弹出菜单: ... // Look for text "Green" in the menu onView(withId(getFieldId(COLOR_ID))).perform(click()); onView(withText("Green")) .inRoot(withDecorView(not(is(rule.g

这仅适用于api级别为28的Android设备。 单击微调器后尝试匹配文本失败

两种方法,一种是查找非活动的窗口,另一种是查找弹出菜单:

...
    // Look for text "Green" in the menu
    onView(withId(getFieldId(COLOR_ID))).perform(click());
    onView(withText("Green"))
            .inRoot(withDecorView(not(is(rule.getActivity().getWindow().getDecorView())))) // Look for popup menu
            .perform(click());

    // Second spinner, Look for the text "Medium"
    onView(withId(getFieldId(SIZE_ID))).perform(click());
    onView(withText("Medium")).inRoot(RootMatchers.isPlatformPopup()).perform(click());
...

通过将构建工具版本更新到28.0.2(WAS28.0.1)并替换所有要使用的android支持库,这两个版本都可以很好地处理设备API问题