Appium Appium IOS 键盘隐藏出错

不二家 · 2015年07月15日 · 最后由 xiaoyan 回复于 2017年10月18日 · 1552 次阅读

1、需要把键盘隐藏并识别出被键盘覆盖的 “下一步” 控键。
2、我写的脚本是,self.driver.hide_keyboard(self,key_name="Return",key=None,strategy=None)

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
共收到 12 条回复 时间 点赞

贴 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"}

#3 楼 @monkey 好的以后会注意,谢谢

#4 楼 @diao2007 不要以后。。。现在改不行吗?就几分钟的事情。

#4 楼 @diao2007 另外,你这是 python 的语法吗?错误信息说得很明显了:

hide_keyboard() got multiple values for keyword argument 'key_name'

你调用 hide_keyboard() 的写法有问题。

#6 楼 @chenhengjie123
那应该正确的语法是什么呢?

请看官方文档:
https://github.com/appium/python-client#hiding-the-keyboard-in-ios

最后提醒一次,请使用 md,把日志改为代码块:

代码块

不懂 md 的麻烦花几分钟看看 排版说明

#8 楼 @chenhengjie123

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"}```

#9 楼 @diao2007

info: [debug] [INST] 2015-07-15 07:58:55 +0000 Debug: No keyboard found. Tapping to make visible.

跑到这一步时在屏幕上有出现键盘吗?

参数多了一个,把 hide_keyboard() 方法中的 self 去掉试试

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册