是否可以單擊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