Appium appium1.6.4 的 send_keys 不支持 zhongwen

小断腿 · 2017年05月12日 · 最后由 usky 回复于 2017年05月15日 · 2134 次阅读

代码

问题:
相同的代码,在 1.6.4 中,send_keys(” 中文 “) 没有反应
在 1.4.16 中能正常输入。这个是什么情况

共收到 13 条回复 时间 点赞

python 的话 send_keys(u'中文') 加个 u 看看

appium log:JSONWP Proxy] Proxying [POST /element] to [POST http://localhost:8200/wd/hub/session/e39eaa0e-a094-4e96-bf59-7773f89c6506/element] with body: {"strategy":"id","selector":"com.hk515.patient:id/rm","context":"","multiple":false}
[JSONWP Proxy] Got response with status 200: {"value":{"ELEMENT":"08319920-91d4-4c11-ba80-fbb4a7fa4c1b"},"status":0,"sessionId":"e39eaa0e-a094-4e96-bf59-7773f89c6506"}
[MJSONWP] Responding to client with driver.findElement() result: {"ELEMENT":"08319920-91d4-4c11-ba80-fbb4a7fa4c1b"}
[HTTP] <-- POST /wd/hub/session/049c6198-4f40-4cfb-85b0-fc453838041a/element 200 501 ms - 122
[HTTP] --> POST /wd/hub/session/049c6198-4f40-4cfb-85b0-fc453838041a/element/08319920-91d4-4c11-ba80-fbb4a7fa4c1b/value {"id":"08319920-91d4-4c11-ba80-fbb4a7fa4c1b","value":["正啊 kang"]}
[MJSONWP] Calling AppiumDriver.setValue() with args: [["正啊 kang"],"08319920-91d4-4c11-ba80-fbb4a7fa4c1b","049c6198-4f40-4cfb-85b0-fc453838041a"]
[JSONWP Proxy] Proxying [POST /element/08319920-91d4-4c11-ba80-fbb4a7fa4c1b/value] to [POST http://localhost:8200/wd/hub/session/e39eaa0e-a094-4e96-bf59-7773f89c6506/element/08319920-91d4-4c11-ba80-fbb4a7fa4c1b/value] with body: {"elementId":"08319920-91d4-4c11-ba80-fbb4a7fa4c1b","text":"正啊 kang","replace":false,"unicodeKeyboard":true}
[JSONWP Proxy] Got response with status 200: {"value":"","status":0,"sessionId":"e39eaa0e-a094-4e96-bf59-7773f89c6506"}
[MJSONWP] Responding to client with driver.setValue() result: ""

linpengcheng 回复

java 的,用 python 也试过,没有用

appium 1.4.16 的 log: info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"e4d10a9d-c40c-4dc5-8720-b7265b803374"}

info: <-- POST /wd/hub/session/e4d10a9d-c40c-4dc5-8720-b7265b803374/element/5/click 200 3890.120 ms - 76 {"status":0,"value":true,"sessionId":"e4d10a9d-c40c-4dc5-8720-b7265b803374"}
info: --> POST /wd/hub/session/e4d10a9d-c40c-4dc5-8720-b7265b803374/element {"using":"id","value":"com.hk515.patient:id/rm"}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"id","selector":"com.hk515.patient:id/rm","context":"","multiple":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.hk515.patient:id/rm","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 com.hk515.patient:id/rm using ID with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.hk515.patient:id/rm]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":{"ELEMENT":"6"},"status":0}
info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":"6"},"sessionId":"e4d10a9d-c40c-4dc5-8720-b7265b803374"}
info: <-- POST /wd/hub/session/e4d10a9d-c40c-4dc5-8720-b7265b803374/element 200 34.281 ms - 87 {"status":0,"value":{"ELEMENT":"6"},"sessionId":"e4d10a9d-c40c-4dc5-8720-b7265b803374"}
info: --> POST /wd/hub/session/e4d10a9d-c40c-4dc5-8720-b7265b803374/element/6/value {"id":"6","value":["姝e晩 kang"]}
info: [debug] Pushing command to appium work queue: ["element:setText",{"elementId":"6","text":"姝e晩 kang","replace":false,"unicodeKeyboard":true}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:setText","params":{"elementId":"6","text":"姝e晩 kang","replace":false,"unicodeKeyboard":true}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: setText
info: [debug] [BOOTSTRAP] [debug] Using element passed in.
info: [debug] [BOOTSTRAP] [debug] Attempting to clear using UiObject.clearText().
info: [debug] [BOOTSTRAP] [debug] Text remains after clearing, but it appears to be hint text.
info: [debug] [BOOTSTRAP] [debug] Text not cleared. Assuming remainder is hint text.
info: [debug] [BOOTSTRAP] [debug] Sending Unicode text to element: 姝e晩 kang
info: [debug] [BOOTSTRAP] [debug] Encoded text: &a2NVSg-kang
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}
info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"e4d10a9d-c40c-4dc5-8720-b7265b803374"}
info: <-- POST /wd/hub/session/e4d10a9d-c40c-4dc5-8720-b7265b803374/element/6/value 200 6771.138 ms - 76 {"status":0,"value":true,"sessionId":"e4d10a9d-c40c-4dc5-8720-b7265b803374"}

备注,输入的其实是中文 value:正啊 kang

set_value 试试

WebElement 没有这个方法吧

小断腿 回复

试试又何妨?set_value

山姆大叔 回复

老哥,我看 WebElement 没有 setValu
e 这个方法啊

小断腿 回复

直接 sendkeys(“中文”),确实不支持,另外如果是原生输入法,也没法输入中文,你用的是第三方的?

大海 回复

你是使用 1.6.4 不支持吗?1.4.16 可以支持吗?我这边也是这个情况,但是 1.4.16 又抓不到 toast

大海 回复

1.4.16 是原生的,可以支持输入中文,但是到了 1.6.4 就不可以了,一样的代码,一个的机器

我也碰到过,感觉跟机型有关。最后用自带的方法封装了一个点击输入框的动作,然后在用 adb 命令输入

用 set_text(), selenium 3.4 后 send_keys,就用不了了, 取而代之的是 set_value,输入速度提高了很多,set_text() 用来输入中文

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