UIAutomator2: exact_text is not found - strategies for debugging?

I’m looking for help on strategies for debugging the following issue, assuming it’s not simply a failure in the UIAutomator2 server on the phone (in which case, we’ll defer migrating for now).

I’m moving our Ruby/Appium UIAutomator tests to UIAutomator2, but while they work for finding elements by ID and scrolling the screen, they fail when I try to use text_exact(‘Hide all’).click:

"An element could not be located on the page using the given search parameters.

This despite ‘Hide all’ being clearly displayed on the screen and available from $driver.get_source:

<android.widget.TextView index=\"1\" text=\"Hide all\" class=\"android.widget.TextView\" package=\"com.bumble.app\" content-desc=\"\" checkable=\"false\" checked=\"false\" clickable=\"true\" enabled=\"true\" focusable=\"false\" focused=\"false\" scrollable=\"false\" long-clickable=\"false\" password=\"false\" selected=\"false\" bounds=\"[48,421][1032,565]\" resource-id=\"android:id/text1\" instance=\"2\"/>

Our package.json requests “appium”: “1.6.3” and I found it necessary to post-install [email protected] into node_modules/appium or it would complain about not being able to find appium-uiautomator2-server-v0.0.8.apk. I also updated to npm install [email protected] in appium’s node_modules and [email protected]. With these and various combinations between those and the originals, I still get this:

Appium’s log shows the mysterious translation from ‘using/value’ to ‘strategy/selector’:

2017-03-17 14:52:50:584 - info: [HTTP] --> POST /wd/hub/session/9457a631-d110-4e13-bc94-e22da1354394/element {"using":"-android uiautomator","value":"new UiSelector().className(\"android.widget.TextView\").description(\"Hide all\");new UiSelector().className(\"android.widget.TextView\").text(\"Hide all\");"}
2017-03-17 14:52:50:585 - debug: [MJSONWP] Calling AppiumDriver.findElement() with args: ["-android uiautomator","new UiSelector().className(\"android.widget.TextView\").description(\"Hide all\");new UiSelector().className(\"android.widget.TextView\").text(\"Hide all\");","9457a631-d110-4e13-bc94-e22da1354394"]
2017-03-17 14:52:50:587 - debug: [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
2017-03-17 14:52:50:588 - debug: [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
2017-03-17 14:52:50:588 - debug: [BaseDriver] Waiting up to 0 ms for condition
2017-03-17 14:52:50:588 - debug: [JSONWP Proxy] Proxying [POST /element] to [POST http://localhost:8200/wd/hub/session/ec82fb86-4011-4f83-a32a-bd42c33ddcf7/element] with body: {"strategy":"-android uiautomator","selector":"new UiSelector().className(\"android.widget.TextView\").description(\"Hide all\");new UiSelector().className(\"android.widget.TextView\").text(\"Hide all\");","context":"","multiple":false}
2017-03-17 14:52:50:640 - info: [HTTP] <-- POST /wd/hub/session/9457a631-d110-4e13-bc94-e22da1354394/element 500 56 ms - 164

And here’s the logcat:

I/appium  ( 9858): channel read: POST /wd/hub/session/ec82fb86-4011-4f83-a32a-bd42c33ddcf7/element
I/appium  ( 9858): Find element command
D/appium  ( 9858): payload: {"strategy":"-android uiautomator","selector":"new UiSelector().className(\"android.widget.TextView\").description(\"Hide all\");new UiSelector().className(\"android.widget.TextView\").text(\"Hide all\");","context":"","multiple":false}
I/appium  ( 9858): find element command using '-android uiautomator' with selector 'new UiSelector().className("android.widget.TextView").description("Hide all");new UiSelector().className("android.widget.TextView").text("Hide all");'.
D/appium  ( 9858): Parsing selector: new UiSelector().className("android.widget.TextView").description("Hide all")
D/appium  ( 9858): UiSelector coerce type: java.lang.Class<T> arg: "android.widget.TextView"
D/appium  ( 9858): UiSelector coerce type: class java.lang.String arg: "android.widget.TextView"
D/appium  ( 9858): UiSelector coerce type: class java.lang.String arg: "Hide all"
D/appium  ( 9858): Parsing selector: new UiSelector().className("android.widget.TextView").text("Hide all")
D/appium  ( 9858): UiSelector coerce type: java.lang.Class<T> arg: "android.widget.TextView"
D/appium  ( 9858): UiSelector coerce type: class java.lang.String arg: "android.widget.TextView"
D/appium  ( 9858): UiSelector coerce type: class java.lang.String arg: "Hide all"
E/EGL_emulation(  737): tid 737: eglCreateSyncKHR(1181): error 0x3004 (EGL_BAD_ATTRIBUTE)
I/appium  ( 9858): AppiumResponse: {"sessionId":"ec82fb86-4011-4f83-a32a-bd42c33ddcf7","status":7,"value":"An element could not be located on the page using the given search parameters."}

Any ideas? Should I report this as a bug?

3 Likes

I have the same setup. Seems to be a bug…? Link if you do enter one.

In the interim I’ll be using:

find_element(uiautomator: ‘text(“Text to be found.”)’)