2

I'm doing instrumentation test using espresso, problem is it can't find the ids of the CoordinatorLayout/ViewPager/AppBarLayout/TabLayout, this is a new screen/activity, shown after I successfully performed click on a button from my main screen.

onView(withId(R.id.main_content)).check(matches(isCompletelyDisplayed())); //tried all the IDs

This always results to NoMatchingViewException

I've tried to explicitly use the string values of my tabItems but still results to same error

I've read here Testing multiple activities with espresso, there shouldn't be any problem even if this not the main activity specified in my ActivityTestRule

My xml file:

<androidx.coordinatorlayout.widget.CoordinatorLayout android:id="@+id/main_content">

<com.google.android.material.appbar.AppBarLayout
    android:id="@+id/appbar">

    <com.google.android.material.tabs.TabLayout
        android:id="@+id/tabs">

        <com.google.android.material.tabs.TabItem
            android:id="@+id/tab1"/>

        <com.google.android.material.tabs.TabItem
            android:id="@+id/tab2"/>

    </com.google.android.material.tabs.TabLayout>

</com.google.android.material.appbar.AppBarLayout>

<androidx.viewpager.widget.ViewPager android:id="@+id/container"/>

This is my first time using espresso. Am I missing something?

Zerosero
  • 323
  • 3
  • 15

0 Answers0