Skip to content

Instantly share code, notes, and snippets.

@DaChelimo
Created March 22, 2021 09:13
Show Gist options
  • Save DaChelimo/9a6af1481d52bc46658e752c7533b86d to your computer and use it in GitHub Desktop.
Save DaChelimo/9a6af1481d52bc46658e752c7533b86d to your computer and use it in GitHub Desktop.
Extensions for Espresso Testing Library
fun setTextInTextView(value: String?): ViewAction {
return object : ViewAction {
override fun getConstraints(): Matcher<View> {
return allOf(isDisplayed(), isAssignableFrom(TextView::class.java))
}
override fun perform(uiController: UiController?, view: View) {
(view as TextView).text = value
}
override fun getDescription(): String {
return "replace text"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment