在Android API 28模拟器点击问题上进行Espresso测试 [英] Espresso testing on Android API 28 emulator click issue

查看:92
本文介绍了在Android API 28模拟器点击问题上进行Espresso测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

仅在api级为28的Android设备上. 单击微调框后尝试匹配文本失败.

This is only on Android devices with api level 28. trying to match a text after clicking the spinner fails.

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

Two approaches, one looking for a window that is not the activity, the second is looking for popup menu:

...
    // 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

Both are working fine with devices API <=27

有人知道为什么它不能在28号上运行吗?谢谢.

Any idea why this is not working on 28? Thank you.

推荐答案

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

Problem solved by updating build tools version to 28.0.2 (was 28.0.1) and replaced all android support libraries to use androidx

这篇关于在Android API 28模拟器点击问题上进行Espresso测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆