I’d like to be able to select from the root node, but everything I try starting with /
doesn’t work.
This is an issue because, for Android, //foo[1]/bar
can happen in multiple places in the hierarchy - much more commonly than in iOS’s view hierarchy.
I want to, instead, do /foo[1]/bar/
so that I’m sure I’m looking at, relative to the top, foo[1]
's bar
children. (Ideas about how to solve this problem with UiSelector
are very welcome!)
Ex. view hierarchy and server logs:
android.view.View # there are many of these. I need to select a specific one.
* android.widget.FrameLayout
- android.view.View
* android.widget.FrameLayout
* android.widget.FrameLayout
...
Given the above hierarchy, I would expect this to work and give me 1 element:
/android.view.View[1]/android.widget.FrameLayout
Unfortunately, no elements can be found.
info: --> POST /wd/hub/session/e774c836-a34c-4f01-b8c9-5d8f7f7dc3ed/elements {"using":"xpath","value":"/android.view.View[1]/android.widget.FrameLayout"}
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"xpath","selector":"/android.view.View[1]/android.widget.FrameLayout","context":"","multiple":true}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"/android.view.View[1]/android.widget.FrameLayout","context":"","multiple":true}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding /android.view.View[1]/android.widget.FrameLayout using XPATH with the contextId: multiple: true
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":[],"status":0}
info: [debug] Responding to client with success: {"status":0,"value":[],"sessionId":"e774c836-a34c-4f01-b8c9-5d8f7f7dc3ed"}
info: <-- POST /wd/hub/session/e774c836-a34c-4f01-b8c9-5d8f7f7dc3ed/elements 200 76.238 ms - 74 {"status":0,"value":[],"sessionId":"e774c836-a34c-4f01-b8c9-5d8f7f7dc3ed"}