2017-08-10 8 views
1

私はIdlingResourceを使用してエスプレッソテストを作成して、ビデオの再生を確認しようとしています。AmbiguousViewMatcherException Espresso

私のプロジェクトはhere

をホストされている。これはテストです:

@RunWith(AndroidJUnit4.class) 
public class RecipeFetchTest { 

@Rule 
public ActivityTestRule<RecipeActivity> mActivityTestRule = new ActivityTestRule<>(RecipeActivity.class); 

private IdlingResource mIdlingResource; 

@Before 
public void registerIdlingResource() { 
    mIdlingResource = mActivityTestRule.getActivity().getIdlingResource(); 
    Espresso.registerIdlingResources(mIdlingResource); 
} 


@Test 
public void checkRecipeNameRecipeActivity() { 
    onView(ViewMatchers.withId(R.id.rv_recipes)).perform(RecyclerViewActions.scrollToPosition(1)); 
    onView(withText("Brownies")).check(matches(isDisplayed())); 
} 

@Test 
public void checkPlayerViewIsVisibleRecipeDetailActivity1() { 
    onView(ViewMatchers.withId(R.id.rv_recipes)).perform(RecyclerViewActions.actionOnItemAtPosition(0,click())); 
    onView(ViewMatchers.withId(R.id.rv_steps)).perform(RecyclerViewActions.actionOnItemAtPosition(0,click())); 
withContentDescription("playerVideo"))).check(matches(isDisplayed())); 
    onView(withId(R.id.playerView)).check(matches(isDisplayed())); 
} 


@After 
public void unregisterIdlingResource() { 
    if (mIdlingResource != null) { 
     Espresso.unregisterIdlingResources(mIdlingResource); 
    } 
} 

} 

と私は、このエラーで失敗し、テストを得る:

android.support.test.espresso.AmbiguousViewMatcherException: '(with id: 
gautamhans.xyz.bakeaid:id/playerView and is displayed on the screen to the 
user)' matches multiple views in the hierarchy. 
Problem views are marked with '****MATCHES****' below. 

+--------->SimpleExoPlayerView{id=2131558584, res-name=playerView, 
visibility=VISIBLE, width=871, height=399, 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} ****MATCHES**** 

+---------->PlaybackControlView{id=2131558584, res-name=playerView, 
visibility=VISIBLE, width=871, height=399, 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=1} ****MATCHES**** 

テストによると、私は2つのビューを持っています同じres-id、すなわち "playerView"である。

一つはSimpleExoPlayerView あり、他方はPlaybackControlView

私はSimpleExoPlayerViewを定義覚えていなくPlaybackControlViewです。

だから、助けていただければ幸いです。

答えて

0

私は同じ問題があります。

私はSimpleExoPlayerが自動的にPlaybackControlViewを生成すると思います。 この世代を回避できるかどうかはわかりませんでしたが、回避策があります。

は、この行を探します。

onView(allOf(instanceOf(SimpleExoPlayerView.class), withId(R.id.playerView))).check(matches(isDisplayed())); 

を私はちょうどSimpleExoPlayerオブジェクトをチェックし、それが正しく表示されますならば、私は必ず確認してくださいするのMatcherを追加します。

関連する問題