I’m seeing the same thing in 1.3+ for any xpath searches that don’t have a unique identifier. I see this when running my test case:
14:19:06,211 INFO xpath searching for ‘//android.widget.CheckBox[1]’
14:19:06,550 INFO Clicking element ‘//android.widget.CheckBox[1]’
14:19:06,892 INFO xpath searching for ‘//android.widget.CheckBox[3]’
ERROR
And the appium server log displays this during the same case:
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: [“find”,{“strategy”:“xpath”,“selector”:"//android.widget.CheckBox[1]",“context”:"",“multiple”:false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“xpath”,“selector”:"//android.widget.CheckBox[1]",“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.CheckBox[1] using XPATH with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.CheckBox, INSTANCE=0]
info: [debug] [BOOTSTRAP] [debug] Returning result: {“value”:{“ELEMENT”:“20”},“status”:0}
info: [debug] Responding to client with success: {“status”:0,“value”:{“ELEMENT”:“20”},“sessionId”:“e6b8a168-6806-42ca-bed3-2fe8f8db7502”}
info: <-- POST /wd/hub/session/e6b8a168-6806-42ca-bed3-2fe8f8db7502/element 200 317.873 ms - 88 {“status”:0,“value”:{“ELEMENT”:“20”},“sessionId”:“e6b8a168-6806-42ca-bed3-2fe8f8db7502”}
info: --> POST /wd/hub/session/e6b8a168-6806-42ca-bed3-2fe8f8db7502/element/20/click {“sessionId”:“e6b8a168-6806-42ca-bed3-2fe8f8db7502”,“id”:“20”}
info: [debug] Pushing command to appium work queue: [“element:click”,{“elementId”:“20”}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“element:click”,“params”:{“elementId”:“20”}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: click
info: [debug] [BOOTSTRAP] [debug] Returning result: {“value”:true,“status”:0}
info: [debug] Responding to client with success: {“status”:0,“value”:true,“sessionId”:“e6b8a168-6806-42ca-bed3-2fe8f8db7502”}
info: <-- POST /wd/hub/session/e6b8a168-6806-42ca-bed3-2fe8f8db7502/element/20/click 200 290.196 ms - 76 {“status”:0,“value”:true,“sessionId”:“e6b8a168-6806-42ca-bed3-2fe8f8db7502”}
info: --> POST /wd/hub/session/e6b8a168-6806-42ca-bed3-2fe8f8db7502/element {“using”:“xpath”,“sessionId”:“e6b8a168-6806-42ca-bed3-2fe8f8db7502”,“value”:"//android.widget.CheckBox[3]"}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: [“find”,{“strategy”:“xpath”,“selector”:"//android.widget.CheckBox[3]",“context”:"",“multiple”:false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“xpath”,“selector”:"//android.widget.CheckBox[3]",“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.CheckBox[3] using XPATH with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:13}
info: [debug] Condition unmet after 309ms. Timing out.
info: [debug] Responding to client with error: {“status”:13,“value”:{“message”:“An unknown server-side error occurred while processing the command.”},“sessionId”:“e6b8a168-6806-42ca-bed3-2fe8f8db7502”}
info: <-- POST /wd/hub/session/e6b8a168-6806-42ca-bed3-2fe8f8db7502/element 500 310.397 ms - 154
info: --> DELETE /wd/hub/session/e6b8a168-6806-42ca-bed3-2fe8f8db7502 {}
I noticed that anytime I attempted an xpath search with the index of an element rather than a unique identifier like text, anything but the first element in the hierarchy would fail. For example, searching for //android.widget.CheckBox[1] works as expected but any searches for //android.widget.CheckBox[2] or //android.widget.CheckBox[3] will fail. The full path doesn’t work either.