通过 xpath 定位总是会定位到错误的元素,导致报错。
我要定位的是"报告异常" ,总是定位到 "个人"
如下是详细 appium 日志:
2016-02-19 16:31:17:552 - info: <-- POST /wd/hub/session/31041efc-ba77-4b5c-a689-2192c937088a/element/3/click 200 1356.006 ms - 74 {"status":0,"value":"","sessionId":"31041efc-ba77-4b5c-a689-2192c937088a"}
2016-02-19 16:31:17:557 - info: --> POST /wd/hub/session/31041efc-ba77-4b5c-a689-2192c937088a/element {"using":"xpath","value":"//UIAApplication[1]/UIAWindow[1]/UIAButton[3]"}
2016-02-19 16:31:17:557 - info: [debug] Waiting up to 0ms for condition
2016-02-19 16:31:17:557 - info: [debug] Pushing command to appium work queue: "au.mainApp().getTreeForXML()"
2016-02-19 16:31:17:558 - info: [debug] Sending command to instruments: au.mainApp().getTreeForXML()
2016-02-19 16:31:17:566 - info: [debug] [INST] 2016-02-19 08:31:17 +0000 Debug: evaluation finished
2016-02-19 16:31:17:568 - info: [debug] [INST] 2016-02-19 08:31:17 +0000 Debug: responding with:
2016-02-19 16:31:17:571 - info: [debug] [INST] 2016-02-19 08:31:17 +0000 Debug: Running system command #16: /Applications/Appium.app/Contents/Resources/node/bin/node /Applications/Appium.app/Contents/Resources/node_modules/appium/submodules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{"status":0,"value":""}...
2016-02-19 16:31:18:585 - info: [debug] [INST] 2016-02-19 08:31:18 +0000 Debug: Got new command 16 from instruments: au.mainApp().getTreeForXML()
2016-02-19 16:31:18:588 - info: [debug] [INST] 2016-02-19 08:31:18 +0000 Debug: evaluating au.mainApp().getTreeForXML()
2016-02-19 16:31:20:769 - info: [debug] [INST] 2016-02-19 08:31:20 +0000 Debug: evaluation finished
{"UIAButton":{"@":{"name":"报告异常","label":"报告异常","value":null,"dom":null,"enabled":true,"valid":true,"visible":true,"hint":null,"path":"/0/0/11","x":27,"y":518,"width":120,"height":39},">":[]}}
{"UIAElement":{"@":{"name":"个人","label":"个人","value":null,"dom":null,"enabled":true,"valid":true,"visible":false,"hint":null,"path":"/0/0/18","x":160,"y":568,"width":80,"height":49},">":[]}}
2016-02-19 16:31:20:780 - info: [debug] [INST] 2016-02-19 08:31:20 +0000 Debug: Running system command #17: /Applications/Appium.app/Contents/Resources/node/bin/node /Applications/Appium.app/Contents/Resources/node_modules/appium/submodules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{"status":0,"value":{"UIAApplication":{"@":{"name":"卡卡测试版","label":"卡卡测试版","value":null,"dom":null,"e...
2016-02-19 16:31:20:867 - info: [debug] Socket data received (7826 bytes)
2016-02-19 16:31:20:867 - info: [debug] Socket data received (7856 bytes)
2016-02-19 16:31:20:868 - info: [debug] Socket data received (5839 bytes)
2016-02-19 16:31:20:868 - info: [debug] Socket data being routed.
2016-02-19 16:31:20:868 - info: [debug] Got result from instruments: {"status":0,"value":{"UIAApplication":{"@":{"name":"卡卡测试版","label":"卡卡测试版","value":null,"dom":null,"enabled":true,"valid":true,"visible":true,"hint":null,"path":"/0","x":0,"y":0,"width":320,"height":568},">":[{"UIAWindow":{"@":{"name":null,"label":null,"value":null,"dom":null,"enabled":true,"valid":
2016-02-19 16:31:20:908 - info: [debug] Pushing command to appium work queue: "au.getElementByIndexPath('/0/0/11')"
2016-02-19 16:31:20:908 - info: [debug] Sending command to instruments: au.getElementByIndexPath('/0/0/11')
2016-02-19 16:31:21:871 - info: [debug] [INST] 2016-02-19 08:31:21 +0000 Debug: Got new command 17 from instruments: au.getElementByIndexPath('/0/0/11')
2016-02-19 16:31:21:874 - info: [debug] [INST] 2016-02-19 08:31:21 +0000 Debug: evaluating au.getElementByIndexPath('/0/0/11')
2016-02-19 16:31:21:879 - info: [debug] [INST] 2016-02-19 08:31:21 +0000 Debug: evaluation finished
2016-02-19 16:31:21:883 - info: [debug] [INST] 2016-02-19 08:31:21 +0000 Debug: Lookup returned [object UIAElement] with the name "个人" (id: 4).
2016-02-19 16:31:21:886 - info: [debug] [INST] 2016-02-19 08:31:21 +0000 Debug: responding with:
2016-02-19 16:31:21:891 - info: [debug] [INST] 2016-02-19 08:31:21 +0000 Debug: Running system command #18: /Applications/Appium.app/Contents/Resources/node/bin/node /Applications/Appium.app/Contents/Resources/node_modules/appium/submodules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{"status":0,"value":{"ELEMENT":"4"}}...
2016-02-19 16:31:21:967 - info: [debug] Socket data received (38 bytes)
2016-02-19 16:31:21:968 - info: [debug] Socket data being routed.
2016-02-19 16:31:21:968 - info: [debug] Got result from instruments: {"status":0,"value":{"ELEMENT":"4"}}
2016-02-19 16:31:21:968 - info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":"4"},"sessionId":"31041efc-ba77-4b5c-a689-2192c937088a"}
2016-02-19 16:31:21:970 - info: <-- POST /wd/hub/session/31041efc-ba77-4b5c-a689-2192c937088a/element 200 4412.745 ms - 87 {"status":0,"value":{"ELEMENT":"4"},"sessionId":"31041efc-ba77-4b5c-a689-2192c937088a"}
2016-02-19 16:31:21:973 - info: --> POST /wd/hub/session/31041efc-ba77-4b5c-a689-2192c937088a/element/4/click {"id":"4"}
2016-02-19 16:31:21:974 - info: [debug] Pushing command to appium work queue: "au.tapById('4')"
2016-02-19 16:31:21:974 - info: [debug] Sending command to instruments: au.tapById('4')
2016-02-19 16:31:22:810 - info: [IOS_SYSLOG_ROW ] Feb 19 16:31:22 PENGBillZhang MobileGestaltHelper[87] <Error>: libMobileGestalt MobileGestalt.c:276: server_access_check denied access to question UniqueDeviceID for pid 1452
2016-02-19 16:31:22:815 - info: [IOS_SYSLOG_ROW ] Feb 19 16:31:22 PENGBillZhang ScriptAgent[1452] <Error>: libMobileGestalt MobileGestaltSupport.m:151: pid 1452 (ScriptAgent) does not have sandbox access for re6Zb+zwFKJNlkQTUeT+/w and IS NOT appropriately entitled
2016-02-19 16:31:22:819 - info: [IOS_SYSLOG_ROW ] Feb 19 16:31:22 PENGBillZhang ScriptAgent[1452] <Error>: libMobileGestalt MobileGestalt.c:537: no access to UniqueDeviceID (see <rdar://problem/11744455>)
2016-02-19 16:31:22:834 - info: [debug] [INST] 2016-02-19 08:31:22 +0000 Debug: Got new command 18 from instruments: au.tapById('4')
2016-02-19 16:31:22:838 - info: [debug] [INST] 2016-02-19 08:31:22 +0000 Debug: evaluating au.tapById('4')
2016-02-19 16:31:22:841 - info: [debug] [INST] 2016-02-19 08:31:22 +0000 Debug: target.frontMostApp().elements()[0].elements()[11].tap()
2016-02-19 16:31:22:843 - info: [debug] [INST] 2016-02-19 08:31:22 +0000 Debug: target.frontMostApp().elements()[0].elements()[11].scrollToVisible()
2016-02-19 16:31:22:846 - info: [debug] [INST] 2016-02-19 08:31:22 +0000 Debug: target.frontMostApp().elements()[0].elements()[11] - scrollToVisible cannot be used because this element has no scrollable ancestor.
2016-02-19 16:31:22:848 - info: [IOS_SYSLOG_ROW ] Feb 19 16:31:22 PENGBillZhang MobileGestaltHelper[87] <Error>: libMobileGestalt MobileGestalt.c:276: server_access_check denied access to question UniqueDeviceID for pid 1452
2016-02-19 16:31:22:849 - info: [IOS_SYSLOG_ROW ] Feb 19 16:31:22 PENGBillZhang ScriptAgent[1452] <Error>: libMobileGestalt MobileGestaltSupport.m:151: pid 1452 (ScriptAgent) does not have sandbox access for re6Zb+zwFKJNlkQTUeT+/w and IS NOT appropriately entitled
2016-02-19 16:31:22:851 - info: [IOS_SYSLOG_ROW ] Feb 19 16:31:22 PENGBillZhang ScriptAgent[1452] <Error>: libMobileGestalt MobileGestalt.c:537: no access to UniqueDeviceID (see <rdar://problem/11744455>)
2016-02-19 16:31:22:853 - info: [debug] [INST] 2016-02-19 08:31:22 +0000 Debug: target.frontMostApp().elements()[0].elements()[11] - scrollToVisible cannot be used because this element has no scrollable ancestor.
2016-02-19 16:31:22:856 - info: [debug] [INST] 2016-02-19 08:31:22 +0000 Debug: target.frontMostApp().elements()[0].elements()[11] could not be tapped because the element is not visible
2016-02-19 16:31:23:132 - info: [debug] [INST] 2016-02-19 08:31:22 +0000 Error: VerboseError: elementId 4 could not be tapped
2016-02-19 16:31:23:156 - info: [debug] Socket data received (57 bytes)
2016-02-19 16:31:23:157 - info: [debug] Socket data being routed.
2016-02-19 16:31:23:158 - info: [debug] Got result from instruments: {"status":13,"value":"elementId 4 could not be tapped"}
2016-02-19 16:31:23:159 - info: [debug] Responding to client with error: {"status":13,"value":{"message":"An unknown server-side error occurred while processing the command.","origValue":"elementId 4 could not be tapped"},"sessionId":"31041efc-ba77-4b5c-a689-2192c937088a"}
2016-02-19 16:31:23:161 - info: <-- POST /wd/hub/session/31041efc-ba77-4b5c-a689-2192c937088a/element/4/click 500 1187.785 ms - 200
2016-02-19 16:31:23:273 - info: [debug] [INST] 2016-02-19 08:31:22 +0000 Error: Error during eval: [native code]
file:///Applications/Appium.app/Contents/Resources/node_modules/appium/6CAB92C8-C959-404B-8E66-9B853355EABE/bootstrap-5923cadea0343e3f.js:711:30
tapById@file:///Applications/Appium.app/Contents/Resources/node_modules/appium/6CAB92C8-C959-404B-8E66-9B853355EABE/bootstrap-5923cadea0343e3f.js:1100:42
eval code
eval@[native code]
startProcessing@file:///Applications/Appium.app/Contents/Resources/node_modules/appium/6CAB92C8-C959-404B-8E66-9B853355EABE/bootstrap-5923cadea0343e3f.js:2710:30
bootstrap@file:///Applications/Appium.app/Contents/Resources/node_modules/appium/6CAB92C8-C959-404B-8E66-9B853355EABE/bootstrap-5923cadea0343e3f.js:2778:31
global code@file:///Applications/Appium.app/Contents/Resources/node_modules/appium/6CAB92C8-C959-404B-8E66-9B853355EABE/bootstrap-5923cadea0343e3f.js:2787:10
2016-02-19 16:31:23:277 - info: [debug] [INST] 2016-02-19 08:31:22 +0000 Debug: responding with:
2016-02-19 16:31:23:281 - info: [debug] [INST] 2016-02-19 08:31:22 +0000 Debug: Running system command #19: /Applications/Appium.app/Contents/Resources/node/bin/node /Applications/Appium.app/Contents/Resources/node_modules/appium/submodules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{"status":13,"value":"elementId 4 could not be tapped"}...