(已解决)
在做 appium IOS 定位的时候遇到问题,是注册的时候一行输入用户名一行输入电话号码,由于没有 id 和 name,靠 xpath,而且 xpath 是基本一致的,但是输入姓名可以正常,输入手机号码就会报错。如图所示。
请贴上 appium server 的 log,光客户端的看不出啥东西
另外,随便猜猜是不是 send_keys 不好使。。。
#1 楼 @eurekasaber 大神 是这样的 你看我上一行也是用 send_keys 的 log 如下所示
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":20,"width":320,"height":548},">":[{"UIAWindow":{"@":{"name":null,"label":null,"value":null,"dom":null,"enabled":true,"valid":t
info: [debug] Pushing command to appium work queue: "au.getElementByIndexPath('/0/0/10')"
info: [debug] Sending command to instruments: au.getElementByIndexPath('/0/0/10')
info: [debug] [INST] 2015-07-10 05:06:45 +0000 Debug: Got new command 9 from instruments: au.getElementByIndexPath('/0/0/10')
info: [debug] [INST] 2015-07-10 05:06:45 +0000 Debug: evaluating au.getElementByIndexPath('/0/0/10')
info: [debug] [INST] 2015-07-10 05:06:45 +0000 Debug: evaluation finished
info: [debug] [INST] 2015-07-10 05:06:45 +0000 Debug: responding with:
info: [debug] [INST] 2015-07-10 05:06:45 +0000 Debug: Running system command #10: /Users/diaojunxian/Desktop/Appium.app/Contents/Resources/node/bin/node /Users/diaojunxian/Desktop/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{"status":0,"value":{"ELEMENT":"2"}}...
info: [debug] Socket data received (38 bytes)
info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {"status":0,"value":{"ELEMENT":"2"}}
info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":"2"},"sessionId":"f98383a2-e5e1-4c6d-b490-f680530f7b9e"}
info: <-- POST /wd/hub/session/f98383a2-e5e1-4c6d-b490-f680530f7b9e/element 200 3262.723 ms - 87 {"status":0,"value":{"ELEMENT":"2"},"sessionId":"f98383a2-e5e1-4c6d-b490-f680530f7b9e"}
info: --> POST /wd/hub/session/f98383a2-e5e1-4c6d-b490-f680530f7b9e/element/2/value {"sessionId":"f98383a2-e5e1-4c6d-b490-f680530f7b9e","id":"2","value":["1","8","1","0","0","0","0","2","2","2","2"]}
info: [debug] Pushing command to appium work queue: "au.getElement('2').setValueByType('18100002222')"
info: [debug] Sending command to instruments: au.getElement('2').setValueByType('18100002222')
info: [debug] [INST] 2015-07-10 05:06:47 +0000 Debug: Got new command 10 from instruments: au.getElement('2').setValueByType('18100002222')
info: [debug] [INST] 2015-07-10 05:06:47 +0000 Debug: evaluating au.getElement('2').setValueByType('18100002222')
info: [debug] [INST] 2015-07-10 05:06:47 +0000 Debug: No keyboard found. Tapping to make visible.
info: [debug] [INST] 2015-07-10 05:06:47 +0000 Debug: target.frontMostApp().elements()[0].elements()[10].tap()
info: [debug] [INST] 2015-07-10 05:06:47 +0000 Debug: Still no keyboard found. Tapping again to make visible.
info: [debug] [INST] 2015-07-10 05:06:47 +0000 Debug: target.frontMostApp().elements()[0].elements()[10].tap()
info: [debug] [INST] 2015-07-10 05:06:47 +0000 Debug: target.frontMostApp().keyboard().typeString("1")
info: [debug] [INST] 2015-07-10 05:06:47 +0000 Debug: target.frontMostApp().keyboard() failed to tap '1'
info: [debug] [INST] 2015-07-10 05:06:47 +0000 Debug: No keyboard found. Tapping to make visible.
info: [debug] [INST] 2015-07-10 05:06:47 +0000 Debug: target.frontMostApp().elements()[0].elements()[10].tap()
info: [debug] [INST] 2015-07-10 05:06:48 +0000 Debug: Still no keyboard found. Tapping again to make visible.
info: [debug] [INST] 2015-07-10 05:06:48 +0000 Debug: target.frontMostApp().elements()[0].elements()[10].tap()
info: [debug] [INST] 2015-07-10 05:06:48 +0000 Debug: Error typing '1': VerboseError: target.frontMostApp().keyboard() failed to tap '1'
info: [debug] [INST] 2015-07-10 05:06:48 +0000 Debug: Retrying...
info: [debug] [INST] 2015-07-10 05:06:48 +0000 Debug: target.frontMostApp().keyboard().typeString("1")
info: [debug] [INST] 2015-07-10 05:06:48 +0000 Debug: target.frontMostApp().keyboard() failed to tap '1'
info: [debug] [INST] 2015-07-10 05:06:48 +0000 Error: VerboseError: target.frontMostApp().keyboard() failed to tap '1'
info: [debug] [INST] 2015-07-10 05:06:48 +0000 Error: Error during eval: typeString@[native code]
sendKeysToActiveElement@file:///Users/diaojunxian/Desktop/Appium.app/Contents/Resources/node_modules/appium/9DEB6A49-B012-4E5A-9476-8CC4EDBFE866/bootstrap-a860e8c2e3014ca8.js:1281:32
setValueByType@file:///Users/diaojunxian/Desktop/Appium.app/Contents/Resources/node_modules/appium/9DEB6A49-B012-4E5A-9476-8CC4EDBFE866/bootstrap-a860e8c2e3014ca8.js:1986:38
eval code
eval@[native code]
startProcessing@file:///Users/diaojunxian/Desktop/Appium.app/Contents/Resources/node_modules/appium/9DEB6A49-B012-4E5A-9476-8CC4EDBFE866/bootstrap-a860e8c2e3014ca8.js:2702:30
bootstrap@file:///Users/diaojunxian/Desktop/Appium.app/Contents/Resources/node_modules/appium/9DEB6A49-B012-4E5A-9476-8CC4EDBFE866/bootstrap-a860e8c2e3014ca8.js:2770:31
global code@file:///Users/diaojunxian/Desktop/Appium.app/Contents/Resources/node_modules/appium/9DEB6A49-B012-4E5A-9476-8CC4EDBFE866/bootstrap-a860e8c2e3014ca8.js:2779:10
info: [debug] [INST] 2015-07-10 05:06:48 +0000 Debug: responding with:
info: [debug] [INST] 2015-07-10 05:06:48 +0000 Debug: Running system command #11: /Users/diaojunxian/Desktop/Appium.app/Contents/Resources/node/bin/node /Users/diaojunxian/Desktop/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{"status":17,"value":"target.frontMostApp().keyboard() failed to tap '1'"...
info: [debug] Socket data received (76 bytes)
info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {"status":17,"value":"target.frontMostApp().keyboard() failed to tap '1'"}
info: [debug] Responding to client with error: {"status":17,"value":{"message":"An error occurred while executing user supplied JavaScript.","origValue":"target.frontMostApp().keyboard() failed to tap '1'"},"sessionId":"f98383a2-e5e1-4c6d-b490-f680530f7b9e"}
info: <-- POST /wd/hub/session/f98383a2-e5e1-4c6d-b490-f680530f7b9e/element/2/value 500 2825.270 ms - 211
info: --> DELETE /wd/hub/session/f98383a2-e5e1-4c6d-b490-f680530f7b9e {}
info: Shutting down appium session
info: [debug] Stopping ios
info: [debug] Destroying instruments client socket.
info: [debug] Closing socket server.
info: [debug] Instruments socket server was closed
info: [debug] Sending sigterm to instruments
info: [debug] [INST] 2015-07-10 05:06:48 +0000 Stopped: Script was stopped by the user
info: [debug] [INST STDERR] 2015-07-10 13:06:49.047 instruments[1917:62694] Attempting to set event horizon when core is not engaged, request ignored
info: [debug] [INST STDERR] 2015-07-10 13:06:49.048 instruments[1917:62694] Attempting to set event horizon when core is not engaged, request ignored
info: [debug] [INST] Instruments Trace Complete (Duration : 37.316639s; Output : /tmp/appium-instruments/instrumentscli0.trace)
info: [debug] [INSTSERVER] Instruments exited with code 0
info: [debug] Cleaning up after instruments exit
info: [debug] Stopping iOS log capture
info: [debug] Reset not set, not ending sim or cleaning up app state
info: [debug] Cleaning up appium session
info: [debug] Responding to client with success: {"status":0,"value":null,"sessionId":"f98383a2-e5e1-4c6d-b490-f680530f7b9e"}
info: <-- DELETE /wd/hub/session/f98383a2-e5e1-4c6d-b490-f680530f7b9e 200 1545.987 ms - 76 {"status":0,"value":null,"sessionId":"f98383a2-e5e1-4c6d-b490-f680530f7b9e"}
#2 楼 @diao2007 https://github.com/appium/appium/issues/3713
有问题先 google 比较好
send_keys 这个方法比较诡异,适配性不是很好,我也碰到过输银行卡密码和手机短信验证码,验证码是 OK,银行卡密码死活不行的情况
info: [debug] [INST] 2015-07-10 05:06:47 +0000 Debug: Got new command 10 from instruments: au.getElement('2').setValueByType('18100002222')
info: [debug] [INST] 2015-07-10 05:06:47 +0000 Debug: evaluating au.getElement('2').setValueByType('18100002222')
info: [debug] [INST] 2015-07-10 05:06:47 +0000 Debug: No keyboard found. Tapping to make visible.
info: [debug] [INST] 2015-07-10 05:06:47 +0000 Debug: target.frontMostApp().elements()[0].elements()[10].tap()
info: [debug] [INST] 2015-07-10 05:06:47 +0000 Debug: Still no keyboard found. Tapping again to make visible.
看日志,提示了 no keyboard found,没有键盘,所以无法输入=。=
#3 楼 @eurekasaber
已经解决,谢谢,就是你提供的方法
#7 楼 @eurekasaber 好像不好加,我在图片的首位置加了,已解决,不明显好像。
弱弱地问下...测 ios 是不是必须要在 os x 操作系统里面
#9 楼 @chenhengjie123
已经标了呀,就是 楼上的提供的方法啊
#3 楼 @eurekasaber 你好,请问如何在 appium 的 python 脚本中获取到 iOS 平台的短信文本呢
#15 楼 @eurekasaber 我问过了,应该是不可以的。。iOS 没办法拦截短信
#3 楼 @eurekasaber
#6 楼 @diao2007 跪求你贴出解决这个问题的方法,我现在也碰到这个问题,很急~~~