【问题标题】:Espresso testing on Android API 28 emulator click issueAndroid API 28 模拟器点击问题上的 Espresso 测试
【发布时间】:2018-09-05 08:09:35
【问题描述】:

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

两种方法,一种寻找不是activity的窗口,第二种寻找弹出菜单:

...
    // 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());
...

两者都可以使用设备 API

知道为什么这不适用于 28 吗?谢谢。

【问题讨论】:

    标签: android testing android-espresso


    【解决方案1】:

    通过将构建工具版本更新为 28.0.2(原为 28.0.1)并替换所有 android 支持库以使用 androidx 解决了问题

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-23
      • 2015-11-06
      • 1970-01-01
      • 1970-01-01
      • 2011-06-27
      相关资源
      最近更新 更多