dimanche 29 septembre 2019

I am using espresso to test android application. I am trying to find a way how to manage matching radiobutton id and textview id for click option

<TextView
                android:id="@+id/manifestName"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="0dp"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="0dp"
                android:text="Balmoral"
                android:textColor="@color/colorPrimary"
                android:textSize="16sp"
                android:visibility="visible" />
<RadioButton
                android:id="@+id/radioButton"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textSize="18sp" />

How to mange textview id and radio button id match with each other for selection of radiobutton in Espresso UI automation.

ViewInteraction appCompatRadioButton = onView(
            allOf(withId(R.id.radioButton),
                    childAtPosition(
                            childAtPosition(
                                    withId(R.id.homeBottomLayout),
                                    2),
                            0),
                    isDisplayed()));
    appCompatRadioButton.perform(click());

I'm tried with above Espresso code but for that i got error:

android.support.test.espresso.AmbiguousViewMatcherException:
Problem views are marked with '****MATCHES****' below.

Aucun commentaire:

Enregistrer un commentaire