Appium Appium sendkeys 输入某些字符串时出现乱码

Tyrion · September 11, 2015 · Last by 陈恒捷 replied at September 11, 2015 · 1304 hits

最近在测试输入不同语言进行搜索,测试输入了很多字符串都没问题,但唯独有一个组合的字符串,输入进去的是乱码。
Java 代码:

driver.findElementById("clearable_edit").sendKeys("TéstBàe中国的臺灣テスト");

使用 genymotion 和 Android SDK 的 Emulator 都是一样的,输入时的结果:

麻烦各位看看这个是什么原因呢? 是转码的问题还是 Appium sendkeys 的 bug 呢?

下面 Appium log: 可以看到倒数第五行:Encoded text: T&AOk-stB&AOA-e&Ti1W,XaEgfpwYzDGMLkwy-,输入的也就是这个编码的字符串

info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[RESOURCE_ID=android:id/clearable_edit]
info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[INSTANCE=0, RESOURCE_ID=android:id/clearable_edit]
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[DESCRIPTION=clearable_edit]
info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[DESCRIPTION=clearable_edit]
info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[DESCRIPTION=clearable_edit, INSTANCE=0]
info: [debug] Responding to client with success: {"status":0,"value":[{"ELEMENT":"2"}],"sessionId":"fa3b8a95-5267-40fc-a9cf-e669ac9c0f22"}
info: <-- POST /wd/hub/session/fa3b8a95-5267-40fc-a9cf-e669ac9c0f22/elements 200 70.222 ms - 89 {"status":0,"value":[{"ELEMENT":"2"}],"sessionId":"fa3b8a95-5267-40fc-a9cf-e669ac9c0f22"}
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":[{"ELEMENT":"2"}],"status":0}
info: --> POST /wd/hub/session/fa3b8a95-5267-40fc-a9cf-e669ac9c0f22/timeouts/implicit_wait {"ms":1000}
info: [debug] Set Android implicit wait to 1000ms
info: [debug] Responding to client with success: {"status":0,"value":null,"sessionId":"fa3b8a95-5267-40fc-a9cf-e669ac9c0f22"}
info: <-- POST /wd/hub/session/fa3b8a95-5267-40fc-a9cf-e669ac9c0f22/timeouts/implicit_wait 200 0.673 ms - 76 {"status":0,"value":null,"sessionId":"fa3b8a95-5267-40fc-a9cf-e669ac9c0f22"}
info: --> POST /wd/hub/session/fa3b8a95-5267-40fc-a9cf-e669ac9c0f22/element/2/value {"id":"2","value":["TéstBàe中国的臺灣テスト"]}
info: [debug] Pushing command to appium work queue: ["element:setText",{"elementId":"2","text":"TéstBàe中国的臺灣テスト","replace":false,"unicodeKeyboard":true}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:setText","params":{"elementId":"2","text":"TéstBàe中国的臺灣テスト","replace":false,"unicodeKeyboard":true}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTST
RAP] [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: TéstBàe中国的臺灣テスト
info: [debug] [BOOTSTRAP] [debug] Closing tag missing. Adding.
info: [debug] [BOOTSTRAP] [debug] Encoded text: T&AOk-stB&AOA-e&Ti1W,XaEgfpwYzDGMLkwy-

info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"fa3b8a95-5267-40fc-a9cf-e669ac9c0f22"}

info: <-- POST /wd/hub/session/fa3b8a95-5267-40fc-a9cf-e669ac9c0f22/element/2/value 200 5170.886 ms - 76 {"status":0,"value":true,"sessionId":"fa3b8a95-5267-40fc-a9cf-e669ac9c0f22"}
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}
共收到 1 条回复 时间 点赞
info: [debug] [BOOTSTRAP] [debug] Encoded text: T&AOk-stB&AOA-e&Ti1W,XaEgfpwYzDGMLkwy-

应该是 encode 时出错了。

需要 Sign In 后方可回复, 如果你还没有账号请点击这里 Sign Up