2016-11-24 4 views
1

エスプレッソライブラリにはfirstMatch()というメソッドがありますか?今、私はこの例外Android Espresso最初の試合をクリックしてください

android.support.test.espresso.AmbiguousViewMatcherException matches multiple views in the hierarchy. 

を取得しています私はRecyclerViewと項目のいくつかはR.id.textRowBottomを表示しているではなく、それがすべて揃っています。私は最初の試合をしてそれをクリックしたい。

それはあなたがこれを使用することができRecylerView内の項目をテストしたい場合は、この

onView(allOf(withId(R.id.textRowBottom), isDisplayed())).perform(click()); 
+0

あなたはこれをお探しですか? http://stackoverflow.com/a/36866682/1219012 –

答えて

0

次のようになります、

android.support.test.espresso.contrib.RecyclerViewActions 

をですから、その位置によって、リスト内の特定の項目を選択することができます次のようなもの:

onView(withId(recyclerViewId)).perform(
        RecyclerViewActions.actionOnItemAtPosition(0, 
          click(R.id.textRowBottom)); 
+0

これは私が探しているものではありません。アイテムの位置は固定されていません。 –

関連する問題