1、需要把键盘隐藏并识别出被键盘覆盖的 “下一步” 控键。
2、我写的脚本是,self.driver.hide_keyboard(self,key_name="Return",key=None,strategy=None)
贴 appium server 的 log
#1 楼 @eurekasaber
nfo: [debug] Pushing command to appium work queue: "au.getElement('8').setValueByType('滨江大道 800 号明艳烟酒专卖店')"
info: [debug] Sending command to instruments: au.getElement('8').setValueByType('滨江大道 800 号明艳烟酒专卖店')
info: [debug] [INST] 2015-07-15 07:58:54 +0000 Debug: Running system command #60: /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":"8"}}...
info: [debug] [INST] 2015-07-15 07:58:55 +0000 Debug: Got new command 60 from instruments: au.getElement('8').setValueByType('滨江大道 800 号明艳烟酒专卖店')
info: [debug] [INST] 2015-07-15 07:58:55 +0000 Debug: evaluating au.getElement('8').setValueByType('滨江大道 800 号明艳烟酒专卖店')
info: [debug] [INST] 2015-07-15 07:58:55 +0000 Debug: No keyboard found. Tapping to make visible.
info: [debug] [INST] 2015-07-15 07:58:55 +0000 Debug: target.frontMostApp().elements()[0].elements()[15].tap()
info: [debug] [INST] 2015-07-15 07:58:55 +0000 Debug: Still no keyboard found. Tapping again to make visible.
info: [debug] [INST] 2015-07-15 07:58:55 +0000 Debug: target.frontMostApp().elements()[0].elements()[15].tap()
info: [debug] [INST] 2015-07-15 07:58:56 +0000 Debug: target.frontMostApp().elements()[0].elements()[15].tap()
info: [debug] [INST] 2015-07-15 07:58:57 +0000 Debug: evaluation finished
info: [debug] [INST] 2015-07-15 07:58:57 +0000 Debug: responding with:
info: [debug] [INST] 2015-07-15 07:58:57 +0000 Debug: Running system command #61: /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":""}...
info: [debug] Socket data received (25 bytes)
info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {"status":0,"value":""}
info: [debug] Responding to client with success: {"status":0,"value":"","sessionId":"530d5c1d-398f-48f5-a0df-6dc6b8b49bf4"}
info: <-- POST /wd/hub/session/530d5c1d-398f-48f5-a0df-6dc6b8b49bf4/element/8/value 200 2477.390 ms - 74 {"status":0,"value":"","sessionId":"530d5c1d-398f-48f5-a0df-6dc6b8b49bf4"}
info: --> DELETE /wd/hub/session/530d5c1d-398f-48f5-a0df-6dc6b8b49bf4 {}
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-15 07:59:02 +0000 Stopped: Script was stopped by the user
info: [debug] [INST STDERR] 2015-07-15 15:59:02.474 instruments[2038:75510] Attempting to set event horizon when core is not engaged, request ignored
info: [debug] [INST] Instruments Trace Complete (Duration : 155.390289s; 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":"530d5c1d-398f-48f5-a0df-6dc6b8b49bf4"}
#6 楼 @chenhengjie123
那应该正确的语法是什么呢?
请看官方文档:
https://github.com/appium/python-client#hiding-the-keyboard-in-ios
最后提醒一次,请使用 md,把日志改为代码块:
代码块
不懂 md 的麻烦花几分钟看看 排版说明
nfo: [debug] Pushing command to appium work queue: "au.getElement('8').setValueByType('滨江大道800号明艳烟酒专卖店')"
info: [debug] Sending command to instruments: au.getElement('8').setValueByType('滨江大道800号明艳烟酒专卖店')
info: [debug] [INST] 2015-07-15 07:58:54 +0000 Debug: Running system command #60: /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":"8"}}...
info: [debug] [INST] 2015-07-15 07:58:55 +0000 Debug: Got new command 60 from instruments: au.getElement('8').setValueByType('滨江大道800号明艳烟酒专卖店')
info: [debug] [INST] 2015-07-15 07:58:55 +0000 Debug: evaluating au.getElement('8').setValueByType('滨江大道800号明艳烟酒专卖店')
info: [debug] [INST] 2015-07-15 07:58:55 +0000 Debug: No keyboard found. Tapping to make visible.
info: [debug] [INST] 2015-07-15 07:58:55 +0000 Debug: target.frontMostApp().elements()[0].elements()[15].tap()
info: [debug] [INST] 2015-07-15 07:58:55 +0000 Debug: Still no keyboard found. Tapping again to make visible.
info: [debug] [INST] 2015-07-15 07:58:55 +0000 Debug: target.frontMostApp().elements()[0].elements()[15].tap()
info: [debug] [INST] 2015-07-15 07:58:56 +0000 Debug: target.frontMostApp().elements()[0].elements()[15].tap()
info: [debug] [INST] 2015-07-15 07:58:57 +0000 Debug: evaluation finished
info: [debug] [INST] 2015-07-15 07:58:57 +0000 Debug: responding with:
info: [debug] [INST] 2015-07-15 07:58:57 +0000 Debug: Running system command #61: /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":""}...
info: [debug] Socket data received (25 bytes)
info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {"status":0,"value":""}
info: [debug] Responding to client with success: {"status":0,"value":"","sessionId":"530d5c1d-398f-48f5-a0df-6dc6b8b49bf4"}
info: <-- POST /wd/hub/session/530d5c1d-398f-48f5-a0df-6dc6b8b49bf4/element/8/value 200 2477.390 ms - 74 {"status":0,"value":"","sessionId":"530d5c1d-398f-48f5-a0df-6dc6b8b49bf4"}
info: --> DELETE /wd/hub/session/530d5c1d-398f-48f5-a0df-6dc6b8b49bf4 {}
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-15 07:59:02 +0000 Stopped: Script was stopped by the user
info: [debug] [INST STDERR] 2015-07-15 15:59:02.474 instruments[2038:75510] Attempting to set event horizon when core is not engaged, request ignored
info: [debug] [INST] Instruments Trace Complete (Duration : 155.390289s; 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":"530d5c1d-398f-48f5-a0df-6dc6b8b49bf4"}```
参数多了一个,把 hide_keyboard() 方法中的 self 去掉试试