是否可以单击ViewPager中ListView的第一项?Espresso:单击ViewPager中ListView中的第一项
我已经尝试过得到它的工作是这样的:
onData(anything()).inAdapterView(withId(R.id.myListView)).atPosition(0).perform(click());
。
但据我所知:Testing ViewPager with Espresso. How perfom action to a button of an Item?你不能使用onData作为ViewPager。 另外,如果我运行测试,我得到一个AmbiguousViewMatcherException多个匹配。
android.support.test.espresso.AmbiguousViewMatcherException: 'with id: my.awesome.app:id/myListView' matches multiple views in the hierarchy. Problem views are marked with '****MATCHES****' below.
如果我像这样运行onView(allOf(withId(R.id.myListView),isDisplayed())).perform(click());
测试的第一个项目是从来没有点击。
是否有另一种方法来点击列表中的第一项?
你只是想要选择第一个项目? – cunniemm
那么,我想点击它 – elpatricko
哦,我看到哈哈。 @PatrickSturm – cunniemm