得知 xpath 的 index 是从 1 开始,但目前写的有问题,前来请教:
我想使用 xpath 的方式去获取框住地方的值,目前 xpath 是这样写的:String xpath = "//ListView[1]/LinearLayout[1]/LinearLayout[1]/LinearLayout[0]/TextView[1]"
这样直接抛异常。日志如下:

info: [debug] Pushing command to appium work queue: ["find",{"strategy":"xpath","selector":"//ListView[2]/LinearLayout[1]/LinearLayout[2]/LinearLayout[1]/TextView[2]","context":"","multiple":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//ListView[2]/LinearLayout[1]/LinearLayout[2]/LinearLayout[1]/TextView[2]","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 //ListView[2]/LinearLayout[1]/LinearLayout[2]/LinearLayout[1]/TextView[2] using XPATH with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":13}
info: [debug] Responding to client with error: {"status":13,"value":{"message":"An unknown server-side error occurred while processing the command."},"sessionId":"7b958536-b344-4a6f-b4b4-195d2824cc86"}
请问这 xpath 必须写出其绝对路径才能正常使用么?
还望各位不吝赐教!


↙↙↙阅读原文可查看相关链接,并与作者交流