2

ヘルプ!!!

EspressoでAndroid UIをテストしたいのですが、毎回画像が変わります。

listview
 ---FrameLayout
     ---imageview
     ---imageview
 ---FrameLayout
     ---imageview
     ---imageview

この方法を試してみましたが、まだクリックできません:

onData(is(instanceOf(ImageView.class)))
                .inAdapterView(withId(R.id.listview))
                .atPosition(3)
                .perform(ViewActions.click());

エラーログ:

com.google.android.apps.common.testing.ui.espresso.PerformException: Error performing 'load adapter data' on view 'with id: is <2131296725>'.
    at com.google.android.apps.common.testing.ui.espresso.PerformException$Builder.build(PerformException.java:67)
:DoubanMovie:connectedAndroidTest FAILED
4

2 に答える 2

3

私は遅れていることを知っていますが、それは他の人に役立ちます。

 onData(anything())
                .inAdapterView(withId(listviewID))
                .atPosition(0)
                .onChildView(withId(childViewID))
                .perform(click());

これは、customlayout を使用してリストビュー内の特定のビューをクリックするのに役立ちます

于 2016-09-12T09:11:33.487 に答える