0
Android Espressoテスト開発を習得しようとしています。Android Espresso - 同じ項目を含む単一のリスト(AmbiguousViewMatcherException)
私は2つの同じ項目(同じリソースID、同じテキスト、1つのリストのみ)を持つリストを持っています。
現在、私は(おそらく非常に間違った)、これをやっている:
DataInteraction dataInteraction = onData(anything()).inAdapterView(withText("Test1"));
dataInteraction.atPosition(0).perform((click()));
これは、結果は例外です:
...
+--------->LinearLayout{id=-1, visibility=VISIBLE, width=720, height=128, 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=65.0, child-count=2}
|
+---------->AppCompatImageView{id=xxxxxxxxx, res-name=image, visibility=VISIBLE, width=80, height=61, 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=33.0}
|
+---------->AppCompatTextView{id=xxxxxxx01, res-name=title, visibility=VISIBLE, width=162, height=46, 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=80.0, y=41.0, text=Test1, input-type=0, ime-target=false, has-links=false} ****MATCHES****
|
+--------->LinearLayout{id=-1, visibility=VISIBLE, width=720, height=65, 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=193.0, child-count=2}
|
+---------->AppCompatTextView{id=xxxxxxxxx, res-name=text, visibility=VISIBLE, width=720, height=63, 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, text=All Tests, input-type=0, ime-target=false, has-links=false}
|
+---------->View{id=-1, visibility=VISIBLE, width=720, height=2, 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=63.0}
|
+--------->LinearLayout{id=-1, visibility=VISIBLE, width=720, height=128, 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=258.0, child-count=2}
|
+---------->AppCompatImageView{id=xxxxxxxxx, res-name=image, visibility=VISIBLE, width=80, height=61, 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=33.0}
|
+---------->AppCompatTextView{id=xxxxxxx01, res-name=title, visibility=VISIBLE, width=162, height=46, 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=80.0, y=40.0, text=Test1, input-type=0, ime-target=false, has-links=false} ****MATCHES****
...
リストです:
I/TestRunner: ----- begin exception -----
I/TestRunner: android.support.test.espresso.AmbiguousViewMatcherException: 'with text: is "Test1"' matches multiple views in the hierarchy.
Problem views are marked with '****MATCHES****' below.
レイアウトは、このようなものですタイプ:
ExpandableListView
それは種類のクラスが含まれています:
class TestType implements Serializable, Searchable
私は同じ情報を複数のインスタンスがある場合、テキストまたはリソースIDによってリストの項目を、私をクリックしてはどうすればよいですか?しかし、より良い方法はをTestTypeに含まれるテキストまたはリソースIDの一致を含めることであろう
onData(allOf(is(instanceOf(TestType.class)))).atPosition(0).perform(click());
: