Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Espresso Scroll表示不使用ScrollView托管LinearLayout,后者托管以编程方式生成的LinearLayout_Android_Android Espresso - Fatal编程技术网

Android Espresso Scroll表示不使用ScrollView托管LinearLayout,后者托管以编程方式生成的LinearLayout

Android Espresso Scroll表示不使用ScrollView托管LinearLayout,后者托管以编程方式生成的LinearLayout,android,android-espresso,Android,Android Espresso,我有一个ScrollView,它在运行时托管一个LinearLayout,然后托管一组LinearLayout(在前一个LinearLayout中) 我想运行一个浓缩咖啡测试,它会滚动到屏幕外的一个视图(滚动视图的下一步),单击该视图可以将我带到下一个活动。运行espresso测试时,我尝试使用ViewActions.scrollTo来访问它,但它只给了我一个resource not found异常 但是,如果我在测试的单击部分之前放置一个断点,手动滚动视图使其可见,然后运行测试的“单击”部分,

我有一个ScrollView,它在运行时托管一个LinearLayout,然后托管一组LinearLayout(在前一个LinearLayout中)

我想运行一个浓缩咖啡测试,它会滚动到屏幕外的一个视图(滚动视图的下一步),单击该视图可以将我带到下一个活动。运行espresso测试时,我尝试使用ViewActions.scrollTo来访问它,但它只给了我一个resource not found异常

但是,如果我在测试的单击部分之前放置一个断点,手动滚动视图使其可见,然后运行测试的“单击”部分,那么测试运行完全正常

有人知道为什么滚动到不起作用吗

我将LinearLayouts id设置为其中一个数据字段,以便知道id

测试代码:

@Test
public void ensureScoreCorrect() {
    int manUtdView = Math.abs("Man Utd".hashCode());
    String score = getScore();
    Log.d("Hashcode:", " " + Math.abs("Man Utd".hashCode()));

    onView(withId(manUtdView)).perform(ViewActions.scrollTo());
    onView(withId(manUtdView)).perform(click());

    onView(withId(R.id.details_score))
            .check(matches(withText(score)));
}
视图:



谢谢

我也面临同样的问题。你对此有什么补救办法吗?
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/all_matches_fragment"
    android:orientation="vertical"
    android:gravity="center"
    android:paddingBottom="90dp">

</LinearLayout>