Android API 28模拟器上的Espresso测试点击问题

问题描述 投票:2回答:1

这仅适用于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());
...

两者都可以正常使用设备API <= 27

知道为什么这不能在28上工作吗?谢谢。

android testing android-espresso
1个回答
1
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.