Espresso 2.0的viewpager列表视图的AmbiguousViewMatcherException



当我尝试在下面运行测试时,我得到了AmbiguousViewMatcherException,我如何才能从多个视图中获得预期的视图。

数据(hasToString (startsWith (ALS))) .inAdapterView(所有(withId (android.R.id.list))) .atPosition (0) .perform(点击());

android.support.test.espresso.AmbiguousViewMatcherException: '(with id: android:id/list)' matches multiple views in the hierarchy.
Problem views are marked with '****MATCHES****' below.
View Hierarchy:
+>DecorView{id=-1, visibility=VISIBLE, width=1440, height=2560, has-focus=false, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=3}
|
+->LinearLayout{id=-1, visibility=VISIBLE, width=1440, height=2392, has-focus=false, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=2}
|
+-->ViewStub{id=16909171, visibility=GONE, width=0, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=true, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0}
|
+-->FrameLayout{id=16908290, res-name=content, visibility=VISIBLE, width=1440, height=2304, has-focus=false, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=88.0, child-count=1}
|
+--->ViewPager{id=2131558505, res-name=pager, visibility=VISIBLE, width=1440, height=2304, has-focus=false, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=true, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=3}
|
+---->KayakPagerTabStrip{id=2131558506, res-name=tabstrip, visibility=VISIBLE, width=1440, height=112, has-focus=false, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=3}
|
+----->TextView{id=-1, visibility=VISIBLE, width=0, height=66, has-focus=false, has-focusable=true, has-window-focus=true, is-clickable=true, is-enabled=true, is-focused=false, is-focusable=true, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=25.0, text=, input-type=0, ime-target=false, has-links=false}
|
+----->TextView{id=-1, visibility=VISIBLE, width=56, height=66, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=692.0, y=25.0, text=All, input-type=0, ime-target=false, has-links=false}
|
+----->TextView{id=-1, visibility=VISIBLE, width=201, height=66, has-focus=false, has-focusable=true, has-window-focus=true, is-clickable=true, is-enabled=true, is-focused=false, is-focusable=true, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=1239.0, y=25.0, text=Favorites, input-type=0, ime-target=false, has-links=false}
|
+---->FrameLayout{id=-1, visibility=VISIBLE, width=1440, height=2192, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=112.0, child-count=2}
|
+----->LinearLayout{id=16711682, visibility=VISIBLE, width=1440, height=2192, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=1}
|
+------>ProgressBar{id=-1, visibility=VISIBLE, width=266, height=266, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=587.0, y=963.0}
|
+----->FrameLayout{id=16711683, visibility=GONE, width=0, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=true, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=2}
|
+------>TextView{id=16711681, visibility=GONE, width=0, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=true, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, text=, input-type=0, ime-target=false, has-links=false}
|

+------>ListView{id=16908298, res-name=list, visibility=VISIBLE,宽度=0,高度=0,has-focus=false, has-focusable=false,Has-window-focus =true, is-clickable=true, is-enabled=true,Is-focused =false, is-focusable=false, is-layout-requested=true,选择= false, root-is-layout-requested = false,Has-input-connection =false, x=0.0, y=0.0, child-count=0}* * * *与* * * *

|
+---->FrameLayout{id=-1, visibility=VISIBLE, width=1440, height=2192, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=1440.0, y=112.0, child-count=2}
|
+----->LinearLayout{id=16711682, visibility=VISIBLE, width=1440, height=2192, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=1}
|
+------>ProgressBar{id=-1, visibility=VISIBLE, width=266, height=266, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=587.0, y=963.0}
|
+----->FrameLayout{id=16711683, visibility=GONE, width=0, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=true, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=2}
|
+------>TextView{id=16711681, visibility=GONE, width=0, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=true, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, text=, input-type=0, ime-target=false, has-links=false}
|

+------>ListView{id=16908298, res-name=list, visibility=VISIBLE,宽度=0,高度=0,has-focus=false, has-focusable=false,Has-window-focus =true, is-clickable=true, is-enabled=true,Is-focused =false, is-focusable=false, is-layout-requested=true,选择= false, root-is-layout-requested = false,Has-input-connection =false, x=0.0, y=0.0, child-count=0}* * * *与* * * *

|
+->View{id=16908335, res-name=statusBarBackground, visibility=VISIBLE, width=1440, height=88, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0}
|
+->View{id=16908336, res-name=navigationBarBackground, visibility=VISIBLE, width=1440, height=168, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=2392.0}
|

您可以将isDisplayed()添加到adapterview匹配器中,以与当前可见的listview交互。

inAdapterView(allOf(withId(android.R.id.list), isDisplayed()))

最新更新