Unable to use xpath on Android (v1.4.8)

I’ve run into issues where I can’t find elements using xpath on specific screens of the app I’m testing.

When I try to find an element with a valid xpath, I get an error (see below), but if downgrade to v1.3.5 and the same xpath works fine.

I’ve also tried inspecting the app with the v1.4.8 of appium.app and the element tree doesn’t show up.

Has anyone else run into this issue?

info: --> POST /wd/hub/session/9c5718dd-7c82-466d-92b0-1c18a2c6871a/element {"using":"xpath","value":"//android.widget.ListView[1]/android.widget.LinearLayout","sessionId":"9c5718dd-7c82-466d-92b0-1c18a2c6871a"}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"xpath","selector":"//android.widget.ListView[1]/android.widget.LinearLayout","context":"","multiple":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.widget.ListView[1]/android.widget.LinearLayout","context":"","multiple":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding //android.widget.ListView[1]/android.widget.LinearLayout using XPATH with the contextId:  multiple: false
info: [debug] [BOOTSTRAP] [debug] Command returned error:java.lang.RuntimeException: Failed to Dump Window Hierarchy
info: [debug] Condition unmet after 69ms. Timing out.
info: [debug] Responding to client with error: {"status":13,"value":{"message":"An unknown server-side error occurred while processing the command.","origValue":"Failed to Dump Window Hierarchy"},"sessionId":"9c5718dd-7c82-466d-92b0-1c18a2c6871a"}
info: <-- POST /wd/hub/session/9c5718dd-7c82-466d-92b0-1c18a2c6871a/element 500 70.387 ms - 200
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"Failed to Dump Window Hierarchy","status":13}

The particular element you are trying to locate is might not be supported on the device, its purely upto the android sdk which supports what of element. good example is hint does not supported in some version of android.

LinearLayout layout is supported almost in all version, can you paste your code as well.

I’ve written my own little wrapper around Appium, but what it’s essentially doing (and I’ve tested this with just pure Appium commands) is:

driver.find_element_by_xpath('//android.widget.ListView[1]/android.widget.LinearLayout')

I’ve tried other valid locators and they don’t work.

Are you sure that lack of locator support could be the issue? I mentioned in my post that this is working in Appium v1.4.8.

I will try to locate an element with path today with 1.4.8 and get back to you…