Recently, I switched from UIAutoimator2 to Espresso and I am trying to rewrite some non-standard selectors.
For example I was using selector to search by text:
(driver as AndroidDriver<*>).findElementByAndroidUIAutomator("new UiSelector().textContains(\"$text\")") as MobileElement
but this does not seems to work when I use Espresso (
InvalidSelectorException: Locator strategy cannot be empty)
Then I tried to use Espresso
viewMatcher strategy and
withText method like so:
(driver as AndroidDriver<*>).findElementByAndroidViewMatcher(Json().toJson( ImmutableMap.of( "name", "withText", "args", text ), ) )) as MobileElement
but I am getting error
No such method: withText() on class: org.hamcrest.Matchers' even that I am following Espresso documentation
I have two questions:
- Am I still able to use UIAutomator2 selectors without using
- How to use viewMatcher correctly?
- How to use dataMatcher correctly?
Appium’s documentation for view/data matchers in Espresso are almost nonexistant. And If there is some documentation, it is not for java-client