Skip to content

Instantly share code, notes, and snippets.

@ngallazzi
Last active January 4, 2024 08:56
Show Gist options
  • Save ngallazzi/876cd27fb190db3ea39461ad34068ac7 to your computer and use it in GitHub Desktop.
Save ngallazzi/876cd27fb190db3ea39461ad34068ac7 to your computer and use it in GitHub Desktop.
Espresso view matching
<EditText android:id="@+id/name_field"
android:layout_width="wrap_content"
android:hint="Please enter your name" android:layout_height="wrap_content" />
<Button android:id="@+id/greet_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Click me to greet!" />
<Text android:id="@+id/greet_field" android:layout_width="wrap_content"
android:visibility="gone"
android:layout_height="wrap_content" />
@Test
fun greeterSaysHello() {
onView(withId(R.id.name_field)).perform(typeText("Steve"))
onView(withId(R.id.greet_button)).perform(click())
onView(withText("Hello, I am a Steve")).check(matches(isDisplayed()))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment