如何使用Espresso点击Android Gallery

前端之家收集整理的这篇文章主要介绍了如何使用Espresso点击Android Gallery前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_502_0@
我们目前有一个 Android应用程序,我们正在使用Espresso进行测试.我们要测试的功能之一是从本地图库中选择图片/图片.我们可以一直调出图库视图,但无法在结果窗口中选择最近,下载,图库.下面列出了我们如何得到的摘要.
public void testShouldBeAbleToSelectPhotoFromGallery() {

    getActivity();

    // given
    onView(withId(launch_gallery_button)).perform(click());
    onView(withText("Gallery")).perform(click());  // this is a button in our app
    // then we get stuck :(
}

谢谢!

解决方法

使用Robotium或Espresso无法实现这一点,因为它们仅适用于被测应用程序的活动.

要编写适用于不同应用和Android内置应用的集成测试,您可以使用Google提供的UiAutomator framework.

基本上,您将分析uiautomatorview中的gallery应用程序,以了解如何选择测试用例所需的ui元素,然后对其进行操作,与Espresso不同.

原文链接:https://www.f2er.com/android/309689.html

猜你在找的Android相关文章