vendredi 31 juillet 2015

Espresso get dynamically created child in layout

Button.java

public class Button extends FrameLayout {
    public Button(Context context, AttributeSet attrs) {
        super(context, attrs);
        TextView textView = new TextView(context);
        textView.setText("Test");
    }
}

layout.xml

<LinearLayout>
    <com.Button id="button_1" />
    <com.Button id="button_2" />
</LinearLayout>

Using Espresso, how to access the TextView created in Button, and verify its text?

onView(withId(R.id.button_1)<get_child>).check(matches(withText("Test")));

Aucun commentaire:

Enregistrer un commentaire