How to write Espresso view/data matchers in Appium Java Client?

Viewed 139

I am using Appium to test Android application and today I was instructed to switch from UIAutomator2 to Espresso automator. I realized that it will not be so simple as just changing automator name.

As far as my searching go, Appium with Espresso automator have very little (almost none) documentation for writing selectors (view/data matchers) in Java/Kotlin.

I am trying to find out how to for example rewrite my current method for search by text. It looks like this:

(driver as AndroidDriver<*>).findElementByAndroidUIAutomator("new UiSelector().textContains(\"$text\")")
// Written for UIAutomator2

I tried:

(driver as AndroidDriver<*>).findElement(MobileBy.androidViewMatcher(Json().toJson(
    ImmutableMap.of(
        "name", "withText",
        "args", ImmutableList.of("<text>"),
    )
)))

But does not seems to work...

I see in appium-espresso-driver readme that I can search by text and by much more, but I cannot simply find a documentation how to send those commands to Appium Server trough Appium java client.

Any recommendations for docs, or help how to do it? Thanks

0 Answers
Related