Compruebe la visibilidad del fragmento después de hacer clic en la pestaña de TabLayout que solo contiene un icono con Android Espres

Estoy tratando de verificar si mi fragmento es visible después de hacer clic en mi pestaña desde mi pestaña Diseño que se ha configurado con el buscapersonas.

Este es mi código de actividad real, dentro de mi actividad en Crear método:

mViewPager = findViewById(R.id.contentFrameLayout);
mViewPager.setAdapter(mSectionPageAdapter);
mViewPager.setPagingEnabled(false);

//Set up the tab layout to display tabs
tabLayout = findViewById(R.id.homeTabs);
tabLayout.setupWithViewPager(mViewPager);

for (int i = 0; i< tabLayout.getTabCount(); i++) {
        TabLayout.Tab mTab = tabLayout.getTabAt(i);
        if (mTab != null) {
            switch (i){
                case 0:
                    mTab.setTag(WFragment.class.toString());
                    mTab.setIcon(R.drawable.home_icon_svg);
                    break;
                case 1:
                    mTab.setTag(MFragment.class.toString());
                    mTab.setIcon(R.drawable.l_svg);
                    break;
                case 2:
                    //etc..
            }
        }
    }

Aquí está mi prueba de instrumentación:

@Test
public void checkIfMFragmentIsVisible() {
    Matcher<View> matcher = allOf(withTagValue(is((Object) MFragment.class.toString())),
            isDescendantOfA(withId(R.id.homeTabs)));
    onView(matcher).perform(click());
    onView(withId(R.id.mFragmentLayout)).check(matches(isCompletelyDisplayed()));
}

Utilicé información deest link que me ayudó a comenzar a crear un emparejador y realizar un clic. Sin embargo, mi prueba falla con el siguiente error:

android.support.test.espresso.NoMatchingViewException: No views in hierarchy found matching: (with tag value: is "class com.test.solution.fragments.MFragment" and is descendant of a: with id: 2131296345)
If the target view is not part of the view hierarchy, you may need to use Espresso.onData to load it from one of the following AdapterViews:com.google.maps.api.android.lib6.impl.ce{d55b63a G.ED..C.. ......I. 0,0-0,0}

PRUEBA DE INSTRUMENTACIÓN EXITOSA:

Intenté una prueba ficticia agregando lo siguiente en mis pestañas en mi actividad:

TabLayout.Tab mTab = tabLayout.getTabAt(i);
            if (mTab != null) {
                switch (i){
                    case 0:
                        mTab.setText("case 0");
                        //etc..
                    case 1:
                        mTab.setText("case 1");
                        //etc..
                    case 2:
                        //etc..

Y en mi prueba de instrumentación:

@Test
public void checkIfMFragmentIsVisible() {
    Matcher<View> matcher = allOf(withText("case 1"),
                isDescendantOfA(withId(R.id.homeTabs)));
        onView(matcher).perform(click());
        onView(withId(R.id.mFragmentLayout)).check(matches(isCompletelyDisplayed()));
}

Esta prueba fue exitosa, sin embargo, no quiero usar un texto en mi actividad, pero quiero usar una etiqueta u otra cosa.

Respuestas a la pregunta(1)

Su respuesta a la pregunta