我有一個活動2列表視圖,我想查找第一個ListView的孩子,但我找到第一個ListView的孩子和第二個ListView,爲什麼?請幫幫我。espresso onData匹配層次結構中的多個視圖
代碼:
DataInteraction dataInteraction =
onData(allOf(
withClassName(endsWith("LinearLayout")),
hasSibling(withText("9.0")),
hasSibling(withText("襯衫"))
));
dataInteraction.onChildView(withId(R.id.order_untake_jijia_listview_jia))
.atPosition(0);
dataInteraction.perform(ViewActions.click());
它發現:
ListView{id=2131493579, res-name=order_jijia_listview, visibility=VISIBLE, width=768,
height=659, 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=345.0, child-count=7} ****MATCHES****
ListView{id=2131493586, res-name=order_jijia_pop_listview, visibility=VISIBLE,
width=0, height=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, is-selected=false,
root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0,
child-count=0} ****MATCHES****